mlkem

Imports

Imports #

"crypto/internal/fips140/mlkem"

Constants & Variables

CiphertextSize1024 const #

CiphertextSize1024 is the size of a ciphertext produced by ML-KEM-1024.

const CiphertextSize1024 = 1568

CiphertextSize768 const #

CiphertextSize768 is the size of a ciphertext produced by ML-KEM-768.

const CiphertextSize768 = 1088

EncapsulationKeySize1024 const #

EncapsulationKeySize1024 is the size of an ML-KEM-1024 encapsulation key.

const EncapsulationKeySize1024 = 1568

EncapsulationKeySize768 const #

EncapsulationKeySize768 is the size of an ML-KEM-768 encapsulation key.

const EncapsulationKeySize768 = 1184

SeedSize const #

SeedSize is the size of a seed used to generate a decapsulation key.

const SeedSize = 64

SharedKeySize const #

SharedKeySize is the size of a shared key produced by ML-KEM.

const SharedKeySize = 32

Structs

DecapsulationKey1024 struct #

DecapsulationKey1024 is the secret key used to decapsulate a shared key from a ciphertext. It includes various precomputed values.

type DecapsulationKey1024 struct {
key *mlkem.DecapsulationKey1024
}

DecapsulationKey768 struct #

DecapsulationKey768 is the secret key used to decapsulate a shared key from a ciphertext. It includes various precomputed values.

type DecapsulationKey768 struct {
key *mlkem.DecapsulationKey768
}

EncapsulationKey1024 struct #

An EncapsulationKey1024 is the public key used to produce ciphertexts to be decapsulated by the corresponding DecapsulationKey1024.

type EncapsulationKey1024 struct {
key *mlkem.EncapsulationKey1024
}

EncapsulationKey768 struct #

An EncapsulationKey768 is the public key used to produce ciphertexts to be decapsulated by the corresponding DecapsulationKey768.

type EncapsulationKey768 struct {
key *mlkem.EncapsulationKey768
}

Functions

Bytes method #

Bytes returns the decapsulation key as a 64-byte seed in the "d || z" form. The decapsulation key must be kept secret.

func (dk *DecapsulationKey1024) Bytes() []byte

Bytes method #

Bytes returns the decapsulation key as a 64-byte seed in the "d || z" form. The decapsulation key must be kept secret.

func (dk *DecapsulationKey768) Bytes() []byte

Bytes method #

Bytes returns the encapsulation key as a byte slice.

func (ek *EncapsulationKey1024) Bytes() []byte

Bytes method #

Bytes returns the encapsulation key as a byte slice.

func (ek *EncapsulationKey768) Bytes() []byte

Decapsulate method #

Decapsulate generates a shared key from a ciphertext and a decapsulation key. If the ciphertext is not valid, Decapsulate returns an error. The shared key must be kept secret.

func (dk *DecapsulationKey768) Decapsulate(ciphertext []byte) (sharedKey []byte, err error)

Decapsulate method #

Decapsulate generates a shared key from a ciphertext and a decapsulation key. If the ciphertext is not valid, Decapsulate returns an error. The shared key must be kept secret.

func (dk *DecapsulationKey1024) Decapsulate(ciphertext []byte) (sharedKey []byte, err error)

Encapsulate method #

Encapsulate generates a shared key and an associated ciphertext from an encapsulation key, drawing random bytes from the default crypto/rand source. The shared key must be kept secret.

func (ek *EncapsulationKey1024) Encapsulate() (sharedKey []byte, ciphertext []byte)

Encapsulate method #

Encapsulate generates a shared key and an associated ciphertext from an encapsulation key, drawing random bytes from the default crypto/rand source. The shared key must be kept secret.

func (ek *EncapsulationKey768) Encapsulate() (sharedKey []byte, ciphertext []byte)

EncapsulationKey method #

EncapsulationKey returns the public encapsulation key necessary to produce ciphertexts.

func (dk *DecapsulationKey1024) EncapsulationKey() *EncapsulationKey1024

EncapsulationKey method #

EncapsulationKey returns the public encapsulation key necessary to produce ciphertexts.

func (dk *DecapsulationKey768) EncapsulationKey() *EncapsulationKey768

GenerateKey1024 function #

GenerateKey1024 generates a new decapsulation key, drawing random bytes from the default crypto/rand source. The decapsulation key must be kept secret.

func GenerateKey1024() (*DecapsulationKey1024, error)

GenerateKey768 function #

GenerateKey768 generates a new decapsulation key, drawing random bytes from the default crypto/rand source. The decapsulation key must be kept secret.

func GenerateKey768() (*DecapsulationKey768, error)

NewDecapsulationKey1024 function #

NewDecapsulationKey1024 expands a decapsulation key from a 64-byte seed in the "d || z" form. The seed must be uniformly random.

func NewDecapsulationKey1024(seed []byte) (*DecapsulationKey1024, error)

NewDecapsulationKey768 function #

NewDecapsulationKey768 expands a decapsulation key from a 64-byte seed in the "d || z" form. The seed must be uniformly random.

func NewDecapsulationKey768(seed []byte) (*DecapsulationKey768, error)

NewEncapsulationKey1024 function #

NewEncapsulationKey1024 parses an encapsulation key from its encoded form. If the encapsulation key is not valid, NewEncapsulationKey1024 returns an error.

func NewEncapsulationKey1024(encapsulationKey []byte) (*EncapsulationKey1024, error)

NewEncapsulationKey768 function #

NewEncapsulationKey768 parses an encapsulation key from its encoded form. If the encapsulation key is not valid, NewEncapsulationKey768 returns an error.

func NewEncapsulationKey768(encapsulationKey []byte) (*EncapsulationKey768, error)

Generated with Arrow