Lattice Lab

Why a quantum computer breaks RSA, why lattice-based encryption is built to resist it, and what the switch costs. Three experiments, all running in your browser.

The problem in two paragraphs

Most of the encryption protecting web traffic, software updates and stored records today rests on two hard problems: factoring large numbers (RSA) and finding discrete logarithms (Diffie-Hellman and elliptic curves). In 1994 Peter Shor showed that a large enough quantum computer solves both in polynomial time.

That matters before such a machine exists. An attacker can record encrypted traffic now and decrypt it later ("harvest now, decrypt later"). In August 2024 NIST published the first post-quantum standards, FIPS 203 (ML-KEM) and FIPS 204 (ML-DSA), built on lattice problems. Most people who will have to migrate have never seen either idea run. This lab lets them.

Every demo here is a toy. It teaches the mechanism with small numbers so you can watch it work. Nothing in this page protects real data.

Experiment 1. Break a lock the way Shor's algorithm does

In plain words: a lock built from a big number N = p × q is safe only if nobody can find p and q. Shor's trick turns factoring into finding how often the pattern of powers ax mod N repeats. A quantum computer finds that repeat length fast. Here a normal computer finds it by brute force, which works for tiny N and fails for real ones.

Why brute force cannot scale

The button below times the same brute-force period search on small semiprimes (products of two primes) and records how many steps each needed.

Experiment 2. Hide a secret in noise

In plain words: imagine a system of linear equations with a secret solution. Solving it is easy algebra. Now nudge every right-hand side by a small random error. Anyone holding the secret can still decrypt, because the errors stay small. Anyone solving the equations gets a wrong answer. That gap is Learning With Errors (LWE), the problem under ML-KEM. Move the sliders and watch where it breaks.

A. Encrypt a message, bit by bit

B. Run 2,000 encryptions and see the noise

C. Attack it with plain algebra

Experiment 3. Count the bytes

In plain words: the new algorithms are not free. A lattice key is a long list of numbers, not a single curve point. These sizes come straight from the published standards, and the "exchange total" is one public key plus one ciphertext (or one signature).

Key exchange

Signatures

Check yourself

About, limits and sources