Understanding post-quantum cryptography with a really big clock
The NSA wants a faster switch to post-quantum cryptography. What puts elliptic curves at risk, and why does the new handshake use different math?
I saw the NSA’s warning about post-quantum cryptography on Hacker News and wanted to know two things: What makes 256-bit elliptic-curve cryptography vulnerable, and why would post-quantum key exchange hold up better? I started with what key exchange does: it lets two computers make the same secret key without sending the key itself.
Imagine a clock
Alice and Bob are the two people in a classic cryptography example. Eve is the eavesdropper. Here, Alice wants to send Bob the Wi-Fi password. Think of putting it in a locked box. If she sends the box and its key together, Eve can open it too. The lock is what protects the password. The clock is how they agree on a key without sending it.
Start with an ordinary clock. Alice starts at noon, moves two ticks, and tells Bob where she landed: 2. Bob starts at noon, moves three ticks, and tells Alice where he landed: 3.
Now they both go back to noon. Each uses the other person’s number as the size of a jump.
- Alice counts by threes, twice: noon → 3 → 6.
- Bob counts by twos, three times: noon → 2 → 4 → 6.
Both land on 6. But on a kitchen clock, the label 3 tells Eve exactly how far Bob moved from noon. The labels give away both secret numbers, so Eve can get to 6 too.
Now swap the numbers on the clock face for point labels. Each tick on the curve has a label like (x, y). It tells you which point you’re at, but not how many ticks it took to get there. Alice and Bob send these labels, not their secret step counts.
Here’s the bit that made it click for me: Alice can repeat Bob’s jump without knowing how long it was. The curve has a rule for adding points. Bob sends Alice the point where he landed; Alice can add that point to itself as many times as her own secret number says. Bob does the same with Alice’s point. It’s the same counting-by-threes and counting-by-twos trick, except nobody has to say “three” or “two” out loud.
Call one tick G. Alice goes a ticks and sends Bob aG; Bob goes b ticks and sends Alice bG. Alice repeats Bob’s jump a times, and Bob repeats Alice’s jump b times. Both land at the same point because a × b = b × a. They turn that shared result into the key for the box.
Eve can use the same addition rule Alice and Bob use. What she’s missing is how many times to repeat either jump. Recovering a secret step count from a point label is called the elliptic-curve discrete logarithm problem.
How many ticks are we talking about?
115,792,089,237,316,195,423,570,985,008,687,907,853,269,984,665,640,564,039,457,584,007,913,129,639,936
That’s exactly 2²⁵⁶. P-256’s clock has slightly fewer points; I’m using the round number to show the scale.
A trillion ticks per second sounds fast. Start your counter at the Big Bang, keep it running for 13.8 billion years, and you still haven’t made anything close to one lap.
The comparison that helps me more is to stop counting seconds and start handing out ticks. Imagine giving each tick its own proton, neutron, or electron. You’d need roughly one out of every few thousand of those particles in the entire observable universe to use up all the ticks on this one clock. That’s based on a published estimate of ordinary matter particles, so treat it as a sense of scale, not an exact inventory. And it tells you how big the clock is, not how much work it takes to break the math.
Why the giant clock isn’t enough
Imagine a lock with an 8-bit code. There are 256 possible codes. Add one bit and there are 512. When someone says “128 bits of security,” they’re estimating how much work the best known attack takes: about 2¹²⁸ operations, not how many bits are printed on the key. NIST rates P-256 at about 128 bits of classical security. The clock has roughly 2²⁵⁶ ticks, but even without a quantum computer Eve can do better than counting every one.
The quantum problem is more fundamental. On a sufficiently powerful quantum computer, Shor’s algorithm gives Eve a way to work backward from a public point to its secret step count. She could record the handshake today and try to recover the key later. That’s a reason to switch before such a machine exists. The new advisory doesn’t show that someone has already broken P-256, and none of this says AES-256 was cracked.
The radio that keeps a little static
ML-KEM stands for Module-Lattice-Based Key-Encapsulation Mechanism. “Key encapsulation” describes the exchange: Bob makes a shared secret and sends Alice a sealed message that lets her recover it. “Module-lattice” names the math behind the seal.
A lattice is a repeating grid of points. Start at one dot, then pick two moves: one horizontal and one diagonal. Repeat either move as many times as you like, forwards or backwards. All the places you can land form a lattice:
This one is easy to draw because it has two dimensions. ML-KEM uses a much higher-dimensional version. The word “module” describes extra structure that helps the algorithm do the math efficiently.
Think of a radio signal with two tones, one low and one high. Bob scrambles the tone before sending it. Alice and Eve hear the same signal, but only Alice has the private key to undo the scramble. There’s still a little static left afterward, but Alice can tell which tone Bob meant.
Here's how I'd map it back to the handshake:
- Alice makes a public key. She can share this key with anyone. Think of it as a worksheet of equations tied to a pattern only Alice knows. Alice adds small errors on purpose. If those were ordinary exact equations, the secret pattern would be much easier to solve for.
- Bob uses that public key to make a shared secret and a sealed reply. He sends the sealed reply, called a ciphertext. He keeps his copy of the shared secret.
- Alice uses her private key to open it. Her private information lets her remove most of the masking. The remaining error is small enough to round to the right answer. Think “I heard 493 Hz, so Bob meant 500 Hz.” The real construction does this with vectors of values and checks the ciphertext; it doesn't literally transmit tones.
Here’s what Eve can actually see on the wire:
Alice → public key → Bob
Alice ← sealed reply ← Bob
Eve sees both messages.
Alice and Bob keep the same secret.
The math underneath is called Module Learning with Errors: the hard part is recovering a hidden pattern from lots of slightly wrong equations. Alice’s private key gives her enough information to decode the reply. Eve doesn’t have that information, and there’s no known quantum shortcut for this problem comparable to Shor’s shortcut for elliptic curves. That’s what makes ML-KEM a better bet against quantum computers.
Why keep the clock?
TLS is the protocol that protects HTTPS connections. In TLS 1.3, Alice and Bob can run both exchanges during the handshake, the opening round of messages. SecP256r1MLKEM768 pairs P-256, the same clock we just used, with ML-KEM-768. The standard also defines X25519MLKEM768, which pairs the same ML-KEM variant with X25519, the key exchange built on Curve25519. In either case, TLS uses both shared secrets to make the keys that protect its messages. The goal is for the resulting secret to stay protected if either exchange holds up, even if the other doesn't.
Once Alice and Bob have those keys, Alice can encrypt the Wi-Fi password with AES-GCM, which scrambles the message and lets Bob check that nobody changed it. They use the same key to encrypt and decrypt, which is what “symmetric” means here. The hybrid exchange changes how they get those keys. It doesn't automatically upgrade the signatures used to authenticate who they're talking to. That's a separate part of the handshake.
I wanted to see how much of this I could understand without being a cryptographer. Following Alice and Bob helped me separate two jobs I used to lump together: making a key and using it to encrypt a message. The Wi-Fi password hasn’t changed. What’s changed is the math they rely on to make the key.
That’s why I’d switch. There’s a known shortcut for the old math on a powerful enough quantum computer, and no known equivalent for the noisy equations ML-KEM uses. That makes it a better bet against that threat, not a promise that it can never be broken.
I don’t need to implement either algorithm to make better decisions about it. If we say our service supports post-quantum key exchange, I want to know what our clients actually negotiate and how often they still fall back. That’s a much better question than whether the new algorithm has a bigger number in its name.