Skip to Content
oxcrypto

ML-KEM

Module-lattice KEM from FIPS 203.

from oxcrypto.kem.ml_kem import ML_KEM

private_key = ML_KEM.ML_KEM_768.generate()
ciphertext, shared_secret = private_key.public_key().encapsulate()
assert private_key.decapsulate(ciphertext) == shared_secret
VariantPrivate keyPublic keyCiphertextShared secret
ML_KEM_51264 bytes800 bytes768 bytes32 bytes
ML_KEM_76864 bytes1184 bytes1088 bytes32 bytes
ML_KEM_102464 bytes1568 bytes1568 bytes32 bytes

Private keys serialize as the 64-byte seed d || z from FIPS 203. The expanded decapsulation key format is not accepted; the upstream crate deprecates it. load_public_key applies the FIPS 203 encapsulation key check and raises ValueError for a key that fails it.

  • Standard: FIPS 203 (August 2024).
  • Crate: RustCrypto ml-kem 0.3.4, stable release, no published audit. Builds with Rust 1.88.
  • Vectors: NIST ACVP-Server ML-KEM-keyGen-FIPS203 and ML-KEM-encapDecap-FIPS203 (key generation, encapsulation, decapsulation, key checks). Encapsulation and decapsulation vectors and differential tests against libcrux-ml-kem 0.0.10 run in Rust (tests/ml_kem.rs); libcrux is a development-only dependency and is not part of the wheel.

Zeroization

Retained state: the decapsulation key holds the PKE secret vector, the seed d, the implicit-rejection value z and the public encapsulation key. With the zeroize feature, ml-kem wipes the secret parts on drop.

Short-lived copies not wiped by the upstream crate: the decapsulation intermediates (decrypted message, re-encryption randomness, candidate shared keys) and the shared key array before oxcrypto copies it into a wiped buffer.

oxcrypto enables the zeroize features of sha3 and shake, so the upstream SHA-3 and SHAKE states are wiped on drop.

On this page