← Back to section · Post-Quantum Cryptography
ML-KEM Explained: Reading NIST's Post-Quantum Key-Encapsulation Standard (FIPS 203)
Starting from why we need key encapsulation at all, a systematic reading of FIPS 203: the Module-LWE foundation, the three parameter sets, the three core algorithms, and how ML-KEM relates to CRYSTALS-Kyber.
Why key encapsulation comes first
Almost every secure connection on today’s internet begins by agreeing on a shared session key. RSA key transport is long gone; the mainstream mechanism is elliptic-curve Diffie–Hellman (ECDH) — and like RSA, it falls to Shor’s algorithm on a sufficiently large quantum computer.
The first building block of the post-quantum migration is therefore a primitive called a Key Encapsulation Mechanism (KEM): one party uses the other’s public key to “encapsulate” a random shared secret, and the other party “decapsulates” it with the private key. On 13 August 2024, NIST published FIPS 203, making ML-KEM the first standardized post-quantum KEM and the default choice for migration work today.
The foundation: Module-LWE
ML-KEM’s security rests on the Module Learning With Errors problem (Module-LWE). Intuitively: given a matrix and a product perturbed by small noise, , recovering the secret vector is believed to be hard — for classical and quantum computers alike.
It works in the polynomial ring with modulus . All operations can be carried out efficiently with the Number Theoretic Transform (NTT), a major reason ML-KEM is fast and implementation-friendly.
Three parameter sets
FIPS 203 defines three parameter sets, aligned with three NIST security categories. The shared secret is always 32 bytes:
| Parameter set | Category | Encapsulation key (bytes) | Decapsulation key (bytes) | Ciphertext (bytes) |
|---|---|---|---|---|
| ML-KEM-512 | 1 (≈ AES-128) | 800 | 1632 | 768 |
| ML-KEM-768 | 3 (≈ AES-192) | 1184 | 2400 | 1088 |
| ML-KEM-1024 | 5 (≈ AES-256) | 1568 | 3168 | 1568 |
ML-KEM-768 is the deployment default today: a comfortable security margin, with a public key and ciphertext of about 1.1 KB each — acceptable inside a TLS handshake. For contrast, an X25519 public key is 32 bytes. A real cost of post-quantum migration is larger handshakes, and any serious assessment has to budget for it.
The knobs behind the parameters
The main difference between the three sets is the dimension k of the polynomial vector, which takes the values 2, 3 and 4: larger k makes the lattice problem harder, and keys and ciphertexts grow accordingly. A less visible but equally critical parameter is the decapsulation failure probability δ. Ciphertexts are compressed before transmission (the parameters du and dv fix how many bits of each coefficient survive), and compression is lossy: with very small probability, noise and compression error combine to make decapsulation recover the wrong message. FIPS 203 bounds δ at roughly 2^-139 (512), 2^-165 (768) and 2^-175 (1024) — low enough to be treated as never occurring in practice.
That number is not decoration. The CCA security argument for the FO transform requires failures to be sufficiently rare: if failure events were observable at any meaningful rate, an attacker could use “which ciphertexts fail” as an oracle and gradually extract the private key (a failure-boosting attack). Parameter selection therefore weighs not just classical and quantum security levels, but how much margin the failure probability keeps — one reason the parameter sets accept larger sizes rather than compressing more aggressively.
The three core algorithms
- KeyGen: expands a random seed into the matrix , samples secret and noise, and produces the encapsulation and decapsulation keys.
- Encaps: encrypts a random message under the public key and hashes it, producing a ciphertext and the 32-byte shared secret.
- Decaps: recovers the message with the private key, re-encrypts and compares the ciphertext (the Fujisaki–Okamoto transform); the shared secret is accepted only on a match, and on mismatch a pseudorandom “implicit rejection” value derived from the private key is returned instead — failure leaks nothing.
This construction gives ML-KEM IND-CCA2 security: even an attacker who can ask the system to decapsulate chosen ciphertexts gains no advantage.
How the standard is layered inside
Open FIPS 203 and ML-KEM turns out to be defined in layers rather than in one step. At the bottom sits an internal public-key encryption scheme, K-PKE: an IND-CPA-secure primitive (secure against chosen-plaintext attacks) that does the actual Module-LWE encryption and decryption. K-PKE alone cannot serve as a KEM — it has no defence against tampered ciphertexts, and anyone can modify a ciphertext and watch what decryption produces.
The layer above performs the lift from PKE to KEM: decapsulation first decrypts with K-PKE, then re-encrypts the recovered message under the public key and compares it byte-for-byte with the received ciphertext, falling back to implicit rejection on any mismatch. The hash functions have explicitly divided labour: G expands seeds and messages into sampling randomness and the shared secret’s source material, H computes a “fingerprint” of the encapsulation key that is bound into key derivation (so a ciphertext cannot be transplanted under a different key), and J derives the pseudorandom value used for implicit rejection. Each hash input serves a single purpose and is never reused across steps — this strict domain separation is one of the places where FIPS 203 changed most relative to earlier Kyber versions, closing off cross-step and cross-parameter-set confusion attacks.
The layering pays off in practice: auditing an ML-KEM implementation can proceed layer by layer — is K-PKE’s sampling and NTT constant-time, is the re-encryption comparison actually performed in full, does the domain separation match the standard — instead of treating the whole implementation as a black box.
Relation to CRYSTALS-Kyber
ML-KEM descends from the academic scheme CRYSTALS-Kyber, one of the first algorithms NIST selected in July 2022. During standardization NIST made a handful of changes — for instance in how key generation consumes randomness, and in encoding and hashing details — so a FIPS 203 implementation is not byte-for-byte compatible with the final-round Kyber specification. When testing interoperability, look for “ML-KEM / FIPS 203” explicitly; do not assume a “Kyber” implementation can be mixed in.
Implementation and deployment notes
Key storage hides an easy trap: the FIPS 203 decapsulation key is not a bare secret vector. It packages the encapsulation key, a hash of that key, and a random value z alongside the secret — which is exactly why the decapsulation key is more than twice the size of the public key. The value z is the seed from which implicit-rejection secrets are derived; lose it or corrupt it and the failure path no longer behaves as standardized. When systems exchange or back up private keys, they must use the complete standard encoding, not store a “core secret” and expect the other side to reconstruct the rest.
Input validation is likewise part of the standard: before encapsulating, the public key undergoes encoding and modulus checks (every coefficient must lie in range), and key generation, encapsulation and decapsulation each carry prescribed checks. “Optimized” implementations that skip them may accept malformed inputs and leave doors open to fault and cross-protocol attacks. Prefer implementations validated against the official test vectors, and re-run those vectors after every upgrade as a matter of routine.
Finally, randomness: the security of key generation and encapsulation depends directly on the quality of the system random source. VM snapshot rollbacks and entropy-starved first boots on embedded devices are classic accident scenes; wherever ML-KEM is deployed in such environments, the health of the entropy source deserves the same audit attention as the algorithm itself.
Deployment status (as of November 2026)
Mainstream browsers and large CDNs have enabled hybrid key exchange — X25519 together with ML-KEM-768 — in TLS 1.3: both algorithms run at once, and the connection stays secure as long as either one holds. This is the most prudent migration posture available today: post-quantum protection now, classical assurance retained, with a switch to pure post-quantum once the ecosystem matures.
Summary
ML-KEM answers the question “how do we agree on keys in the quantum era”: based on Module-LWE, three parameter sets spanning AES-128 to AES-256 security levels, with 768 as the current deployment sweet spot. Next, we get hands-on: the tutorials run a real ML-KEM key generation, encapsulation and decapsulation with liboqs.
References
- NIST, FIPS 203: Module-Lattice-Based Key-Encapsulation Mechanism Standard, 2024-08-13. https://doi.org/10.6028/NIST.FIPS.203
- NIST, Post-Quantum Cryptography Standardization (project page). https://csrc.nist.gov/projects/post-quantum-cryptography
- Bos, J. et al., CRYSTALS – Kyber: a CCA-secure module-lattice-based KEM, IEEE EuroS&P 2018. https://eprint.iacr.org/2017/634
Tags: ML-KEMFIPS 203NISTKey Encapsulation