
A bismuth crystal, its atoms in a regular lattice. The points in this experiment form a lattice too, in two dimensions. Generated image. Shows no real place.
Experiment 3
The closest point is easy to find, until it is not.
Experiment 3A lattice to play withSimulation in your browser. Not a quantum computer.
Instrument
Reading
Find the lattice point closest to the target: move your guess, or round with one of the two bases.
- Basis
- good basis: b1 = (5.00, 1.00), b2 = (1.00, 4.00)
- Your guess
- (0, 0) = 0 b1 + 0 b2
- Distance to target
- 2.55
- Closest point
- hidden until you check
- Rounding, 1,000 targets
- good basis found the secret 1000 times, skewed basis 376 times (computed by this page)
Your browser is not running script, so this is a finished run of the experiment.
Instrument
Reading
Not this one: (0, 0) is 2.55 from the target, but the closest lattice point is 1.58 away.
- Basis
- skewed basis: b1 = (11.00, 6.00), b2 = (6.00, 5.00)
- Your guess
- (0, 0) = 0 b1 + 0 b2
- Distance to target
- 2.55
- Closest point
- (minus 1.00, minus 4.00), 1.58 away
- Rounding, 1,000 targets
- good basis found the secret 1000 times, skewed basis 376 times (computed by this page)
Method
A lattice is every point you can reach by adding whole-number multiples of two basis vectors. The same lattice has many bases. Here the good basis is (5, 1) and (1, 4); the skewed basis is (11, 6) and (6, 5), made from the good one with whole-number steps that can be undone, so it reaches exactly the same points.
A secret lattice point is chosen, and the target is a small random step away from it, shorter than half the distance between any two points, so the secret is always the closest point. Finding the closest point is easy here if you round the target's coordinates in the good basis. In the skewed basis the cell around each point is long and thin, and rounding often lands on the wrong point. Over 1,000 random targets the page counts how often each basis finds the secret and shows the counts.
What this has to do with ML-KEM
NIST's standard FIPS 203 says the security of ML-KEM is related to the difficulty of the Module Learning With Errors problem: solving systems of linear equations that have small errors added, which is a lattice problem of this kind. The difference is size. ML-KEM-768 works with vectors of 3 polynomials of 256 coefficients each (FIPS 203, Table 2), 768 numbers where this toy has 2.
What this toy does not show
It is a toy in two dimensions. Anyone can find the closest point here by checking the points nearby, which is how the page marks the answer. It shows why a bad basis makes rounding fail; it does not show that any scheme is secure.
Sources
- NIST, FIPS 203, "Module-Lattice-Based Key-Encapsulation Mechanism Standard", August 13, 2024 Read at its original address on .
Try it on your codeThe scanner lists the cryptography a project depends on.