4. Learning with errors

Draft

Linear equations are easy, noisy ones are not

Pick a secret vector \(s\) of \(n\) integers modulo \(q\) together with a matrix \(A\) of uniformly random integers modulo \(q\), and publish \(A\) alongside the exact product \(b = As \bmod q\). Anyone can recover \(s\) in milliseconds by Gaussian elimination, the standard method of a first course in linear algebra. Now perturb each entry of \(b\) by a tiny random error before publishing it: \(-1\), 0, or 1. Run on those noisy equations, Gaussian elimination returns garbage unrelated to \(s\), and at cryptographic dimensions nobody knows, as of November 2026, any algorithm that beats exponential-time search by much. Recovering \(s\) from noisy modular linear equations is the learning with errors (LWE) problem, and it gives this series its title: where the classical schemes of Section 1 hid secrets behind periods that a quantum computer can spot (Section 2), lattice schemes hide secrets behind small additive errors. ML-KEM (Kyber), the key-encapsulation mechanism (Section 1.1) standardized by the United States National Institute of Standards and Technology (NIST) in 2024, encrypts directly with noisy equations. In its plainest form, encryption needs only subset sums of those equations, three lines of algebra explain why decryption reads through the noise, and concrete lattice-reduction costs set the required dimension.

system   4 equations in 4 unknowns mod 97; the secret is s = (28, 38, 42, 67)
         without errors, b = A s        with errors e = (+1, −1, 0, −1), b = A s + e
         75 15 95 80 = 89               75 15 95 80 = 90
         40 22 89 16 = 73               40 22 89 16 = 72
         87 14 91  3 =  7               87 14 91  3 =  7
          6 80 70 50 = 89                6 80 70 50 = 88
steps    the same 16 row operations on both: multiply a row by the inverse of its pivot, subtract a
         multiple of it from the other rows
returns  28 38 42 67, the secret        51 63 68 79: 4 of 4 unknowns wrong
bars     the error each row of the right system carries, as a whole number: it grows from 1 to
         3.1 × 10^10; past 48, half of 97, it has wrapped around the modulus
count    of 1,000 random systems, returned wrong: 0 without errors, 989 with errors −1 to 1,
         999 with −2 to 2, 1,000 with −3 to 3
size     768 unknowns mod 3,329 with the error law of ML-KEM: 768 of 768 unknowns returned right
         without errors, 0 with them
(the live figure needs JavaScript; it loads no data)
The same elimination on two systems that share a matrix and a secret: exact at the left, with an error of −1, 0 or 1 in each equation at the right. Green: the error a row carries, as a whole number on a logarithmic scale; the number beside it is its value mod 97; hatched: past half the modulus, where it has wrapped around. Play the row operations, change the modulus (17 starts with the example of Regev's survey), draw a new system. Below, 1,000 random systems at each width of error, eliminated in the page, and one system of 768 unknowns mod 3,329, the size of ML-KEM-768.

Gaussian elimination shatters because every row operation multiplies errors by large modular constants. To clear a column modulo \(q\), elimination multiplies a pivot row by the modular inverse of its leading entry and subtracts multiples of that row from the remaining rows; modulo \(q\), those multipliers have typical size \(O(q)\), and each equation's hidden error gets multiplied right along with it. In the figure's four-equation system modulo 97, scaling the first pivot 75 to 1 multiplies that row and its error of \(+1\) by \(75^{-1} \equiv 22 \pmod{97}\); clearing the 40 below it subtracts \(40 \times 22\) from the second row's error of \(-1\), blowing that error up to \(-881\). After all 16 row operations, the accumulated integer errors reach eleven digits, wrapping around the modulus 97 millions of times (anything past 48, half of 97, has already wrapped) until only uniform-looking remainders survive. All four unknowns come back wrong, even though the third equation started with zero error.

That breakdown is all-or-nothing rather than gradual. Algebraically, applying \(A^{-1} \bmod q\) to \(b = As + e\) returns \(s + A^{-1} e \bmod q\), and for a random invertible matrix \(A\), multiplying any nonzero error vector \(e\) by \(A^{-1}\) scrambles it across all residues modulo \(q\). Across 1,000 random four-unknown systems with errors in \(\{-1, 0, 1\}\), elimination recovered \(s\) in the 11 instances where all four errors happened to draw 0, and in not a single other. Scaled to 768 unknowns modulo 3,329 with ML-KEM-768's error distribution, elimination recovers all 768 coordinates without errors and zero with them.

Oded Regev, who introduced LWE in 2005, states why elimination fails in a single sentence of his 2010 survey.

If not for the error, finding s would be very easy: after about n equations, we can recover s in polynomial time using Gaussian elimination. Introducing the error seems to make the problem significantly more difficult. For instance, the Gaussian elimination algorithm takes linear combinations of n equations, thereby amplifying the error to unmanageable levels, leaving essentially no information in the resulting equations.

—Oded Regev, "The Learning with Errors Problem" (2010). Invited survey for the 25th Conference on Computational Complexity, 2010 (the author's copy), Section 1. It opens with seven such equations modulo 17 in four unknowns, each "correct up to some small additive error (say, ±1)", and gives their answer, (0, 13, 9, 11); eliminating the first four of them returns (0, 9, 1, 2), three of four wrong. The problem was posed in O. Regev, "On lattices, learning with errors, random linear codes, and cryptography", STOC 2005; Journal of the ACM 56(6), 2009.

Information-theoretically, \(s\) is not lost at all. Given a small multiple of \(n\) noisy equations, almost surely only a single vector \(s \in \mathbb Z_q^n\) satisfies all of them to within small errors: a statistician would call \(s\) uniquely identifiable, and brute-force testing of all \(q^n\) candidates would spot it. What is missing is an efficient way to compute it. The name learning with errors comes from computational learning theory, which had long studied the binary case \(q = 2\) (learning parity with noise, recovering a bit vector from noisy mod-2 inner products). When the best combinatorial elimination algorithm from that literature is adapted to modulus \(q\), it still requires both running time and a supply of noisy equations exponential in \(n\); Regev's 2010 survey called it "the best known algorithm for the LWE problem".

The problem, and the lattice inside it

Without modular wrap-around, solving \(b = As + e\) would be ordinary linear regression. Over the real numbers, the least-squares estimate misses \(s\) by \((A^{\top} A)^{-1} A^{\top} e\), whose entries shrink as more equations are collected until rounding recovers the integer vector \(s\). Modulo \(q\), however, \(b \equiv As + e \pmod q\) means that over the integers \(b = As + qk + e\) for an unknown integer wrap-around vector \(k \in \mathbb Z^m\). Because \(k\) can be any integer vector, the noiseless right-hand sides \(As + qk\) form a discrete grid of points, a \(q\)-ary lattice in \(\mathbb R^m\) (Section 3), and \(b\) is one of those grid points nudged off-grid by the short error \(e\).

plane    two equations in one unknown, mod 31 (across: the first, up: the second)
            21 s + e1 = 7          25 s + e2 = 12
         the lattice: the 31 points (21 s, 25 s) mod 31, one for each s, repeated every 31
         b = (7, 12) lies just off the point (8, 11) = (21 · 24, 25 · 24) mod 31
         so s = 24, and the error is e = (−1, +1), of length 1.41
reach    a circle around b of 2 spacings of the lattice (a spacing: the radius of a disc as large as
         one cell, 3.14 here): 4 lattice points lie inside it
strip    lattice points within the same reach of b, with n unknowns and 2 n equations
         unknowns       2      3      4      512       768       1,024
         counted       17     63    256
         estimated     16     64    256    2^1024    2^1536    2^2048     (the sizes of ML-KEM-512, 768, 1024)
(the live figure needs JavaScript; it loads no data)
Two equations in one unknown, drawn: the dots are every pair (21 s, 25 s) mod 31, a point to a value of s, and b is the pair of right-hand sides. Green: the error, from the nearest lattice point to b. The wash is that point's cell, the dashed circle the reach. Drag b, change the reach, draw new equations. The strip counts the lattice points within the same reach as the unknowns grow: dots counted in the page by going through every secret, lines and rings estimated as the volume of the ball over the volume of a cell, up to the sizes of ML-KEM.

With two equations in a single unknown modulo 31, the vector \(b\) sits in the plane, and the 31 noiseless pairs \((21s, 25s) \bmod 31\) repeat periodically across every \(31 \times 31\) square to form a planar lattice: recovering \(s\) means finding the lattice point closest to \(b\). In general, \(m\) equations define an \(m\)-dimensional lattice of all vectors congruent to \(As \bmod q\), and \(b\) is one lattice point perturbed by the short noise vector \(e\). Recovering \(s\) is therefore bounded-distance decoding on that \(q\)-ary lattice (Definition 3.2.2), where \(b\) is promised to lie much closer to a unique lattice point than to any other. Cryptography poses the problem in two forms: key-recovery attacks try to find \(s\), whereas hiding messages requires that noisy equations look indistinguishable from uniform random numbers.

Definition 4.2.1 (learning with errors). Fix a number of unknowns \(n\), a number of equations \(m\), a modulus \(q\) and a law \(\chi\) on small integers, the error law. Draw the entries of \(A \in \mathbb Z_q^{m \times n}\) and of \(s \in \mathbb Z_q^{n}\) uniformly and those of \(e \in \mathbb Z^{m}\) from \(\chi\), and set

\[b = A s + e \pmod q .\]

The search problem is to find \(s\) from \((A, b)\). The decision problem is to tell \((A, b)\) from \((A, u)\), where \(u\) is uniformly random in \(\mathbb Z_q^{m}\).

In Regev's 2005 paper, the error law \(\chi\) is a normal distribution of width \(\alpha q\) (for an error rate \(\alpha\)) rounded to the nearest integer. Standardized schemes use narrower, bounded distributions: ML-KEM draws errors from \(-2\) to 2 (or \(-3\) to 3 in its smallest parameter set) and draws the secret \(s\) from that same small law rather than uniformly modulo \(q\), a change proved not to weaken the problem. Once at least \(n\) equations are published, providing a moderate multiple more helps an attacker very little.The error laws: Regev's survey, Section 1, and FIPS 203, Table 2. That a secret drawn from the error law is no easier to find than a uniform one: C. Peikert, "A Decade of Lattice Cryptography", Foundations and Trends in Theoretical Computer Science 10(4), 2016 (ePrint 2015/939), Section 4.2.1. Regev's survey calls the number of equations insignificant for most purposes. The exception is an attack that makes the equations linear in many more unknowns, one for each product of at most \(2\beta + 1\) of the old ones when the errors are bounded by \(\beta\), and that needs at least as many equations as it has unknowns. Their number is of the order of \(n^{2\beta + 1}\): with errors from −2 to 2 and 768 unknowns, \(768^5/5!\), about \(2 \times 10^{12}\), where an encapsulation key of ML-KEM-768, its public key, holds 768 (the order is from V. Lyubashevsky, "Basic Lattice Cryptography: The concepts behind Kyber (ML-KEM) and Dilithium (ML-DSA)", ePrint 2024/1287, Section 2.3).

One problem, asked two waysthe same noisy equations, a row to a question: what is given and what is asked, in ink, then what the question is in the lattice and who needs the answer

  1. 4.6search what an attack answers

    Recover the secret behind the equations: in the lattice, find the point nearest to b. Whoever can do this reads every message sent to the key.

    given: A and b = A s + e mod q

    find: s

  2. 4.3decision what encryption needs to be hard

    Tell noisy equations from random numbers: in the lattice, say whether b lies next to a point or just anywhere. If nobody can tell, a public key and a ciphertext look like noise to an eavesdropper.

    given: A and b, or A and random numbers u

    say: which

green: the form in which the security of encryption is stated

Search and decision are computationally equivalent: an efficient solver for either converts into an efficient solver for the other with only polynomial overhead.For a prime modulus of moderate size the harder direction takes a few lines. To test a guess \(g\) for the first coordinate of \(s\), add to each equation a fresh random number \(\rho\) in the first entry of its row of \(A\), and \(\rho g\) on its right-hand side. If the guess is right the result is again a set of noisy equations in \(s\); if it is wrong the right-hand sides are uniformly random. Whoever can tell the two cases apart can test all \(q\) guesses for each coordinate in turn. Peikert's survey, Section 4.2.2, lists the proofs for other moduli. That equivalence bridges cryptanalysis and design: concrete attacks target search (and Section 4.6 times one), while encryption security relies on decision so that public keys and ciphertexts look indistinguishable from random noise. Geometrically, search asks which lattice point lies near \(b\), whereas decision asks whether \(b\) sits anomalously close to the lattice or landed uniformly in \(\mathbb Z_q^m\).

In the plane, the eye spots the nearest lattice point among four local candidates. In high dimensions, local neighborhoods explode exponentially. By the volume-density heuristic behind Definition 3.5.1 (one grid point per cell volume), a ball around \(b\) of radius equal to twice the lattice's characteristic spacing (the radius of a one-cell ball) encloses roughly \(2^d\) grid points in dimension \(d\): 4 in the plane, rising to roughly \(2^{1{,}536}\) for 768 unknowns and 1,536 equations. Exactly one of them is the unperturbed point. That \(2^d\) figure is a volume estimate rather than a theorem or an attack cost; where every candidate can be counted exhaustively for one to four unknowns, the ball encloses 4, 17, 63, and 256 points, compared with the volume estimate's 4, 16, 64, and 256. Nor is the right point geometrically ambiguous: at ML-KEM-768's parameters, the error norm is just 0.07 of the spacing, placing \(b\) deep inside a single cell. What blocks decoding is the basis trap of Section 3.3: rounding works only in a short, nearly orthogonal basis, whereas \(A\) and \(q I_m\) hand everyone vectors of length \(O(q)\), and reducing that skewed basis requires the exponential-time block reduction of Section 3.4. Crucially, nobody holds a short basis of this lattice, not even the key holder, who knows only the single secret point \(As \bmod q\) that was perturbed.

Remark 4.2.2 (which lattice problem). LWE is sometimes loosely described as SVP in disguise. More accurately, it is bounded-distance decoding posed on average over random \(q\)-ary lattices generated by \(A\). Remark 3.2.3 explained why worst-case NP-hardness does not settle average-case security, and Section 4.5 states the reduction that connects random LWE instances to worst-case lattice problems. Equivalently, LWE can be read in coding-theory terms as decoding a random linear code over \(\mathbb Z_q\) corrupted by errors small in magnitude, whereas the code-based schemes of Section 9 use errors small in Hamming weight (corrupting few coordinates).

Encrypting with noisy equations

If nobody holds a short basis of the public lattice, how can the key holder decrypt? By exploiting linearity instead of a geometric trapdoor. Publish \(m\) noisy equations \((A, b = As + e \bmod q)\) as the public key, keeping \(s\) private. Because adding linear equations together preserves their solution, anyone can manufacture a fresh noisy equation in \(s\) without knowing \(s\) simply by summing a random subset of the public rows: the summed coefficients \(c_1\) and summed right-hand side \(b^{\top} r\) still satisfy \(b^{\top} r \approx \langle c_1, s \rangle \pmod q\), carrying only the sum of the selected rows' small errors. To encrypt one bit \(\mu \in \{0, 1\}\), the sender transmits that fresh equation unchanged for \(\mu = 0\), or adds \(\lfloor q/2 \rfloor\) to its right-hand side for \(\mu = 1\). The holder of \(s\) then evaluates \(c_2 - \langle c_1, s \rangle \bmod q\): the unknown modular inner product cancels out completely, revealing whether the equation is nearly satisfied (near 0) or deliberately off by half the modulus (near \(q/2\)).

key      16 noisy equations a · s + e = b in 4 unknowns mod 3,329; the errors e have standard deviation 64
encrypt  a 1: 8 of the 16 equations, chosen at random, added up, + 1,664:  c1 = (2070, 1370, 2987, 2109)   c2 = 492
decrypt  c2 − c1 · s = 1,786 = 1,664 + 122, the sum of the 8 errors: nearer 1,664 than 0, read as 1
clock    the residues mod 3,329 on a circle; the top half is read as 0, the bottom half as 1

                       0                    a decrypted value is the message, 0 or 1,664, plus a sum of errors;
              2,497         832             it is read wrong once that sum passes 832, a quarter of the modulus
                     1,664

run      1,001 bits encrypted and decrypted under this key: 0 read wrong. Exact, for this key: none of its
         65,536 subsets fails. Exact, with a fresh key every time: 2^-15
wider    errors of standard deviation 192, another key: 89 of 1,001 bits read wrong (9 %); exact for
         that key 9.2 %, with a fresh key every time 12.4 %
(the live figure needs JavaScript; it loads no data)
Regev's scheme in numbers and on a clock. Left: a public key of 16 noisy equations; the rows in ink are the random subset the last encryption added up. Right: every decrypted value at its place on the clock of 3,329, green, outside the circle when a 0 was sent and inside when a 1 was; hatched, the half in which it is read wrong, a quarter of the modulus (832) from the message. The hairline over a cloud is the exact law of this key's sums. Encrypt a bit, run 1,000, widen the errors, draw a new key. The readout counts the wrong bits beside two exact probabilities.

The figure uses a tiny key of 16 equations in four unknowns so every row is visible on screen; four unknowns offer no security, though the modulus \(q = 3{,}329\) matches ML-KEM's. Notice what happens on the residue clock during decryption: decryption never removes the summed errors, it simply cancels \(\langle c_1, s \rangle\) and reads the coarse message bit (0 at twelve o'clock, 1,664 at six o'clock) right through the residual noise.

Regev's 2005 paper writes the resulting public-key cryptosystem in four lines.

Definition 4.3.1 (Regev's scheme, one bit at a time). In the notation of Definition 4.2.1, the private key is \(s\) and the public key is \((A, b)\), that is, \(m\) noisy equations in \(s\). To encrypt a bit \(\mu\), draw \(r \in \{0, 1\}^m\) uniformly, which selects a random subset of the equations, and send

\[c_1 = A^{\top} r, \qquad c_2 = b^{\top} r + \mu \lfloor q/2 \rfloor \pmod q .\]

To decrypt, compute \(c_2 - \langle c_1, s \rangle \bmod q\) and return 1 if it lies strictly between \(q/4\) and \(3q/4\), the half of the residues around \(q/2\), and 0 otherwise.

Encryption from noisy equations, in four linesa row to a step, in time: the key holder, then anyone who sends a bit, then the key holder again

  1. 4.3private key the key holder, once

    A secret vector. Nothing else is kept, and nothing about the lattice: the holder knows only this one answer.

    s: n numbers mod q

  2. 4.2public key published

    Noisy equations in the secret: a random matrix, and its product with the secret plus a small error in every entry.

    A, and b = A s + e

  3. 4.3add up a random subset anyone, a bit at a time

    One more noisy equation in the same secret, made by adding up a random handful of the published ones, with half the modulus added to its right-hand side when the bit is 1.

    c1 = sum of the chosen rows of A

    c2 = sum of their b, + ⌊q/2⌋ for a 1

  4. 4.4subtract and round the key holder, with s

    The secret cancels the equations. What is left is the bit, scaled to half the modulus, under the sum of the chosen errors: read right while that sum stays under a quarter of the modulus.

    c2 − c1 · s = bit × ⌊q/2⌋ + summed errors

    between q/4 and 3q/4: read 1; else 0

green: the one step that needs the secret

In the page's toy implementation, the binary selector \(r\) is passed as a list subset of row indices; regevEncryptWithSubset sums those rows of A into c1, sums the matching entries of b into c2, and shifts c2 by \(\lfloor q/2 \rfloor\) when bit is 1:

function regevEncryptWithSubset(publicKey, bit, subset) {
  var q = publicKey.q, c1 = new Array(publicKey.n).fill(0), c2 = 0;
  for (var k = 0; k < subset.length; k++) {
    var row = publicKey.A[subset[k]];
    for (var j = 0; j < publicKey.n; j++) c1[j] = (c1[j] + row[j]) % q;
    c2 = (c2 + publicKey.b[subset[k]]) % q;
  }
  return { c1: c1, c2: (c2 + bit * Math.floor(q / 2)) % q };
}

FIPS 203, the standard that defines ML-KEM, introduces the assumption it rests on with this same construction, told in words.

In the LWE problem, the input is a set of random “noisy” linear equations in some secret variables 𝑥 ∈ ℤ𝑞𝑛, and the task is to recover 𝑥. The noise in the equations is such that standard algorithms (e.g., Gaussian elimination) are intractable. The LWE problem naturally lends itself to cryptographic applications. For example, if 𝑥 is interpreted as a secret key, then one can encrypt a one-bit plaintext value by sampling either an approximately correct linear equation (if the plaintext is zero) or a far-from-correct linear equation (if the plaintext is one). Plausibly, only a party in possession of 𝑥 can distinguish these two cases. Encryption can then be delegated to another party by publishing a large collection of noisy linear equations, which can be combined appropriately by the encrypting party. The result is an asymmetric encryption scheme.

—NIST, FIPS 203, "Module-Lattice-Based Key-Encapsulation Mechanism Standard" (2024). Section 3.2, in the informal account of the computational assumption, p. 13. The standard's 𝑥 is this part's \(s\), a vector of \(n\) numbers modulo \(q\). Its far-from-correct equation is the one shifted by half the modulus.

Why an eavesdropper learns nothing about \(\mu\) follows in two short hops. First, replace the LWE public key \((A, b)\) with a completely uniform matrix-vector pair \((A, u)\): if decision LWE (Definition 4.2.1) is hard, no efficient eavesdropper can detect the swap. Second, once \((A, u)\) is truly uniform and holds enough rows (roughly \(m \approx n \log q\), so that the \(2^m\) possible subset sums vastly outnumber the \(q^{n+1}\) possible pairs \((A^{\top} r, u^{\top} r)\)), the subset sum \((c_1, u^{\top} r)\) is statistically almost uniform in \(\mathbb Z_q^{n+1}\), completely masking \(\mu \lfloor q/2 \rfloor\). Any efficient distinguisher that guessed \(\mu\) from ciphertexts would therefore distinguish LWE samples from uniform randomness.This is security against an eavesdropper who may choose the messages, called semantic security or security against chosen-plaintext attacks: Peikert's survey, Section 4.2.3; Regev's survey, Section 4, which takes \(m = 1.1 \cdot n \log q\) equations. Notice the boundary of that guarantee: it covers only passive eavesdroppers. An active attacker who crafts malformed ciphertexts and observes how the receiver reacts steps outside this proof, and Section 6.4 demonstrates the key-recovery attack that opens up unless a protective check is wrapped around decryption.

The obvious drawback of plain Regev encryption is blow-up in size: sending a single bit transmits \(n + 1\) residues modulo \(q\), and the public key stores \(m(n + 1)\) of them. Section 4.4 closes with the symmetric variant that shrinks \(m\) down to a square \(n \times n\) matrix, and Section 5 introduces polynomial rings that pack \(n\) bits into one ciphertext while compressing the matrix by another factor of \(n\).

The noise budget

On the clock of residues modulo \(q\), message bit 0 sits at 0 (twelve o'clock) and message bit 1 sits at \(\lfloor q/2 \rfloor\) (six o'clock), separated by decision boundaries halfway around on either side at \(q/4\) and \(3q/4\). Subtracting \(\langle c_1, s \rangle\) from \(c_2\) cancels the public equations cleanly, so decryption recovers \(\mu\) whenever the summed errors stay under \(q/4\).

Proposition 4.4.1 (decryption, and the noise budget). Let \((c_1, c_2)\) encrypt the bit \(\mu\) with the subset \(r\), as in Definition 4.3.1. Then

\[c_2 - \langle c_1, s \rangle = \mu \lfloor q/2 \rfloor + r^{\top} e \pmod q, \tag{4.1}\]

and decryption returns \(\mu\) whenever \(\lvert r^{\top} e \rvert < q/4 - 1/2\).

Proof. Since \(\langle c_1, s \rangle = r^{\top} A s\) and \(b = As + e\),

\[\begin{aligned} c_2 - \langle c_1, s \rangle &= r^{\top} b + \mu \lfloor q/2 \rfloor - r^{\top} A s \\ &= r^{\top} (A s + e) - r^{\top} A s + \mu \lfloor q/2 \rfloor \\ &= \mu \lfloor q/2 \rfloor + r^{\top} e \pmod q . \end{aligned}\]

If \(\lvert r^{\top} e \rvert < q/4 - 1/2\), this value is within that distance of 0 when \(\mu = 0\), hence outside the middle half of the residues, and within that distance of \(\lfloor q/2 \rfloor\), a number from \((q - 1)/2\) to \(q/2\), when \(\mu = 1\), hence strictly inside it. ∎

The private vector \(s\) strips away the linear equations and leaves the summed errors \(r^{\top} e\) sitting atop \(\mu \lfloor q/2 \rfloor\). Decryption reads the right bit whenever that error sum stays below a quarter of the modulus (minus \(1/2\) to account for rounding \(q/2\) down on odd \(q\)): strictly below 832 when \(q = 3{,}329\). That three-line cancellation is the entire correctness proof of Regev's scheme, and with a few extra small terms in the noise sum it is the entire correctness proof of ML-KEM. In the page's code, regevDecrypt computes the modular residual value and checks \(q/4 < \text{value} < 3q/4\) in exact integers via 4 * value:

function regevDecrypt(secretKey, ciphertext, trace) {
  var q = secretKey.q, value = mod(ciphertext.c2 - dotMod(ciphertext.c1, secretKey.s, q), q);
  if (trace) trace.value = value;
  return 4 * value > q && 4 * value < 3 * q ? 1 : 0;
}

Every LWE scheme squeezes its error width from opposite sides: errors must be wide enough to thwart lattice attacks, yet narrow enough for their sums to fit inside the \(q/4\) decryption budget. Make the errors too small relative to \(q\), and the secret falls to the basis reduction of Section 4.6; make them too wide, and summed errors spill past \(q/4\). In the figure's 16-equation key, a random subset averages eight rows. When individual errors have standard deviation 64, summing eight independent errors gives standard deviation \(\sqrt 8 \cdot 64 \approx 181\), placing the threshold 832 more than four standard deviations away; under the first key drawn, not one of its 65,536 subsets fails. Raise the per-row standard deviation to 192, and the threshold sits only about 1.5 standard deviations away: the first key drawn misreads 9.2 % of its ciphertexts. Nobody has attacked the scheme at that point; it has simply ceased to decrypt reliably.

Lyubashevsky, Peikert and Regev, introducing the ring toolkit of Section 5.3, state this two-sided tension as a core design rule.

In all applications of ring-LWE, and particularly those related to homomorphic encryption, a main technical challenge is to control the sizes of the noise terms when manipulating ring-LWE samples under addition, multiplication, and other operations. For correct decryption, q must be chosen large enough so that the final accumulated error terms do not “wrap around” modulo q and cause decryption error. On the other hand, the error rate (roughly, the ratio of the noise magnitude to the modulus q) of the original published ring-LWE samples and the dimension n trade off to determine the theoretical and concrete hardness of the ring-LWE problem. Tighter control of the noise growth therefore allows for a larger initial error rate, which permits a smaller modulus q and dimension n, which leads to smaller keys and ciphertexts, and faster operations for a given level of security.

—V. Lyubashevsky, C. Peikert and O. Regev, "A Toolkit for Ring-LWE Cryptography" (2013). EUROCRYPT 2013; ePrint 2013/293, Section 1. The paragraph applies unchanged to the plain problem. Homomorphic encryption computes on ciphertexts without decrypting them, and every operation adds to their errors.

Remark 4.4.2 (two failure probabilities). Counting wrong bits under a single fixed key measures only that specific key's failure probability, and individual keys vary widely: at standard deviation 192, the first three keys drawn fail on 9.2 %, 4.3 %, and 12 % of their ciphertexts, whereas the true average across all keys is 12.4 %. Testing one key therefore cannot estimate the overall failure rate. Standards quote the joint probability averaged over both key generation and encryption: at standard deviation 64 that average is roughly \(2^{-15}\) for this toy scheme, even though the first key drawn has zero failing subsets. FIPS 203's quoted failure bound of \(2^{-164.8}\) for ML-KEM-768 is defined over keys and ciphertexts in the same joint way, and Section 6.3 computes it exactly.FIPS 203, Section 3.2, defines the probability of a decapsulation failure, a run that leaves the two sides with different keys, over the random seeds of key generation and the random message of the sender; the rates are in its Table 1.

Definition 4.3.1 needed \(m \approx n \log q\) public rows only because the sender combined rows with binary \(0/1\) weights and added no fresh noise of their own. ML-KEM switches to a symmetric variant with a square \(n \times n\) matrix \(A\), in which the sender generates fresh LWE samples mirroring the key holder's.Lyubashevsky's tutorial, Sections 2.2 and 2.3.1, which introduces the scheme by its likeness to ElGamal encryption, a classical scheme made from the key agreement of Section 1.3; Peikert's survey, Section 5.2.3. The key holder draws both \(s\) and \(e\) from the small error distribution and publishes \(t = As + e\) (FIPS 203's name for \(b\)). To encrypt \(\mu\), the sender draws small vectors \(r\) and \(e_1\) together with a small scalar \(e_2\), and sends

\[u = A^{\top} r + e_1, \qquad v = t^{\top} r + e_2 + \mu \lceil q/2 \rfloor \pmod q,\]

where \(\lceil q/2 \rfloor\) rounds \(q/2\) to the nearest integer (1,665 for \(q = 3{,}329\), whereas the floor in Definition 4.3.1 gave 1,664). Expanding \(v - s^{\top} u\) cancels the shared term \(s^{\top} A^{\top} r\) in the same three lines:

\[v - s^{\top} u = \mu \lceil q/2 \rfloor + e^{\top} r + e_2 - s^{\top} e_1 \pmod q . \tag{4.2}\]

Read symmetrically, this is Diffie-Hellman key agreement (Section 1.3) carried out with noisy matrices: the key holder publishes \(t \approx As\), the sender publishes \(u \approx A^{\top} r\), both compute approximate versions of \(s^{\top} A^{\top} r\) that differ only by the small cross-noise \(e^{\top} r - s^{\top} e_1\), and \(\mu\) rides at half the modulus, coarse enough to survive that discrepancy. Security invokes decision LWE twice: once to replace the \(n\) rows of \(t\) with uniform randomness, and a second time to argue that \((u, v - \mu \lceil q/2 \rfloor)\), being \(n + 1\) noisy inner products in the sender's secret \(r\), looks uniform as well.

Notice how the noise in (4.2) scales: \(e^{\top} r - s^{\top} e_1 + e_2\) sums \(2n\) products of two small integers plus one small integer, independent of \(q\), while the decryption budget \(q/4\) scales linearly with \(q\). If every small entry has magnitude at most \(\beta\), the worst-case noise sum reaches \(2n\beta^2 + \beta\); for 768 unknowns and \(\beta = 2\), that worst case is 6,146, far past the limit of 832. Because the \(2n\) terms carry independent random signs, however, they mostly cancel out, keeping typical sums near \(O(\sqrt{n}\,\beta^2)\). Accordingly, ML-KEM does not guarantee zero decryption failures in the worst case; instead, its designers computed the exact tail probability that the sum reaches 832 and chose parameters to drive that probability astronomically low.Lyubashevsky's tutorial, Section 2.3.1 for the bound and Section 2.3.2 for the typical size and the exact computation, which multiplies the laws of the terms as polynomials.

Why it is believed hard

No one can prove unconditionally that LWE is hard, any more than anyone has proved factoring hard (Section 10.1). Confidence in LWE rests on three distinct pillars: a mathematical reduction that rules out average-case flukes, two decades of cryptanalytic attack records, and the absence of a quantum period-finding shortcut.

The reduction directly addresses the failure of GGH in Section 3.6. GGH relied on heuristic trapdoor lattices with no proof tying its generated keys back to general lattices, and attackers exploited special structure in those keys. Any public-key scheme requires average-case hardness across the random keys it actually generates, a much stronger demand than worst-case hardness: many computational puzzles with hard worst-case corners become easy on typical random inputs.Peikert's survey, Section 1, which credits the first connection between the worst case and the average case of lattice problems to M. Ajtai, "Generating hard instances of lattice problems", STOC 1996. Regev's 2005 paper proved that for LWE, solving typical random instances is at least as hard as solving two standard worst-case approximation problems on every \(n\)-dimensional lattice: GapSVP (deciding whether \(\lambda_1(\mathcal L)\) is below a threshold or more than \(\gamma\) times above it) and SIVP (finding \(n\) linearly independent lattice vectors within a factor \(\gamma\) of the shortest possible maximum length).

Theorem 4.5.1 (solving random instances is at least as hard as approximating short vectors in every lattice on a quantum computer). Let \(0 < \alpha < 1\) and \(q \le 2^{\mathrm{poly}(n)}\), let the error law be a discretized normal law of width \(\alpha q \ge 2\sqrt n\), and let the number of equations be polynomial in \(n\). If an algorithm solves the decision problem of Definition 4.2.1 in time polynomial in \(n\), then a quantum algorithm solves in polynomial time, on every lattice of dimension \(n\), two approximation problems with a factor \(\gamma = \tilde O(n/\alpha)\): to decide whether the shortest nonzero vector is at most a given length or more than \(\gamma\) times that length (GapSVP), and to find \(n\) linearly independent lattice vectors that are at most \(\gamma\) times longer than such vectors need to be (SIVP).

Read in the direction that matters: unless a quantum computer can approximate short vectors within a factor of about \(n/\alpha\) in every lattice of dimension \(n\), no efficient algorithm tells random noisy equations with errors that wide from random numbers. A random matrix cannot have produced an easy special case, because an algorithm for the random case would deal with every case.The statement is the one in Peikert's survey, Section 4.2.2, of the theorem of Regev's paper, which the survey gives in a slightly stronger form than the paper. In its convention a normal law of width \(w\) has standard deviation \(w/\sqrt{2\pi}\). Discretized means made to take whole-number values, which the paper does by rounding; \(\mathrm{poly}(n)\) stands for a polynomial in \(n\), and \(\tilde O\) hides factors logarithmic in \(n\). A reduction that needs no quantum computer was given in 2009, for the first of the two problems and an exponentially large modulus (Section 4.2.4 there). Reductions of this kind are still being added.Three papers posted on 30 November 2026 relate the worst-case problems to the average-case ones with other approximation factors than the earlier reductions: Anthropic, "Approximate search SVP reduces to SIS and SIVP and, quantumly, to LWE and GapSVP", "A converse of the dual attack, and a quantum equivalence of SIVP and LWE at small noise rates" and "Public-key encryption from GapSVP within Õ(n), classically: an adaptive reduction to decision LWE in dimension kn with exponential modulus" (November 2026, in the folder lattices of github.com/anthropics/formal-math, with a formalization in the proof language Lean 4). They are reductions between lattice problems, not algorithms against a scheme. They are posted, not peer reviewed, and nothing in them was checked for this series.

What such a theorem gives, and what it does not, is said most plainly by four authors who went looking for the concrete guarantee.

Remark 7. Suppose that one has a polynomial-time reduction of a well-studied worst-case problem Π1 to an average-case problem Π2. Then, if one assumes that the worst-case instances of Π1 are not polytime solvable, then the reduction provides the assurance that no polynomial-time algorithm can solve Π2 on average. This asymptotic assurance is viewed by some as ruling out “structural weaknesses” in Π2; for example, see Section 5.1 of [66]. However, in the absence of a concrete analysis, the reduction by itself does not guarantee the hardness of fixed-sized instances of Π2.

—S. Chatterjee, N. Koblitz, A. Menezes and P. Sarkar, "Another Look at Tightness II: Practical Issues in Cryptography" (2016). Mycrypt 2016 (LNCS 10311); ePrint 2016/360, Section 6.4. Here Π1 is the worst-case lattice problem and Π2 the decision problem of Definition 4.2.1; the reference [66] is to the designers of a hash function built on lattices.

Remark 4.5.2 (the theorem sets no sizes). Reading Theorem 4.5.1 as a certificate that a specific parameter set is secure would be wrong on three separate counts. First, the reduction is asymptotic and suffers huge polynomial blow-up ("non-tightness"): working through the constants for 1,024 unknowns, Chatterjee et al. calculate that an attack of cost \(T\) on random LWE converts into a worst-case quantum lattice solver of cost roughly \(2^{504}\,T\), whereas the fastest quantum SVP algorithm known in their analysis already runs in about \(2^{293}\) steps, rendering the bound vacuous at concrete sizes. Second, practical schemes step outside the theorem's hypotheses: Theorem 4.5.1 requires error width at least \(2\sqrt n\) (dozens at real dimensions), whereas ML-KEM caps individual error coordinates at 3, and ML-KEM replaces the unstructured matrix \(A\) of Definition 4.2.1 with a structured module matrix whose worst-case guarantee applies only within module lattices (Section 5.3). Third, the underlying worst-case problems themselves rest on conjecture rather than proof: at approximation factors near \(n/\alpha\) they are likely not NP-hard (Remark 3.2.3), and their assumed hardness must hold against quantum algorithms. What Theorem 4.5.1 truly provides is structural insurance that random LWE instances hide no unexpected algebraic trapdoor. Concrete parameter sizes come instead from pricing the best known attacks: as a tutorial on the two lattice standards puts it, parameter tables are "set based on the best currently-known lattice-reduction algorithm".The worked example is Section 6.5 of the same paper, for the parameters of Regev's scheme and one reading of 128-bit security; \(2^{293}\) is its figure for the fastest quantum algorithm known in 2016 for the exact shortest vector problem, which it assumes to be the fastest for the problems of the theorem as well. On the hypothesis, Peikert's survey, Section 5.2.3, notes of the scheme in the form of (4.2) that a guarantee from this theorem needs small entries of the order of \(\sqrt n\). The tutorial is Lyubashevsky's, Section 3.4.

The second pillar is the empirical record of cryptanalysis. As of November 2026, every known attack against plain LWE at practical noise rates and key-sized equation counts takes time exponential in \(n\). The strongest attacks reduce LWE to basis reduction (Section 3.4), set up as in Section 4.6, where total cost is governed by solving exact SVP inside \(b\)-dimensional blocks. Over two decades of improvements, the fastest block solver, lattice sieving (Section 3.5), has seen its asymptotic exponent trimmed from roughly \(2^{0.415\,b}\) down to \(2^{0.292\,b}\) in the 2021 Kyber specification, sharpening the constant in the exponent while leaving the exponential wall intact.Avanzi et al., "CRYSTALS-Kyber Algorithm Specifications and Supporting Documentation", version 3.02 (4 August 2021), Section 5.1.1. Section 10 examines that twenty-year trajectory in full.

The third pillar is the absence of an algebraic quantum shortcut. Shor's algorithm broke Section 1's schemes by uncovering a hidden period via the quantum Fourier transform (Section 2.1), and no analogous period has been found for general lattices. Immediately after stating Theorem 4.5.1, Peikert's 2016 survey notes what quantum algorithms were known.

Theorem 4.2.4 is proved by giving a quantum polynomial-time reduction that uses an oracle for LWE to solve GapSVPγ and SIVPγ in the worst case, thereby transforming any algorithm (whether classical or quantum) that solves LWE into a quantum algorithm for lattice problems. The quantum nature of the reduction is meaningful because there are no known quantum algorithms for GapSVPγ or SIVPγ that significantly outperform classical ones, beyond generic quantum speedups. Still, it would be very useful to have a completely classical reduction to give further confidence in the hardness of LWE. Such a reduction was given in 2009 by Peikert [Pei09], and is discussed below in Section 4.2.4.

—Chris Peikert, "A Decade of Lattice Cryptography" (2016). Foundations and Trends in Theoretical Computer Science 10(4), 2016; ePrint 2015/939, Section 4.2.2. Theorem 4.2.4 and Section 4.2.4 are the survey's own numbers: its theorem is the one stated here as Theorem 4.5.1.

Those generic quantum speedups come from Grover-style search (Section 2.6) accelerating neighbor finding inside sieving: the exponent drops from \(0.292\,b\) to \(0.265\,b\), trimming ML-KEM-768's estimated cost in Section 4.6 from \(2^{183}\) to \(2^{166}\) operations, and ML-KEM's designers remark where they quote both exponents that "in practice, the quantum speed-up remains tenuous". Shor's algorithm, by contrast, collapsed super-polynomial runtime all the way to polynomial. Two caveats keep this third pillar empirical rather than proved. First, not knowing a fast quantum algorithm is not a proof that none can exist; indeed, Regev's reduction behind Theorem 4.5.1 uses the quantum Fourier transform of Section 2.3 constructively inside its proof. Second, that absence applies to unstructured lattices. For lattices carrying the extra module symmetry used in the standards (Section 5.3), a paper posted on 30 November 2026 gives a quantum algorithm whose asymptotic running time is quasi-polynomial as the ring degree grows (faster than exponential, though able to outgrow every polynomial). Its authors call the algorithm galactic and not practical for the parameter sets of ML-KEM and ML-DSA (Dilithium, the signature standard of Section 7), and it does not apply to the unstructured plain LWE problem of Section 4; Section 5.6 examines what it shows.Anthropic, "Galactic quasi-polynomial quantum algorithms for integral and module lattices", November 2026, posted in the same folder as the three papers of reductions and, like them, not peer reviewed and not checked for this series. Its list of limitations names learning with errors on general lattices among what it does not treat.

How big is big enough

Because Theorem 4.5.1 sets no concrete sizes, choosing \(n\) comes down to running and modeling the strongest attacks and leaving a safety margin. In Section 4.2, recovering \(s\) from \(b = As + e \bmod q\) was a closest vector problem (finding the lattice point near an external target \(b\)), whereas LLL and BKZ (Section 3.4) search for short vectors. Kannan's primal embedding converts that closest-vector instance into a single shortest-vector instance of dimension \(m + n + 1\) by packing \(q I_m\), \(A\), and \(b\) into the columns of one basis matrix:

\[B = \begin{pmatrix} q I_m & A & b \\ 0 & I_n & 0 \\ 0 & 0 & 1 \end{pmatrix} .\]

Multiply \(B\) by the integer column vector \((k, -s, 1)^{\top}\), where \(k \in \mathbb Z^m\) is the modular wrap-around vector satisfying \(b - As + qk = e\): subtracting \(As\) and multiples of \(q\) from \(b\) leaves \(e\) in the top \(m\) coordinates, records \(-s\) in the middle \(n\) coordinates, and keeps \(1\) at the bottom, producing the lattice vector \((e, -s, 1)\). When both \(s\) and \(e\) have tiny entries (such as \(-2\) to 2 in ML-KEM), that vector has length roughly \(\sqrt{m + n}\), dramatically shorter than the Gaussian heuristic (Definition 3.5.1) predicts for a random lattice of dimension \(m + n + 1\) and determinant \(q^m\). An LWE key is thus a lattice containing one planted, anomalously short vector, and basis reduction hunts directly for it: first LLL, followed by BKZ at increasing block sizes until \((e, -s, 1)\) (or its negation) surfaces in the basis and reveals \(s\).

measured   seconds of one core to recover a secret by lattice reduction (modulus 3,329, secret and errors
           from −2 to 2, as many equations as unknowns): 90 runs, 5 a size, every secret found
           unknowns           30     50     70 |    85    100    115    120 |   125    130    140
           seconds, median  0.03   0.17   0.46 |   4.7     14     49     62 |   159    247    712
                            plain reduction    |   block reduction needed   |   after a step of 2.5 ×
           fitted on 85 to 140 unknowns: the time doubles every 7.3 unknowns (6.8 to 7.7)
           fitted on 115 to 140: every 6.3 (5.8 to 6.9)
           beyond 140 unknowns: not run here (140 took 8 to 17 minutes)
break      another attack, another unit: nothing here turns seconds into operations
published  ML-KEM-512      512 unknowns, 3.7 times 140    2^151.5 gates    core-SVP 2^118, quantum 2^107
           ML-KEM-768      768 unknowns, 5.5 times        2^215.1 gates    core-SVP 2^183, quantum 2^166
           ML-KEM-1024   1,024 unknowns, 7.3 times        2^287.3 gates    core-SVP 2^256, quantum 2^232
           estimates for sieving at block sizes 406 to 894: nobody can run these
(the live figure needs JavaScript and loads about 0.06 MB of data)
Left, measured: the seconds one core took to recover the secret of a learning-with-errors instance at ML-KEM's modulus, with secret and errors from −2 to 2 (the law of ML-KEM-768 and 1024; ML-KEM-512's is wider). Green: a run. Repeated, a run took the same time within 1.3 % where the arithmetic was the same, and between 0.5 and 1.6 times as long above 120 unknowns. Lines: two fits, each over its own sizes. Right, beyond the break: the estimates published for ML-KEM, hollow, for another attack in another unit. Point at a mark to read it; the button runs the attack in this page.

Example 4.6.1 (the attack, measured). Draw 90 instances of Definition 4.2.1 at ML-KEM's modulus \(q = 3{,}329\), setting \(m = n\) and drawing both \(s\) and \(e\) from \(-2\) to 2 under the centered binomial law of ML-KEM-768 and ML-KEM-1024, with five instances at each of 18 sizes from 30 to 140 unknowns. Running fplll 5.5.0 on a single core of a 16-core server, each embedded basis \(B\) is reduced first by LLL and then by BKZ at block sizes 3, 4, 5, and upward, one tour per block size, halting as soon as a basis vector yields a candidate \(s\) verified against \(A\), \(b\), and \(q\); we record the single-core processor time from the start of LLL to recovery.

Every single one of the 90 secrets was recovered. Up to 70 unknowns, LLL alone uncovers the planted vector in under half a second, and the page's plain-JavaScript implementation breaks instances up to 60 unknowns directly in the browser. From 85 unknowns onward, every instance requires BKZ, and across the measured range median recovery time doubles every six to eight unknowns depending on the fitting window: every 7.3 unknowns across 85 to 140 and every 6.3 across 115 to 140 (with 8.2 across 85 to 120 and 6.0 across 120 to 140). At 140 unknowns, recovery took 8 to 17 minutes and reached block sizes 55 to 60. The experiment stopped at 140 because its compute budget ended, not because the attack hit a barrier. ◁

What those timings omit matters just as much as what they show. They measure one specific attack implementation on a single core, and their fitted slope cannot be extrapolated straight to cryptographic sizes: inside each BKZ block, fplll searched by tree enumeration (Section 3.4), whose runtime grows super-exponentially in the block size \(b\), whereas state-of-the-art attacks at large block sizes switch to sieving, which was not run here. Even the visible 2.5-fold jump in runtime between 120 and 125 unknowns (where five extra unknowns elsewhere cost 1.2-fold to 1.7-fold) is an artifact of fplll's internal parameterization, in which one tour jumps roughly tenfold between block sizes 40 and 50, rather than a sudden change in LWE itself. And each dot is a single run: re-running instances above 120 unknowns varied between 0.5 and 1.6 times the initial time.

ML-KEM's standardized parameter sets use 512, 768, and 1,024 unknowns, 3.7, 5.5, and 7.3 times the largest system broken here, and their published security estimates are not extrapolations of enumeration seconds. Instead, they price a faster sieving attack in abstract operation or gate counts. Using a geometric model of BKZ's reduced profile (Section 3.4), ML-KEM's designers compute the block size \(b\) at which the planted vector becomes detectable: block sizes 406, 626, and 878, compared with at most 60 in our experiment. Under the conservative core-SVP methodology, which charges only a single call to the best known sieve at that block size (at the exponents of Section 3.5) and ignores tour overhead, the three sets require \(2^{118}\), \(2^{183}\), and \(2^{256}\) classical operations, or \(2^{107}\), \(2^{166}\), and \(2^{232}\) with the quantum speedup of Section 4.5. A refined circuit-level count in elementary logic gates yields \(2^{151.5}\), \(2^{215.1}\), and \(2^{287.3}\) gates.Avanzi et al. (2021), Table 4, where the three sets carry their earlier names Kyber512, Kyber768 and Kyber1024. The refined count is made at block sizes 413, 637 and 894, and Section 5.3 there puts its uncertainty at a factor between \(2^{-16}\) and \(2^{14}\). The categories are claimed in FIPS 203, Section 8. On the strength of such estimates, FIPS 203 assigns the three sets to NIST security categories 1, 3, and 5, meaning an attack should cost at least as much as exhaustive key search against AES-128, AES-192, or AES-256 (Section 1.6); Section 10.4 explains how gate models map to categories. Notice that these estimates treat ML-KEM's underlying lattice as completely unstructured; Section 5.6 asks whether its extra algebraic symmetry changes the picture.

Standardized lattice dimensions thus rest on cost models for the best known sieving attacks weighed against published cryptanalytic records (Section 10.4), not on Theorem 4.5.1 and not on small-scale browser or server timings.

Exact linear equations fall immediately to Gaussian elimination, whereas adding a tiny error to each equation turns solving into bounded-distance decoding on a random lattice, where as of November 2026 nothing much faster than exponential search is known at cryptographic sizes. Publishing noisy equations as a public key lets anyone encrypt a bit by summing a combination of equations and shifting by half the modulus, while the secret holder decrypts reliably so long as the accumulated errors stay under a quarter of the modulus.

The remaining catch is size: an unstructured matrix of \(n \times n\) residues modulo \(q\) at \(n\) near a thousand holds roughly a million numbers, and Section 5 shows how polynomial rings compress it.

← Back to all posts