Skip to content
Post-Quantum Plan

Back to the Lab

Lattice explorer: the idea behind ML-KEM and ML-DSA

ML-KEM and ML-DSA are built on lattice problems. A lattice is a regular grid of points generated by a few vectors. Here you play the attacker: a hidden lattice point has been nudged by some noise, and you have to find it.

This is a teaching tool, not an audit. Real schemes use lattices with hundreds of dimensions and structured noise; this two-dimensional picture only builds intuition and proves nothing about security.

Basis used by Babai rounding
b₁b₂

Click or tap the lattice point you think is closest to the diamond. With the keyboard, focus the picture and use the arrow keys. Drag the green handles to reshape the lattice.

  • Lattice point
  • Target (hidden point plus noise)
  • Your guess
  • Babai rounding's answer
  • Closest lattice point (after checking)

Choose the lattice point you think is closest to the diamond, then check.

Same lattice, two bases

Same lattice, two bases
Vector lengthsOrthogonality defect (1 is perfect)Babai recovers the hidden point
Good basis1.23 / 1.111.00100%
Bad basis4.43 / 6.1219.9416%

The last column is measured over 400 random puzzles at the current noise level and lattice shape. Real attacks on lattices use far stronger algorithms than Babai rounding; the point here is only that the quality of the basis matters.

What this shows

The grid of dots is one lattice. A basis is a pair of vectors that generates it: every dot is a whole-number combination of the two. The green arrows are a good basis: short and nearly at right angles. The dashed arrows are a bad basis of the very same lattice: long and almost parallel. The dots do not move when you switch.

The diamond is the target: a hidden lattice point plus noise. The task is the closest vector problem. With a good basis, Babai rounding (write the target in the basis, round each coordinate) lands on the right point, because the cells around each dot are compact. With a bad basis the cells are long thin slivers and rounding picks a wrong neighbour. Same lattice, same target, very different difficulty. Turn up the noise and even the good basis fails: when the noise is larger than the gap between points there is no unique answer.

That is the intuition behind learning with errors (LWE). The private key is a good basis, or something equivalent to it; the public key is a bad one. Whoever has the good basis can remove the noise; whoever has only the bad one is stuck. In two dimensions a computer solves every case instantly. In hundreds of dimensions no efficient algorithm is known, classical or quantum, and that is the bet the NIST standards make.