Documentation
¶
Overview ¶
Package mlkem provides a wrapper around github.com/cloudflare/circl/kem/mlkem for ML-KEM (Module-Lattice-based Key Encapsulation Mechanism) support.
Index ¶
- Constants
- Variables
- func GenerateKey(mode Mode) (*PublicKey, *PrivateKey, error)
- func GenerateKeyPair(reader io.Reader, mode Mode) (*PublicKey, *PrivateKey, error)
- func GetCiphertextSize(mode Mode) int
- func GetPrivateKeySize(mode Mode) int
- func GetPublicKeySize(mode Mode) int
- type Mode
- type PrivateKey
- type PublicKey
Constants ¶
const ( MLKEM512PublicKeySize = mlkem512.PublicKeySize MLKEM512PrivateKeySize = mlkem512.PrivateKeySize MLKEM512CiphertextSize = mlkem512.CiphertextSize )
Key size constants for ML-KEM-512
const ( MLKEM768PublicKeySize = mlkem768.PublicKeySize MLKEM768PrivateKeySize = mlkem768.PrivateKeySize MLKEM768CiphertextSize = mlkem768.CiphertextSize )
Key size constants for ML-KEM-768
const ( MLKEM1024PublicKeySize = mlkem1024.PublicKeySize MLKEM1024PrivateKeySize = mlkem1024.PrivateKeySize MLKEM1024CiphertextSize = mlkem1024.CiphertextSize )
Key size constants for ML-KEM-1024
Variables ¶
var ErrInvalidCiphertextSize = errors.New("invalid ciphertext size")
ErrInvalidCiphertextSize is returned when a ciphertext has an incorrect size
var ErrInvalidKeySize = errors.New("invalid key size")
ErrInvalidKeySize is returned when a key has an incorrect size
Functions ¶
func GenerateKey ¶ added in v1.4.18
func GenerateKey(mode Mode) (*PublicKey, *PrivateKey, error)
GenerateKey generates a new ML-KEM key pair using crypto/rand
func GenerateKeyPair ¶
GenerateKeyPair generates a new ML-KEM key pair with a specific reader
func GetCiphertextSize ¶ added in v1.4.18
GetCiphertextSize returns the size of a ciphertext for the given mode
func GetPrivateKeySize ¶ added in v1.4.18
GetPrivateKeySize returns the size of a private key for the given mode
func GetPublicKeySize ¶ added in v1.4.18
GetPublicKeySize returns the size of a public key for the given mode
Types ¶
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
PrivateKey represents a ML-KEM private key
func PrivateKeyFromBytes ¶
func PrivateKeyFromBytes(data []byte, mode Mode) (*PrivateKey, error)
PrivateKeyFromBytes creates a private key from its byte representation
func (*PrivateKey) Bytes ¶
func (sk *PrivateKey) Bytes() []byte
Bytes returns the byte representation of the private key
func (*PrivateKey) Decapsulate ¶
func (sk *PrivateKey) Decapsulate(ciphertext []byte) ([]byte, error)
Decapsulate recovers the shared secret from a ciphertext
func (*PrivateKey) Equal ¶ added in v1.4.18
func (sk *PrivateKey) Equal(other *PrivateKey) bool
Equal reports whether sk and other represent the same private key
func (*PrivateKey) PublicKey ¶
func (sk *PrivateKey) PublicKey() *PublicKey
PublicKey returns the public key corresponding to this private key
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey represents a ML-KEM public key
func PublicKeyFromBytes ¶
PublicKeyFromBytes creates a public key from its byte representation
func (*PublicKey) Encapsulate ¶
Encapsulate generates a shared secret and ciphertext