Has it been Pwned

How ML-KEM works

A sender and a receiver agree on a secret by calculating two slightly different versions of the same quantity. The receiver knows how to round away the difference.

Program status. FIPS 203 defines ML-KEM-512, ML-KEM-768 and ML-KEM-1024. The guide uses the final standard published in August 2024. NIST program history

See what Anthropic’s lattice papers mean for ML-KEM.

Why both parties get the same bits

Suppose a public calculation gives a number close to either zero or halfway around a clock. Someone who knows how to remove a much larger term can tell which position was intended. ML-KEM arranges one such decision for each bit of an internally generated value. Strangers see the large terms mixed with small, deliberately sampled errors.

The public calculation uses modular arithmetic, in which numbers wrap around at a fixed modulus. Several hundred coefficients take part. The security question is whether an outsider can distinguish noisy products involving a secret from independent random data. Rounding works for the receiver because the two calculations have a common term that only the receiver can cancel.

The cancellation

t = A s + e; u = Aᵀ r + e₁; v = tᵀ r + e₂ + μ

A is a public matrix, s the receiver’s small secret vector, r the sender’s fresh small vector, and e, e₁ and e₂ small errors. The superscript T transposes a vector or matrix. The polynomial μ encodes the bits. These equations show the encryption core before ciphertext compression.

Every matrix entry is a polynomial with 256 coefficients. Coefficients wrap modulo 3329, and multiplying polynomials reduces powers using X²⁵⁶ = −1. A module vector is an ordered list of such polynomials. The three parameter sets use lists of length two, three and four respectively. This compact multiplication structure is the difference from ordinary matrix LWE in FrodoKEM.

Subtract sᵀu from v. The products sᵀAᵀr and tᵀr share the same large component. What remains is μ + eᵀr + e₂ − sᵀe₁, plus the effect of encoding and compression in the actual algorithm. If a coefficient stays close enough to the intended value, it decodes to the original bit.

Worked example

With ordinary numbers modulo 17, let A = 5, s = 2, e = 1, r = 1, e₁ = 0, e₂ = 1 and μ = 8. Then t = 11, u = 5 and v = 3. Subtraction gives 3 − 2 × 5 = 10 modulo 17, closer to 8 than to 0 on the circle. This checks one rounding decision. A one-coordinate system provides no meaningful secrecy.

From the arithmetic to a shared key

  1. Generate

    The receiver expands fresh seeds into the public matrix, secret and noise. Its encapsulation key contains a matrix seed and an encoding of t. Its decapsulation key also carries information for handling invalid ciphertexts.

  2. Encapsulate

    The sender generates 32 random bytes internally. Hashing them with a digest of the encapsulation key derives both the shared key and the randomness for encrypting those bytes. The sender transmits only the ciphertext.

  3. Decapsulate

    The receiver decodes the internal bytes and repeats the sender’s calculation. An exact ciphertext match selects the candidate key. A mismatch selects secret-derived fallback bytes without exposing that choice to the caller.

What the protocol must supply

ML-KEM delivers 32 bytes of shared key material. An application still needs an authenticated peer key, a protocol that derives traffic keys, and authenticated encryption for its data. At the implementation boundary, FIPS 203 specifies input checks and implicit rejection separately. Reporting a secret-dependent re-encryption comparison through timing or an error code defeats the purpose of the fallback. Kyber was the submission from which NIST developed ML-KEM. Peers need the same final algorithm and encoding.

Correct hardware outputs can accompany key leakage

Researchers report recovering an ML-KEM-1024 key from the Adams Bridge 2.0.3 accelerator during lab measurements, with its countermeasures enabled. Correct-output tests and measurements of physical leakage answer different questions about what a device does.

Read the study and its scope →

The earlier FPGA study on testing accelerator behavior →

What weak, noisy leakage means for ML-KEM evaluations →

Primary sources

Construction and program sources reviewed .