mlkem

package
v1.17.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2025 License: BSD-3-Clause Imports: 9 Imported by: 8

Documentation

Index

Constants

View Source
const (
	// ML-KEM-512 (Level 1 security)
	MLKEM512PublicKeySize    = mlkem512.PublicKeySize
	MLKEM512PrivateKeySize   = mlkem512.PrivateKeySize
	MLKEM512CiphertextSize   = mlkem512.CiphertextSize
	MLKEM512SharedSecretSize = mlkem512.SharedKeySize

	// ML-KEM-768 (Level 3 security)
	MLKEM768PublicKeySize    = mlkem768.PublicKeySize
	MLKEM768PrivateKeySize   = mlkem768.PrivateKeySize
	MLKEM768CiphertextSize   = mlkem768.CiphertextSize
	MLKEM768SharedSecretSize = mlkem768.SharedKeySize

	// ML-KEM-1024 (Level 5 security)
	MLKEM1024PublicKeySize    = mlkem1024.PublicKeySize
	MLKEM1024PrivateKeySize   = mlkem1024.PrivateKeySize
	MLKEM1024CiphertextSize   = mlkem1024.CiphertextSize
	MLKEM1024SharedSecretSize = mlkem1024.SharedKeySize
)

Security parameters for ML-KEM (Module Lattice Key Encapsulation Mechanism)

Variables

This section is empty.

Functions

func DeserializeDRY

func DeserializeDRY(bytes []byte, expectedSize int, typeName string) ([]byte, error)

DeserializeDRY provides unified deserialization

func GenerateKeyPair

func GenerateKeyPair(rand io.Reader, mode Mode) (*PrivateKey, *PublicKey, error)

GenerateKeyPair generates a new ML-KEM key pair using REAL implementation

func SerializeDRY

func SerializeDRY(data []byte, expectedSize int, typeName string) ([]byte, error)

SerializeDRY provides unified serialization

Types

type BatchKEM

type BatchKEM struct {
	// contains filtered or unexported fields
}

Batch operations for better throughput

func NewBatchKEM

func NewBatchKEM(mode Mode, numKeys int) (*BatchKEM, error)

NewBatchKEM creates a batch KEM processor

func (*BatchKEM) EncapsulateBatch

func (b *BatchKEM) EncapsulateBatch(rand io.Reader) ([][]byte, [][]byte, error)

EncapsulateBatch performs batch encapsulation

type EncapsulationResult

type EncapsulationResult struct {
	Ciphertext   []byte
	SharedSecret []byte
}

EncapsulationResult holds the result of encapsulation

type Mode

type Mode int

Mode represents the ML-KEM parameter set

const (
	MLKEM512  Mode = iota // Level 1 security
	MLKEM768              // Level 3 security
	MLKEM1024             // Level 5 security
)

func (Mode) String added in v1.4.16

func (m Mode) String() string

String returns the string representation of the mode

type PrivateKey

type PrivateKey struct {
	PublicKey *PublicKey
	// contains filtered or unexported fields
}

PrivateKey represents an ML-KEM private key

func GenerateKeyPairDRY

func GenerateKeyPairDRY(random io.Reader, mode Mode) (*PrivateKey, error)

GenerateKeyPairDRY generates a key pair using DRY principles

func GenerateKeyPairOptimized

func GenerateKeyPairOptimized(rand io.Reader, mode Mode) (*PrivateKey, error)

Optimized key generation with pre-allocated buffers

func PrivateKeyFromBytes

func PrivateKeyFromBytes(data []byte, mode Mode) (*PrivateKey, error)

PrivateKeyFromBytes reconstructs a private key from bytes

func (*PrivateKey) Bytes

func (priv *PrivateKey) Bytes() []byte

Bytes returns the private key as bytes

func (*PrivateKey) Decapsulate

func (priv *PrivateKey) Decapsulate(ciphertext []byte) (sharedSecret []byte, err error)

Decapsulate recovers the shared secret from ciphertext using REAL implementation

func (*PrivateKey) DecapsulateDRY

func (priv *PrivateKey) DecapsulateDRY(ciphertext []byte) ([]byte, error)

DecapsulateDRY performs decapsulation using DRY principles

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

PublicKey represents an ML-KEM public key

func PublicKeyFromBytes

func PublicKeyFromBytes(data []byte, mode Mode) (*PublicKey, error)

PublicKeyFromBytes reconstructs a public key from bytes

func (*PublicKey) Bytes

func (pub *PublicKey) Bytes() []byte

Bytes returns the public key as bytes

func (*PublicKey) Encapsulate

func (pub *PublicKey) Encapsulate(rand io.Reader) (*EncapsulationResult, error)

Encapsulate generates a ciphertext and shared secret using REAL implementation

func (*PublicKey) EncapsulateDRY

func (pub *PublicKey) EncapsulateDRY(random io.Reader) ([]byte, []byte, error)

EncapsulateDRY performs encapsulation using DRY principles

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL