Skip to content

ML-KEM explained

ML-KEM is a key encapsulation mechanism: instead of two parties agreeing a shared secret by exchanging public values, one party encapsulates a fresh secret under the other's public key and sends the ciphertext. Its security rests on the hardness of the Module Learning With Errors problem.

Encapsulation rather than agreement

Diffie-Hellman is symmetric: both sides contribute a public value and both derive the same secret. A KEM is not. The recipient publishes a key. The sender generates a random secret, encapsulates it under that key, and transmits the ciphertext. The recipient decapsulates to recover it.

The shape difference matters in practice. The sender chooses the secret, so the sender's randomness quality directly determines the session's security — there is no second party whose contribution compensates.

The working mental model

The underlying problem is Learning With Errors: given a system of linear equations with small random errors added, recover the secret. Without the errors this is straightforward linear algebra; with them it becomes hard, and is believed hard for quantum computers too.

ML-KEM works over polynomial rings, which is what makes the keys and operations efficient enough to be practical. That is as far as the intuition takes you, and it is far enough for an architect — the security proof is not something to reason about informally.

What it costs in practice

Public keys and ciphertexts are larger than their elliptic-curve equivalents by roughly an order of magnitude, which matters most for handshake size and for constrained links. Computation is fast — often faster than the elliptic-curve operations it replaces.

So the cost is bandwidth and memory rather than CPU, which is a different constraint than most people expect. What to measure goes into that properly.

The randomness dependency

Both key generation and encapsulation consume randomness. Encapsulation is the one worth dwelling on: the sender samples a fresh secret per session, and if that sampling is predictable the session is compromised regardless of how sound ML-KEM is.

This is the same dependency ECDH always had, which is the point — the algorithm generation changed and the requirement did not.

Deploying it

Almost always in a hybrid construction today, combined with X25519 so that a break in either component alone is not fatal. Why hybrid, and how long it persists.