Good and Bad Bases
August 25, 20266 min readbeginner
This note contains the idea that makes lattice cryptography possible. Everything before it was setup.
This note contains the idea that makes lattice cryptography possible. Everything before it was setup.
The observation is that one lattice has many different bases, that some of those bases are far more useful than others, and that working out a good basis from a bad one is itself a hard problem.
01.The same lattice, described twice
Keep the running lattice, generated by and .
Now take a different pair of vectors:
These generate exactly the same set of points. Not a similar set. The same one.
To see it, express each new vector in terms of the old ones, and check the coefficients come out as whole numbers:
Because those coefficients are integers, every point reachable with and was already reachable with and .
The reverse direction has to hold too, or the new pair would generate only part of the lattice. It does:
Again integers. So the two bases generate each other, which means they generate the same lattice.
02.When does this happen
The bookkeeping above has a compact statement. Collect the change of coefficients into a matrix
so that the new basis is . Then
A square integer matrix whose determinant is or is called unimodular, and the rule is exactly this:
precisely when for some unimodular .
The determinant condition is what forces the inverse of to have integer entries as well, which is what makes the reverse direction work. Any other determinant would give a basis generating only a sparser sub-grid.
There are infinitely many unimodular matrices, so a lattice in dimension already has infinitely many bases. In dimension the supply is beyond description.
03.Good and bad
Now compare the two bases as tools rather than as sets.
The original pair, and , has lengths and , and the angle between them is exactly . Short, and pointing in genuinely different directions.
The second pair, and , has lengths and , and the angle between them is about . Long, and very nearly parallel.
Look at the dots, not the arrows. They are the same points in both panels, in the same places. The lattice did not change. Only the pair of arrows used to describe it did.
Now ask a practical question of each panel. Given some arbitrary point in the plane, which lattice point is nearest?
With the good basis this is easy. The two arrows are short and point in different directions, so you step along until you are roughly in the right place, then along to close the gap, and you land next to the target. Small corrections are available because the steps are small.
With the bad basis it is genuinely awkward. Both arrows point in almost the same direction, so moving sideways at all requires taking a large number of steps along and almost as many back along , and the two nearly cancel. To move a short distance perpendicular to the shared direction, you need enormous coefficients. Guessing them is not possible by eye, and in high dimension it is not possible by computer either.
04.Where the trapdoor comes from
Recall the contract from One-Way Functions and Trapdoors. Easy forwards, hard backwards, easy backwards again for whoever holds a secret.
Lattice cryptography fills it in like this:
The private key is a good basis. The public key is a bad basis of the same lattice.
Bob generates a lattice by choosing a good basis, short and nearly perpendicular. He then multiplies by a large unimodular matrix to produce a bad basis of the identical lattice, and publishes that.
Anybody can use the public bad basis to do the forward operation, which amounts to picking a lattice point and pushing it slightly off. Nobody with only the bad basis can undo it, because undoing it means finding the nearest lattice point and the bad basis makes that search hopeless. Bob undoes it immediately, because his good basis makes the same search easy.
The asymmetry does not come from the lattice. Both parties have the same lattice. It comes from which description of it they hold.
05.Why you cannot just improve the bad basis
The obvious objection: if both bases describe the same lattice, why not convert the bad one into a good one and be done?
That conversion is called lattice basis reduction, and it is a real and well-studied algorithm rather than a wish. In two dimensions it is completely solved, by a method due to Gauss, and it takes almost no time. So the picture above is genuinely breakable, exactly as the overview warned.
The best general algorithm is LLL, from Lenstra, Lenstra and Lovász in 1982. It runs in polynomial time and it always terminates with a better basis than it started with. That sounds fatal until you look at how much better. LLL guarantees a vector within a factor of roughly of the shortest, in dimension . For that factor is , which is nearly perfect. For it is , which is no guarantee at all.
Stronger algorithms exist, principally the BKZ family, which trade running time for a better factor. Choosing lattice parameters for a cryptosystem is essentially the exercise of picking a dimension where the best achievable BKZ factor is still useless to an attacker while the honest party's good basis remains comfortable.
So the answer is that you can improve a bad basis, always, and in the dimensions that matter you cannot improve it nearly enough.