Tutorial · Cryptography

Post-Quantum Cryptography

A large enough quantum computer would break the encryption that protects almost everything online today. Here's why, what's replacing it, and what to do about it — with a few things you can poke at.

~20 min read interactive beginner → intermediate updated 2026

01The threat

Today's public-key cryptography rests on math problems that ordinary computers can't solve in a reasonable time. Quantum computers change that for some of those problems.

When you open an https:// site, two kinds of cryptography protect the connection. Public-key crypto (RSA, Elliptic-Curve Diffie-Hellman) sets up a shared secret and proves identity. Symmetric crypto (AES) then encrypts the actual data with that secret. Quantum computers threaten these two very differently.

Shor's algorithm breaks public-key crypto

In 1994 Peter Shor showed that a quantum computer could factor large numbers and compute discrete logarithms efficiently. Those are exactly the problems RSA and elliptic-curve crypto rely on being hard. A large, fault-tolerant quantum computer running Shor's algorithm would recover private keys from public keys — collapsing RSA and ECC entirely, not just weakening them.

Grover's algorithm only dents symmetric crypto

Grover's algorithm speeds up brute-force search quadratically. Against a symmetric cipher it roughly halves the effective key length: AES-128 drops to about 64 bits of quantum security, which is uncomfortable. The fix is simple — use AES-256, and hashes like SHA-256/SHA-3 stay fine. Symmetric crypto survives; public-key crypto is the emergency.

What quantum computing does to each primitive
PrimitiveUsed forQuantum attackVerdict
RSA-2048key exchange, signaturesShor'sbroken
ECDH / ECDSA (P-256)key exchange, signaturesShor'sbroken
AES-128bulk encryptionGrover'sweakened (~64-bit)
AES-256bulk encryptionGrover'ssafe
SHA-256 / SHA-3hashing, integrityGrover's (collisions)safe

The honest caveat

No one has built a quantum computer anywhere near large enough to run Shor's algorithm on a 2048-bit key — that needs millions of stable qubits, and today's machines have far fewer, far noisier ones. The threat is future. The problem, as the next section shows, is that "future" is already a problem today.

02Harvest now, decrypt later

You don't need a quantum computer to exist yet for your data to be at risk now.

An adversary can record encrypted traffic today and simply store it. When a capable quantum computer arrives — call it Q-day — they decrypt the archive retroactively. Anything whose secrecy must outlive Q-day is already exposed. This is why migration is urgent even though Q-day may be a decade or more away.

interactive · is data you encrypt today safe?

Drag the sliders. If a secret's required lifetime stretches past Q-day, traffic captured today can be decrypted later.

Medical records, state secrets, biometric data, long-term IP, infrastructure keys — all have shelf lives measured in decades. For those, the clock already ran out.

03The hard problems

Post-quantum algorithms swap factoring and discrete-log for problems that quantum computers are not known to solve efficiently. Three families do the heavy lifting.

lattices

Lattice problems

Finding short or near vectors in a high-dimensional grid. Basis for ML-KEM & ML-DSA — the fast, small defaults.

hashes

Hash-based

Security rests only on a hash function being hard to invert. Basis for SLH-DSA — slow and bulky, but very conservative.

codes

Code-based

Decoding a deliberately garbled error-correcting code. Basis for HQC — the backup, studied since the 1970s.

A feel for lattices

A lattice is just the set of all whole-number combinations of some basis vectors — an infinite grid of points. Two problems on it are believed hard even for quantum computers: find the shortest nonzero point (SVP), or find the lattice point nearest to an arbitrary target (CVP). Easy to picture in 2-D; brutally hard in the hundreds of dimensions the real schemes use.

interactive · closest-vector problem in 2-D

With a nice (short, near-perpendicular) basis, rounding to the nearest point is easy — that's the private key. With a skewed basis describing the same grid, the obvious rounding misses badly — that's roughly what an attacker sees from the public key. Scale that gap up to 500+ dimensions and it becomes intractable.

Deep dive: Learning With Errors (LWE), the engine inside ML-KEM

LWE hides a secret vector s behind noisy linear equations. You publish a matrix A and the vector b = A·s + e (mod q), where e is small random noise. Without the noise, you'd solve for s with school algebra. With it, recovering s is the hard problem.

interactive · tiny LWE instance (mod 97)
…
The published rows look random. The small errors are what make s hard to pin down at real sizes.

04The standards

After an eight-year public competition, NIST published its first finalized post-quantum standards on August 13, 2024, and added a backup in March 2025.

FIPS 203 · final

ML-KEM

Key encapsulation (Kyber). Lattice-based. The default for establishing shared secrets. Fast, small.

FIPS 204 · final

ML-DSA

Signatures (Dilithium). Lattice-based. The default for authentication and code signing.

FIPS 205 · final

SLH-DSA

Signatures (SPHINCS+). Hash-based. Slow and large, but rests on the fewest assumptions — a conservative backup.

FIPS 206 · draft

FN-DSA

Signatures (Falcon). Lattice-based, very compact signatures, trickier to implement safely. Standard still in progress.

backup · ~2027

HQC

Key encapsulation. Code-based — different math from ML-KEM, so it survives if lattices are ever broken. Larger; insurance, not the default.

They're bigger than what they replace

The trade-off for quantum resistance is size. Pick a parameter set and compare against classical crypto:

interactive · key & signature sizes
strength:
AlgorithmPublic keyCiphertext / Signaturevs classical

Rule of thumb

Use ML-KEM for key exchange and ML-DSA for signatures as your defaults. Reach for SLH-DSA when you want maximum assurance and can absorb big, slow signatures. Track HQC and FN-DSA, but don't wait for them to start.

05How a PQ key exchange works

ML-KEM is a KEM — a key-encapsulation mechanism. It's a slightly different shape from the Diffie-Hellman handshake you may know, but the goal is the same: two parties end up holding the same secret, without an eavesdropper learning it.

interactive · step through an ML-KEM exchange

Alice

generates keypair (pk, sk)
decapsulate(sk, ct) → K
channel

Bob

encapsulate(pk) → (ct, K)

In practice: hybrid mode

Nobody fully trusts brand-new cryptography overnight. So real deployments — TLS 1.3 in browsers and servers already do this — use a hybrid: run a classical exchange (like X25519) and ML-KEM, then mix both shared secrets together. The connection is safe if either one holds. You get quantum resistance now without betting everything on the new math.

# Conceptual hybrid key-exchange (TLS-style)
classical_secret = X25519(client_priv, server_pub)
pq_ct, pq_secret  = ML_KEM_768.encapsulate(server_pq_pub)
session_key = HKDF(classical_secret || pq_secret)
#            safe if X25519 *or* ML-KEM stays unbroken

The real lesson: crypto-agility

The biggest win isn't any single algorithm — it's building systems that can swap algorithms without a redesign. Whatever gets broken or standardized next, agile systems adapt; hard-coded ones get rewritten under pressure.

06Migrating

You don't flip a switch. You find your cryptography, rank it by risk, and move the urgent parts first.

  1. Inventory. Build a cryptographic bill of materials: where RSA/ECC are used across TLS, VPNs, code signing, PKI, secrets, and third-party products. You can't migrate what you can't see.
  2. Prioritize by shelf life. Apply the harvest-now-decrypt-later test. Long-lived secrets and anything protecting data that must stay private for years go first.
  3. Adopt crypto-agility. Abstract algorithm choices behind interfaces so swapping ML-KEM, HQC, or a future pick is a config change, not a rebuild.
  4. Deploy hybrids. Turn on hybrid key exchange (X25519 + ML-KEM) where your stack supports it. Prefer AES-256 over AES-128 for bulk encryption.
  5. Test & measure. Bigger keys mean bigger handshakes and more bytes on the wire. Validate performance, MTU/packet sizes, and HSM and library support before you flip production.

Start now, even though Q-day hasn't come

NIST's own guidance is blunt: the standards are final and ready — begin. Migrations across large estates take years, and the harvest-now risk is already live for long-lived data.

07Check yourself

Six quick questions. Pick an answer to see whether it's right and why.

1. Which quantum algorithm is the real emergency for today's public-key crypto?

2. What's the right response to Grover's algorithm for symmetric encryption?

3. "Harvest now, decrypt later" means an attacker…

4. Which NIST standard is the default for key establishment?

5. Why did NIST standardize HQC as a backup when ML-KEM already works?

6. What does a "hybrid" key exchange give you?

Sources & further reading

Primary, official sources for the facts above:

Sizes shown are approximate, typical values for common parameter sets and are meant for comparison, not implementation. Always consult the FIPS documents for exact figures.