Chapter 10Down the Rabbit Hole: The Post-Quantum Key Exchange That Is Wrong on Purpose
Cloudflare's number pulled me in: by October 2025 more than half of human traffic at their edge used post-quantum key agreement, over 65% by April 2026. Chrome has it on by default since 131, Firefox since 132, Apple since OS 26. OpenSSH 10 made it the default in April 2025. Signal and iMessage run it.
I knew the headline: ML-KEM, standardized Kyber (FIPS 203, August 2024), "based on lattices". That told me nothing. Underneath is a scheme whose security comes from arithmetic that is deliberately wrong, a correctness argument that only works because a huge term cancels exactly, and a list of real breaks where not one touched the math.
Why anything had to change#
DH, ECDH and RSA key transport all fall to Shor's algorithm on a large enough quantum computer. Nobody knows when. But traffic can be recorded now and decrypted later ("harvest now, decrypt later"). That's why key exchange migrates before signatures: authentication only has to hold at connection time, confidentiality for as long as anyone keeps the recording.
NIST's competition started in 2016 with 69 first-round submissions, picked Kyber in July 2022, and published ML-KEM in August 2024. It won on being practical: keys and ciphertexts around a kilobyte, often faster than X25519. Classic McEliece needs public keys around 261 KB.
A clock with 3,329 ticks#
Picture a clock face with 3,329 ticks. To send one bit, I set a hand to 12 o'clock for 0 or 6 for 1, then bump it by a random "smudge" of a few hundred ticks. To an eavesdropper it looks random. You hold a secret that removes most of the smudge, not all. What's left is small enough to tell whether the hand is nearer 12 or 6. Do that 256 times and we share a 32-byte note, which becomes the session key.
0 832 1665 2497 3329 (= 0) ├──────────┼───────────────────┼───────────────────┼──────────┤ │◀─ reads 0 ─▶│◀────── reads 1, centred on 1665 ──────▶│◀ reads 0 ▶│ bit 0 sits at 0 / 3329; bit 1 sits at 1665 (the 6 o'clock position)
ML-KEM is a KEM, not a two-sided exchange. You publish an "open box" (encapsulation key, 1,184 bytes for ML-KEM-768). I put the note inside, seal it, and send it back (ciphertext, 1,088 bytes). Only one side picks the secret.
you: s (small), e (small)
t = A.s + e
you ── t, seed(A) ──▶ me (1,184 B)Your public key is t, whose coefficients look uniform. That is the security assumption.
Where the smudge comes from#
The hard problem is Learning With Errors: given a matrix A and t = A·s + e with small s and e, find s. Without e it's first-year Gaussian elimination. With a small error, nobody knows how to solve it efficiently, classically or quantumly.
ML-KEM uses Module-LWE: entries are polynomials with 256 coefficients mod 3329, multiplication wraps so X^256 becomes -1. For ML-KEM-768, A is a 3x3 grid of polynomials, an effective 768-dimension puzzle. More security just means 2x2, 3x3, 4x4 with the same arithmetic.
Small secrets come from a centered binomial: count four random bits, take (b0 + b1) - (b2 + b3), giving -2..2. No Gaussian tables, no floating point, nothing to leak through timing.
The cancellation that makes it work#
The one equation worth staring at. I send u = Aᵀy + e1 and v = tᵀy + e2 + (q/2)·m, both rounded down (errors c_u, c_v). You compute w = v - sᵀu:
w = (As + e)ᵀy + e2 + (q/2)m + c_v - sᵀ(Aᵀy + e1 + c_u)
= sᵀAᵀy + eᵀy + e2 + (q/2)m + c_v - sᵀAᵀy - sᵀe1 - sᵀc_u
= (q/2)m + [ eᵀy - sᵀ(e1 + c_u) + e2 + c_v ]sᵀAᵀy is big and uniform-looking, appears once from each side, and cancels exactly. What's left is the message plus noise where every piece is a product of two small things or a bounded rounding error. While that stays under q/4 = 832 per coefficient, rounding recovers m. That's why your secret key is just s.
The dive's Python implementation round-trips byte for byte against OpenSSL 3.6. With fixed seeds, the first eight coefficients of w were 1666, 95, 1647, 3318, 3290, 1760, 3208, 1781. Near 1665 means 1, near 0 or 3329 means 0: 1, 0, 1, 0, 0, 1, 0, 1, exactly what was sent. Worst leftover noise: 121 ticks, against 832 needed for an error.
The noise budget, and why 2^-81 is the wrong estimate
I assumed most noise came from the random secrets. It doesn't. Variances for ML-KEM-768: eᵀy about 768, sᵀ(e1 + c_u) about 1,444, e2 about 1, and rounding v down to 4 bits about 3,608. Total about 5,821, so σ about 76. Across 51,200 coefficients the measured σ was 76.6 and the worst case 292.
So 62% of the variance comes from throwing away ciphertext bits on purpose: every bit saved is 32 bytes off the ciphertext.
Treat the noise as Gaussian with σ ≈ 76 and the threshold is about 10.9σ, giving a failure chance of about 2^-81 over 256 coefficients. FIPS 203 says 2^-164.8, and the dive reproduces it by exact convolution: an 84-bit gap. The rounding of v is bounded at ±104, so the unbounded part must supply at least 728 on its own, with σ around 47: 15.5σ. A central limit shortcut can't estimate lattice failure rates.
Why the failure rate has to be absurdly small#
The raw scheme is only secure against eavesdroppers. If an attacker sends crafted ciphertexts and watches whether you derive the right key, each answer leaks a bit about s: a few hundred to a few thousand queries to full key recovery with reused keys. Ring-LWE exchanges were broken this way in 2016.
The fix is the Fujisaki-Okamoto transform: derive all encryption randomness from a hash of the message and public key, so after decrypting you can re-encrypt and check you get the exact 1,088 bytes that arrived. On mismatch you quietly return a pseudorandom key from a secret z and the ciphertext. The attacker sees a key either way. FIPS 203 forbids exposing the reject flag.
In the dive, flipping one ciphertext bit usually still decrypted to the same message (the flip moved a coefficient by about 3), but re-encryption produced the original ciphertext, the comparison failed, and decapsulation returned an unrelated key with no error. The handshake fails later at key confirmation.
The tiny failure probability earns its keep here: every attacker hash query is a lottery ticket for a decryption failure, and failures leak. With 2^64 queries and δ = 2^-164.8, the attacker's edge is about 2^-98.8.
Every break went through the code#
The math has held. Every practical key recovery came from implementations, and the FO re-encryption step that makes the scheme CCA-secure on paper also turns a tiny decapsulation side channel into a key-recovery oracle.
mask = -((msg[i] >> j) & 1); // 0 or all-ones, no branchThe classic constant-time idiom. Same instructions whatever the secret bit is.
compiler notices: value is only ever 0 or 1
|
v
if (secret_bit) { ... } else { ... } a branch on the secret
|
v
timing leaks the bit -> ML-KEM-512 key recovery in 5-10 minutesThe KyberSlash division and its fix
The reference code:
t = (((t << 1) + KYBER_Q/2) / KYBER_Q) & 1;The fix is a multiply-and-shift:
t = (((t << 1) + 1665) * 80635 >> 28) & 1;The dive checks this equals the division for all 3,329 inputs.
Who actually turned it on#
Less "the internet migrated", more "a few CDNs flipped a switch".

Fig. 2a from "Mind the Gap: Policy vs Reality in PQ TLS" (IMC 2026), arXiv:2607.29005, licensed CC BY 4.0. Cropped and recompressed.
By March 2026 about half of a stable domain panel defaulted to post-quantum key exchange, almost all X25519MLKEM768, and Cloudflare alone carried 57% of those domains. Adoption was driven by CDNs, not national roadmaps.
Browsers run ML-KEM next to X25519 and feed both secrets into the key schedule, so the connection is safe if either holds. That got concrete in April 2024, when a claimed polynomial-time quantum LWE algorithm caused alarm until a bug was found and the claim withdrawn on April 18.
The hybrid costs bytes: the client key share is 1,216 bytes, pushing the ClientHello past one packet. Middleboxes and servers that called read() once and expected the whole ClientHello broke when Chrome first shipped Kyber. Go still keeps a GODEBUG switch to turn it off.
The question I'm left with#
The gap between "verified" and "safe". libcrux (in Firefox and OpenSSH) is Rust verified for correctness and secret independence. mlkem-native, default in AWS-LC and liboqs, has C proven memory-safe and assembly proven correct and constant-time in HOL Light. A CRYPTO 2024 paper has a machine-checked IND-CCA proof linked to a constant-time Jasmin implementation.
But each proof stops at the instruction level. KyberSlash was a DIV with input-dependent latency; the patched version leaked through power; Clangover was a compiler deciding it knew better. The gap from assembly to silicon needs leakage models of real hardware: variable-time multipliers, power, EM, speculation. Nobody has a proof all the way down, and I'm not sure what one would look like.
On the math side, nobody can prove the module structure is harmless. The cost of the best lattice attacks on ML-KEM-512 depends on whether you charge for memory access, and that argument (MATZOV, NIST, Bernstein, Ducas-Pulles) isn't settled, which is partly why everyone deployed 768 and CNSA 2.0 asks for 1024.
Next on my list is ML-DSA: same ring, secret hidden with rejection sampling, signatures of 2.4-4.6 KB, which is the real reason post-quantum authentication on the web is still stuck.
Sources#
- NIST. FIPS 203: Module-Lattice-Based Key-Encapsulation Mechanism Standard
- CRYSTALS-Kyber Round 3 specification
- Regev. On Lattices, Learning with Errors, Random Linear Codes, and Cryptography (2005)
- Cloudflare. Post-quantum in 2025 and post-quantum roadmap
- Google Security Blog. A new path for Kyber on the web
- OpenSSH 10.0 release notes
- Bernstein et al. KyberSlash and the KyberSlash FAQ
- SPA on the patched ML-KEM
- Clangover
- wolfSSL CVE-2026-10097 (aggregator listing)
- Schmieg. Unbindable Kemmy Schmidt and Cremers, Dax, Medinger. Keeping Up with the KEMs
- Almeida et al. Formally Verifying Kyber Episode V
- mlkem-native and libcrux
- Chen. Claimed quantum LWE algorithm (withdrawn)
- Mind the Gap: Policy vs Reality in PQ TLS (IMC 2026)
- tldr.fail
- RFC 9935