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.
How the clock models key exchange
The older key exchange I wanted to understand is elliptic-curve Diffie–Hellman (ECDH). Say Alice and Bob want to encrypt a Wi-Fi password, and Eve can hear every message they exchange. With ECDH, Alice and Bob each pick a private number and send the other person a public point on a curve. How does that leave them with a secret they both know?
I picture a clock because the curve has a move you can repeat, like advancing a hand one tick. Keep making that move and eventually you come back to where you started. Think of noon as the starting point. How many ticks you choose to move stands for your private number. Where the hand lands stands for the public point you send.
Try it on a kitchen clock. Alice picks 2, moves two ticks from noon, and tells Bob the hand landed on 2. Bob picks 3, moves three ticks from noon, and tells Alice the hand landed on 3. Now each starts again at noon, using the other person’s jump size and their own private count:
- Alice counts by threes, twice: noon → 3 → 6.
- Bob counts by twos, three times: noon → 2 → 4 → 6.
The 6 is the shared result. Alice and Bob get there independently because two jumps of three cover the same distance as three jumps of two. Eve can follow along on this clock, too. When Bob says his hand landed on 3, the dial tells her he moved three ticks.
Now do the same exchange on the curve. Call the point one tick from noon G. With the same choices, Alice’s public point is 2G and Bob’s is 3G. I’m writing 3G because we know how Bob got there. What he actually sends is the point, which can be written as a pair of coordinates (x, y). Neither coordinate is a tick count.
Here’s the part that made ECDH click for me. Alice can double Bob’s point without knowing his number. The curve has a rule for adding points using their coordinates. Alice adds Bob’s point to itself and gets 3G + 3G = 6G. Bob adds three copies of Alice’s point and gets 2G + 2G + 2G = 6G. That point plays the role of 6 on the kitchen clock. They use its x-coordinate as a shared secret from which to derive an encryption key.
In a real exchange, Alice and Bob pick large random private numbers. The arithmetic still works in either order. Eve sees both public points and knows the addition rule. What she’s missing is how many copies of either point to add. Recovering a private count from its public point and the known one-tick point G 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.