What a quantum computer is

An ordinary computer stores bits that are either 0 or 1. A quantum computer stores qubits, whose state is a combination of 0 and 1 described by complex numbers called amplitudes. Operations on qubits change all these amplitudes at once, and measuring gives one outcome with a probability set by them. This is not “trying every answer in parallel”: a measurement returns a single result. The trick is to arrange the computation so that wrong answers cancel and the right answer becomes likely. Only a few problems have that structure, and two of them matter for cryptography.

Today’s machines have a few hundred to a few thousand noisy qubits. Breaking real cryptography needs a fault-tolerant machine, which corrects its own errors and so needs far more physical qubits. No such machine exists yet. The question for engineers is not whether one exists today but whether data encrypted today still needs to be secret when one does.

Shor’s algorithm: public-key cryptography falls

In 1994 Peter Shor showed that a quantum computer can find the period of a function exponentially faster than any known classical method. Factoring a number NN and computing discrete logarithms both reduce to period finding. So a large quantum computer can:

These are exactly the problems behind public-key encryption and key exchange and digital signatures. Larger keys do not help: Shor’s running time grows only polynomially with the key size, so doubling an RSA key barely slows it down. The algorithms have to be replaced by ones built on different mathematics.

Grover’s algorithm: symmetric cryptography bends

Grover’s algorithm (1996) searches an unstructured space of 2n2^n possibilities in about 2n/22^{n/2} steps instead of 2n2^n. Applied to an AES key it looks like it halves the security level: AES-128 would drop to about 64 bits.

In practice the loss is much smaller. Each Grover step is a full AES evaluation built as a reversible quantum circuit, the steps must run one after another, and splitting the search across KK machines only shortens it by a factor of K\sqrt{K}, not KK. NIST still counts AES-128 as meeting its lowest post-quantum security category. The simple, conservative rule is still worth following: use AES-256 for data that must stay secret for a long time, and SHA-256 or SHA-384 for hashing. See symmetric encryption and hash functions for what these primitives do.

What a large quantum computer would break

Pick a primitive to see its classical security estimate and what changes if a large quantum computer is built.

primitive
RSA-2048
what it does
Encryption and signatures (factoring)
classical security (estimate)
≈ 112 bits
with a large quantum computer
broken (Shor)
verdict
Broken by Shor

Shor’s algorithm factors the modulus in polynomial time, which recovers the private key. It needs a large fault-tolerant quantum computer that does not exist yet.

What to notice: Every public-key algorithm in today’s internet (RSA, Diffie–Hellman, elliptic curves) falls to Shor’s algorithm, while symmetric ciphers and hashes only lose part of their margin to Grover. That is why the migration replaces key exchange and signatures, and keeps AES and SHA-2 with longer keys and outputs.

Harvest now, decrypt later

Why migrate before the machine exists? Because an adversary can record encrypted traffic today and keep it. If a TLS session’s key was agreed with ECDH, a future quantum computer can recover that key from the recorded handshake and decrypt everything in the session. Medical records, state secrets and long-lived business data may still matter in fifteen years.

Signatures are less urgent in this one respect: a forged signature only matters once someone can forge it, and old signatures can be re-issued. Key exchange protects data that has already been sent, so it goes first. That is why browsers and servers switched their key exchange to hybrid X25519MLKEM768 before touching certificates.

What a KEM is

Diffie–Hellman is symmetric in shape: both parties pick a secret, publish a value, and combine their own secret with the other’s public value. Post-quantum schemes do not have this neat structure, so the standards use a key encapsulation mechanism (KEM) instead.

Key encapsulation mechanism

A KEM is three algorithms:

  • KeyGen() → a public encapsulation key ekek and a private decapsulation key dkdk.
  • Encaps(ekek) → a shared secret KK and a ciphertext cc.
  • Decaps(dkdk, cc) → the same shared secret KK.

Only ekek and cc travel over the network. Without dkdk, the ciphertext reveals nothing about KK.

Side by side, the two message flows look like this:

Diffie–Hellman                     KEM
Alice            Bob               Alice                   Bob
a (secret)       b (secret)                                 (ek, dk) = KeyGen()
A = g^a  ──A──►                                    ◄──ek──
         ◄──B──  B = g^b           (K, c) = Encaps(ek)
K = B^a          K = A^b                           ──c──►
                                                            K = Decaps(dk, c)

Both end with the same 32-byte secret, which then feeds a key derivation function and an authenticated cipher. The difference is who creates the secret: in Diffie–Hellman both sides contribute; in a KEM the sender generates it and wraps it for the receiver. For TLS the change is small: the client sends an encapsulation key where it used to send a DH share, and the server answers with a ciphertext.

Here is ML-KEM-768 in Python with the cryptography library (version 50):

from cryptography.hazmat.primitives.asymmetric.mlkem import MLKEM768PrivateKey
from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat

# Bob: generate a key pair and publish the encapsulation key
bob_private = MLKEM768PrivateKey.generate()
bob_public = bob_private.public_key()
ek = bob_public.public_bytes(Encoding.Raw, PublicFormat.Raw)

# Alice: encapsulate -> (shared secret, ciphertext); she sends only the ciphertext
alice_secret, ciphertext = bob_public.encapsulate()

# Bob: decapsulate the ciphertext with his private key
bob_secret = bob_private.decapsulate(ciphertext)

print("encapsulation key:", len(ek), "bytes")
print("ciphertext:       ", len(ciphertext), "bytes")
print("shared secret:    ", len(alice_secret), "bytes")
print("secrets match:    ", alice_secret == bob_secret)
encapsulation key: 1184 bytes
ciphertext:        1088 bytes
shared secret:     32 bytes
secrets match:     True

The keys are random on every run, but the sizes and the match are always the same. Compare the sizes with X25519, where each side sends 32 bytes: post-quantum key exchange costs about a kilobyte more per handshake.

Hybrid key exchange

ML-KEM is new, and new algorithms sometimes have implementation bugs or, rarely, mathematical weaknesses. Deployments therefore run a classical and a post-quantum exchange together and derive the session key from both secrets. The result stays secure as long as either component holds. TLS 1.3 does this with the group X25519MLKEM768, now on by default in major browsers, OpenSSL 3.5 and Go. The hybrid TLS guide shows how to enable and check it.

The NIST standards

After an eight-year public competition, NIST has standardised or selected these algorithms:

AlgorithmPurposeBased onStatus (September 2026)
ML-KEM (Kyber)Key encapsulationModule latticesFIPS 203, final (August 2024)
ML-DSA (Dilithium)SignaturesModule latticesFIPS 204, final (August 2024)
SLH-DSA (SPHINCS+)SignaturesHash functions onlyFIPS 205, final (August 2024)
FN-DSA (Falcon)Compact signaturesNTRU latticesFIPS 206, not yet final
HQCBackup key encapsulationError-correcting codesSelected March 2025; draft expected, final planned for 2027

HQC is a deliberate backup: if a weakness were found in ML-KEM, a KEM based on different mathematics would be ready. NIST still recommends ML-KEM for general use.

Deadlines

The PQC migration checklist turns these dates into concrete steps and 2.7 Post-quantum security explains the security levels.

Why lattices won

Three of the four NIST algorithms rest on lattice problems. The reasons are practical:

SchemePublic keyCiphertext or signatureQuantum-safe
X2551932 B32 B shareNo
ML-KEM-7681,184 B1,088 B ciphertextBelieved so
Ed2551932 B64 B signatureNo
ML-DSA-651,952 B3,309 B signatureBelieved so
SLH-DSA-SHA2-128s32 B7,856 B signatureBelieved so

What exactly is a lattice, and why is finding a short vector in one so hard? That is where the main part of this site begins: 1.1 What is a lattice?

Common mistakes

Further reading

Check Your Understanding

  1. Q1. A large quantum computer is built. Which of these needs to be replaced rather than just given a longer key?

  2. Q2. Why does “harvest now, decrypt later” make the key-exchange migration urgent even though no large quantum computer exists today?

  3. Q3. In a KEM, who chooses the shared secret?

  4. Q4. Grover’s algorithm turns a 21282^{128} key search into roughly how many quantum steps, ignoring its practical overheads?