Documentation
¶
Overview ¶
Package crypto provides post-quantum cryptographic operations for SessionVM using github.com/luxfi/crypto for ML-KEM-768 and ML-DSA-65.
Index ¶
- Constants
- Variables
- func Decapsulate(secretKey, ciphertext []byte) (sharedSecret []byte, err error)
- func Decrypt(key, ciphertext []byte) ([]byte, error)
- func DecryptFromSender(secretKey, ciphertext []byte) ([]byte, error)
- func DeriveSessionID(kemPublicKey, dsaPublicKey []byte) (string, error)
- func Encapsulate(recipientPublicKey []byte) (ciphertext, sharedSecret []byte, err error)
- func Encrypt(key, plaintext []byte) ([]byte, error)
- func EncryptToRecipient(recipientPublicKey, plaintext []byte) ([]byte, error)
- func Sign(secretKey, message []byte) (signature []byte, err error)
- func Verify(publicKey, message, signature []byte) bool
- type Identity
- func (i *Identity) DecryptFrom(ciphertext []byte) ([]byte, error)
- func (i *Identity) EncryptTo(recipient *Identity, plaintext []byte) ([]byte, error)
- func (i *Identity) PublicIdentity() *Identity
- func (i *Identity) SignMessage(message []byte) ([]byte, error)
- func (i *Identity) VerifyMessage(signedMessage []byte) ([]byte, bool)
Constants ¶
const ( // PQ Session ID prefix (07 = post-quantum) PQPrefix = "07" // Legacy Session ID prefix (05 = X25519/Ed25519) LegacyPrefix = "05" // ML-KEM-768 sizes (NIST Level 3, FIPS 203) MLKEMPublicKeySize = mlkem.MLKEM768PublicKeySize MLKEMSecretKeySize = mlkem.MLKEM768PrivateKeySize MLKEMCiphertextSize = mlkem.MLKEM768CiphertextSize // ML-DSA-65 sizes (NIST Level 3, FIPS 204) MLDSAPublicKeySize = mldsa.MLDSA65PublicKeySize MLDSASecretKeySize = mldsa.MLDSA65PrivateKeySize MLDSASignatureSize = mldsa.MLDSA65SignatureSize )
Variables ¶
Functions ¶
func Decapsulate ¶
Decapsulate performs ML-KEM-768 key decapsulation
func DecryptFromSender ¶
DecryptFromSender decrypts a message using our secret key
func DeriveSessionID ¶
DeriveSessionID derives a session ID from public keys
func Encapsulate ¶
Encapsulate performs ML-KEM-768 key encapsulation Returns: ciphertext, shared secret
func EncryptToRecipient ¶
EncryptToRecipient encrypts a message for a recipient using their public key
Types ¶
type Identity ¶
type Identity struct {
// Session ID: "07" + hex(Blake2b-256(KEM_pk || DSA_pk))
SessionID string `json:"sessionId"`
// ML-KEM-768 keypair (for receiving encrypted messages)
KEMPublicKey []byte `json:"kemPublicKey"`
KEMSecretKey []byte `json:"kemSecretKey,omitempty"`
// ML-DSA-65 keypair (for signing messages)
DSAPublicKey []byte `json:"dsaPublicKey"`
DSASecretKey []byte `json:"dsaSecretKey,omitempty"`
// contains filtered or unexported fields
}
Identity represents a post-quantum identity for the Session network
func GenerateIdentity ¶
GenerateIdentity creates a new post-quantum identity using ML-KEM-768 and ML-DSA-65
func (*Identity) DecryptFrom ¶
DecryptFrom decrypts a message from a sender
func (*Identity) PublicIdentity ¶
PublicIdentity returns only the public parts of the identity
func (*Identity) SignMessage ¶
SignMessage signs a message and returns signature with message prepended