Class: KEM
Defined in: kem.ts:139
Pure ML-KEM (ML-KEM-512/768/1024), matching quantum-safe-py's KEM. Not recommended for new deployments during the transition period; prefer HybridKEM.
Extends
BaseKem
Constructors
Constructor
new KEM(
algorithm?):KEM
Defined in: kem.ts:146
Creates a pure ML-KEM instance.
Parameters
algorithm?
"ML-KEM-512" | "ML-KEM-768" | "ML-KEM-1024" = 'ML-KEM-768'
ML-KEM-512, ML-KEM-768 or ML-KEM-1024. Default ML-KEM-768.
Returns
KEM
Throws
if algorithm is not a supported pure KEM.
Throws
if init() has not completed.
Overrides
BaseKem.constructor
Properties
algorithm
readonlyalgorithm:KemAlgorithm
Defined in: kem.ts:33
Canonical algorithm string.
Inherited from
BaseKem.algorithm
info
readonlyinfo:SuiteInfo
Defined in: kem.ts:35
Suite metadata (NIST level, CNSA 2.0 status, …).
Inherited from
BaseKem.info
Methods
decapsulate()
decapsulate(
secretKey,ciphertext):SecretBytes
Defined in: kem.ts:95
Recovers the shared secret from ciphertext.
ML-KEM uses implicit rejection (FIPS 203): a ciphertext that was not produced for this key yields a pseudorandom secret rather than an error, so a wrong ciphertext is detected downstream (for example by AEAD authentication), not here.
Parameters
secretKey
The recipient's secret key for this KEM's algorithm.
ciphertext
Uint8Array
The ciphertext field of the Encapsulation returned by encapsulate().
Returns
The shared secret; free it when done.
Throws
if the ciphertext has the wrong structure or length.
Throws
if the key belongs to a different algorithm.
Throws
if the classical component of a hybrid fails.
Throws
if secretKey is not a SecretKey, has been freed, or ciphertext is not bytes.
Inherited from
BaseKem.decapsulate
encapsulate()
encapsulate(
publicKey):Encapsulation
Defined in: kem.ts:66
Encapsulates a fresh shared secret to publicKey.
Parameters
publicKey
The recipient's public key for this KEM's algorithm.
Returns
The ciphertext to send and the 32-byte shared secret; free the secret when done.
Throws
if the key belongs to a different algorithm.
Throws
if the key bytes are invalid.
Throws
if publicKey is not a PublicKey or has been freed.
Inherited from
BaseKem.encapsulate
generateKeyPair()
generateKeyPair():
KeyPair
Defined in: kem.ts:54
Generates a key pair. Free it (or use using) when done.
Returns
A new key pair for this KEM's algorithm.
Throws
if init() has not completed.
Inherited from
BaseKem.generateKeyPair