Learning With Errors Exercise

Here’s a concrete example of a LWE problem and how one might attack it “by hand.” This exercise will make the inherent difficulty of the problem quite intuitive, but also give us some ideas on how one might write a LWE solver in practice to attack badly-written / small LWE problems.

Problem (by Aardvark)

We are working over , and there is some secret vector . There are two sets of claims. Each claim “” purports the relationship

One of the sets of claims is “genuine” and comes from a consistent set of , while the other set is “fake” and has randomly generated values. Tell them apart and find the correct secret vector .

Blue Set Red Set
(1, 0, 1, 7) : 2 (5, 4, 5, 2) : 2
(5, 8, 4, 10) : 9 (7, 7, 7, 8) : 5
(7, 7, 8, 5) : 3 (6, 8, 2, 2) : 0
(5, 1, 10, 6) : 3 (10, 4, 4, 3) : 1
(8, 0, 2, 4) : 1 (1, 10, 8, 6) : 6
(9, 3, 0, 6) : 9 (2, 7, 7, 4) : 4
(0, 6, 1, 6) : 9 (8, 6, 6, 9) : 1
(0, 4, 9, 7) : 5 (10, 6, 1, 6) : 9
(10, 7, 4, 10) : 10 (3, 1, 10, 9) : 7
(5, 5, 10, 6) : 8 (2, 4, 10, 3) : 7
(10, 7, 3, 1) : 9 (10, 4, 6, 4) : 2
(0, 2, 5, 5) : 6 (8, 5, 7, 2) : 2
(9, 10, 2, 1) : 2 (4, 7, 0, 0) : 8
(3, 7, 2, 1) : 5 (0, 3, 0, 0) : 0
(2, 3, 4, 5) : 3 (8, 3, 2, 7) : 8
(2, 1, 6, 9) : 3 (4, 6, 6, 3) : 2

Solution

We start with some helpful notation. Define an information vector , where , to mean the statement “, where ”. In particular, a given purported approximation in the LWE protocol corresponds to the information vector . The benefit of this notion is that we can take linear combinations of them. Specifically,

Proposition: If and are information vectors (where are vectors), then

where and .

We can observe the following:

  1. if we obtain two vectors and , then we have the information (assuming the vectors are accurate) . So if we are lucky enough, say, to have , then we have found an actual equation with no error.
  2. As we linearly combine vectors, their “error part” gets bigger exponentially. So we can only add vectors very few times, ideally just 1 or 2 times, before they start being unusable.

With these heuristics, we are ready to solve this problem.

Red Set

First, we show that the “Red set” is inconsistent. Our main strategy will be to make vectors with many ’s in the same places.

  1. Our eyes are drawn to the juicy-looking , which immediately gives .
  2. gives . Since , , and .
  3. which is nice because it has 3 zeroes! This gives . Combining with (2), we conclude that .
  4. We can reuse . Since we knew from (2) that , we can substitute to get . This forces because of (1).

At this point, basically any isolation of the first two variables would force a contradiction. For example, we can compute

Since , but , we have a contradiction.

Blue Set

This is slightly harder because we don’t have really nice vectors like , but still very doable. First, we try to isolate two of the variables. For example, we can compute

By looking at the intersection, we can conclude that . Equivalently, or . Now, we can compute

The combination proves that ; in turn, we deduce by substitution. We omit some details in the remaining algebra (which can be done in various ways, as any triple of equations will set up 3 “almost equations” in the 2 remaining unknowns):

  1. gives .
  2. gives .
  3. gives .

This is enough to conclude that and , giving the answer .