SIS, LWE, Ring-SIS

What’s the difference between Learning With Errors (LWE) and Ring Learning With Errors(RLWE)? Well, for this, one first needs to know what are ideal lattices.

Ideal lattices are a generalization of cyclic lattices. And what are cyclic lattices?

First, we define the rotational shift operator rotrot on Rn\mathbb{R}^n (n2n \ge 2):

rot(x1,...,xn1,xn)=(xn,x1,...,xn1)rot(x_1, ..., x_{n-1}, x_n) = (x_n, x_1, ..., x_{n-1})

A cyclic lattice is a lattice that is closed under the rotation shift operator. For example, Zn\mathbb{Z}^n is a cyclic lattice.

Let’s now observe the ring Z[x]/(xn1)\mathbb{Z}[x]/(x^n-1).

First of all, if we take the polynomials in Z[x]\mathbb{Z}[x] up to some degree, let’s say nn, we can view these polynomials as points in Zn\mathbb{Z}^n, simply by viewing, for example, a0+a1x+a2x2a_0 + a_1 x + a_2 x^2 as (a0,a1,a2)(a_0, a_1, a_2). Now, the problem is that when we multiply two polynomials, we can end up with the polynomial that is of degree greater than nn.

For example, let’s have n=2n = 2 and polynomials a=a0+a1xa = a_0 + a_1 x, b=b0+b1xb = b_0 + b_1 x. We can see aa as (a0,a1)(a_0, a_1) and bb as (b0,b1)(b_0, b_1).

However, we have:

ab=a0b0+(a1b0+a0b1)x+a1b1x2a b = a_0 b_0 + (a_1 b_0 + a_0 b_1) x + a_1 b_1 x^2

We would need three coordinates for ab=(a0b0,a1b0+a0b1,a1b1)a b = (a_0 b_0, a_1 b_0 + a_0 b_1, a_1 b_1).

It would be nice if we could stay within two coordinates. So, we take R=Z[x]/(x21)R = \mathbb{Z}[x]/(x^2-1). Now, in RR, we have x21=0x^2 - 1 = 0, which means x2=1x^2 = 1. This allows us to always replace x2x^2 by 11, ensuring that we never get a polynomial of degree greater than 11.

So, our vector abab is actually:

ab=a0b0+(a1b0+a0b1)x+a1b1x2=a0b0+(a1b0+a0b1)x+a1b1=a b = a_0 b_0 + (a_1 b_0 + a_0 b_1) x + a_1 b_1 x^2 = a_0 b_0 + (a_1 b_0 + a_0 b_1) x + a_1 b_1 =

=(a0b0+a1b1)+(a1b0+a0b1)x= (a_0 b_0 + a_1 b_1) + (a_1 b_0 + a_0 b_1) x

In lattice-based cryptograpy, we operate in the ring R=Z[x]/(xn1)R = \mathbb{Z}[x]/(x^n-1). Let’s consider an ideal IRI \subset R. The lattice that corresponds to II (by viewing the RR elements as points in Zn\mathbb{Z}^n, as described earlier) is called an ideal lattice. It is a sublattice of Zn\mathbb{Z}^n.

It holds:

Theorem: The lattice LZnL \subset \mathbb{Z}^n is cyclic if and only if it corresponds to some ideal II in the quotient polynomial ring R=Z[x]/(xn1)R = \mathbb{Z}[x]/(x^n-1).

The theorem can be quickly proved (see Wikipedia (opens new window)) by observing that the rotational shift operator is the same as multiplying by xx in Z[x]/(xn1)\mathbb{Z}[x]/(x^n-1).

Let’s have (I am abusing the equal sign operator a bit):

(a0,...,an2,an1)=a0+...+an2xn2+an1xn1(a_0, ..., a_{n-2}, a_{n-1}) = a_0 + ... + a_{n-2} x^{n-2} + a_{n-1} x^{n-1}

Then:

rot((a0,...,an2,an1))=(an1,a0,...,an2))=rot((a_0, ..., a_{n-2}, a_{n-1})) = (a_{n-1}, a_0, ..., a_{n-2})) =

=an1+a0x+...+an2xn2= a_{n-1} + a_0 x + ... + a_{n-2} x^{n-2}

=x(a0+...+an2xn2+an1xn1)= x(a_0 + ... + a_{n-2} x^{n-2} + a_{n-1} x^{n-1})

Learning With Errors (LWE)

The LWE problem was introduced by Oded Regev in 2005, and it asks to solve a system of noisy linear equations. That is, to find sZqns \in \mathbb{Z}^n_q given:

{(ai,y=<ai,s>+ei);sZqn,aiZqn,eiZ}i=1m\{(a_i, y = <a_i, s> + e_i); s \in \mathbb{Z}^n_q, a_i \in \mathbb{Z}^n_q, e_i \in \mathbb{Z} \}^m_{i=1}

We could also write:

As+e=ymodqA s + e = y \; mod \; q

where AZqm×nA \in \mathbb{Z}^{m \times n}_q and eZqne \in \mathbb{Z}^n_q.

Short Integer Solution (SIS) problem

The system of linear equations

Ax=bmodqAx = b \; mod \; q

where AZqm×nA \in \mathbb{Z}^{m \times n}_q and bZqnb \in \mathbb{Z}^n_q can be solved in polynomial time with Gaussian elimination. However, variations of this problem can be hard. For example, when we require that the norm of xx is smaller than some bound BB. Note that the bound needs to be smaller than qq; otherwise, (q,0,...,0)(q, 0, ..., 0) is a trivial solution.

The SIS problem SIS(m,n,q,B)SIS(m, n, q, B) is the problem of finding x=(x1,...,xn)x = (x_1, ..., x_n) such that xiB|x_i| \leq B.

MIT notes (opens new window) say the solutions are very likely to exist if (2B+1)m>>qn(2B + 1)^m >>q^n. If not, we first pick a BB-bounded vector ee and compute b=Aemodqb = Ae \; mod \; q. We "plant" the solution ee inside bb (this is called the planted regime or the LWE regime).

The SIS and LWE problems are related.

Let’s say we have a matrix CC such that CA=0modqC A = 0 \; mod \; q. We are solving

As+e=ymodqA s + e = y \; mod \; q

C(As+e)=CymodqC(A s + e) = C y \; mod \; q

Ce=CymodqC e = C y \; mod \; q

which is a SIS problem.

Example of public-key cryptosystem based on LWE

Let’s have a secret key sZqns \in \mathbb{Z}^n_q and a public key (ai,bi=<ai,s>q+ei)i=1m(a_i, b_i = \frac{<a_i, s>}{q} + e_i)^m_{i=1}.

The encryption of a bit xx goes as follows. Let’s choose a subset S[m]S \subset [m] and compute the ciphertext:

c=(a,b)=(iSai,x2+iSbi)c = (a, b) = (\sum_{i \in S} a_i, \frac{x}{2} + \sum_{i \in S} b_i)

The decryption of cc is 00 if b<a,s>qb - \frac{<a, s>}{q} is closer to 00 than to 12\frac{1}{2}, and 11 otherwise.

Just for intuition, let’s have S={1,2}S = \{1, 2\}. Then

c=(a,b)=(a1+a2,x/2+<a1,s>q+<a2,s>q)c = (a, b) = (a_1 + a_2, x/2 + \frac{<a_1, s>}{q} + \frac{<a_2, s>}{q})

And we have:

(b<a,s>q)=x2(b - \frac{<a, s>}{q}) = \frac{x}{2}

Hash function based on SIS

Let’s have AZqn×mA \in \mathbb{Z}^{n \times m}_q and e[0,B]me \in [0, B]^m. We define

hA(e)=Aemodqh_A(e) = Ae \; mod \; q

Can we find a collision? It’s difficult, because

hA(e1)=hA(e2)h_A(e_1) = h_A(e_2)

means

Ae1Ae2=A(e1e2)=0Ae_1 - Ae_2 = A(e_1 - e_2) = 0

and because (e1e2)[B,B]m(e_1 - e_2) \in [-B, B]^m this means a solution to the SIS problem.

However, as simple as this hash function is, it is also inefficient—just reading the matrix requires a time of n2n^2.

How to make hash function faster

This is where ideal lattices come into play. The idea is to only have matrices which enable very fast multiplication.

So let’s have AZqn×mA \in \mathbb{Z}^{n \times m}_q where m>nm > n (to have a compression function), and let’s have nmn | m, let’s denote l=mnl = \frac{m}{n}. Let’s see AA as a tuple of matrices: A=(A1,...,Al)A = (A_1, ..., A_l).

Let’s have e{1,0,1}me \in \{-1, 0, 1\}^m. Let’s see ee as an ll-tuple (e1,...,el)(e_1, ..., e_l).

The operation AeA e is now:

hA(e)=(A1,...,Al)(e1,...,el)Th_A(e) = (A_1, ..., A_l) (e_1, ..., e_l)^T

We will take AiA_i of special form to have fast multiplication. Let’s have vectors a1,...,ala_1, ..., a_l where ai=(ai,1,...,ai,n)a_i = (a_{i,1}, ..., a_{i,n}).

We define

Rot(ai)=(ai,1ai,n...ai,2ai,2ai,1...ai,3............ai,n1ai,n2...ai,nai,nai,n1...ai,1)Rot(a_i) = \begin{pmatrix} a_{i,1} & a_{i, n} & ... & a_{i,2} \\ a_{i,2} & a_{i, 1} & ... & a_{i,3} \\ ... & ... & ... & ... \\ a_{i,n-1} & a_{i,n-2} & ... & a_{i,n} \\ a_{i,n} & a_{i,n-1} & ... & a_{i,1} \end{pmatrix}

Let’s define

X=(00...0110...0001...00.........0000...10)X = \begin{pmatrix} 0 & 0 & ... & 0 & 1 \\ 1 & 0 & ... & 0 & 0 \\ 0 & 1 & ... & 0 & 0 \\ ... & ... & ... & 0 & 0 \\ 0 & 0 & ... & 1 & 0 \end{pmatrix}

It holds:

Rot(ai)=(ai,Xai,X2ai,Xn1ai)Rot(a_i) = (a_i, X a_i, X^2 a_i, X^{n-1} a_i)

But also:

Rot(ai)=ai,1In+ai,2X+...+ai,nXn1Rot(a_i) = a_{i,1} I_n + a_{i,2} X + ... + a_{i,n} X^{n-1}

We can see that R~:={Rot(a);aZn}\tilde{R} := \{Rot(a); a \in \mathbb{Z}^n \} is isomorphic to R=Z[x]/(xn1)R = \mathbb{Z}[x]/(x^n - 1).

So instead of multiplying the matrices from Zqn×n\mathbb{Z}^{n \times n}_q, we can move into R[q]R_{[q]} and multiply polynomials via fast Fourier transform.

So above we had:

hA(e)=(Rot(a1),...,Rot(al))(e1,...,el)Tmodqh_A(e) = (Rot(a_1), ..., Rot(a_l)) (e_1, ..., e_l)^T \; mod \; q

And thus:

hA(e)=Rot(a1)e1+...+Rot(al)elmodqh_A(e) = Rot(a_1) e_1 + ... + Rot(a_l) e_l \; mod \; q

But wait! We haven’t moved to R~\tilde R fully, we have matrix-vector multiplication, this is not in R~\tilde R. We should have something like:

hA(e)=Rot(a1)Rot(e1)+...+Rot(al)Rot(el)modqh_A(e) = Rot(a_1) Rot(e_1) + ... + Rot(a_l) Rot(e_l) \; mod \; q

Which would mean:

hA(e)=a1e1+...+alelmodqRh_A(e) = a_1 e_1 + ... + a_l e_l \; mod \; qR

However, this is ok since:

Rot(a)Rot(e)=Rot(Rot(a)e)Rot(a) Rot(e) = Rot(Rot(a) e)

Why is this so? Let’s have two vectors x=(x1,...,xn)x = (x_1, ..., x_n). It’s enough to show:

XRot(x)e=Rot(x)XeX Rot(x) e = Rot(x) X e

This is clear from below:

XRot(x)e=X(x1In+x2X...+xnXn1)eX Rot(x) e = X (x_1 I_n + x_2 X ... + x_n X^{n-1}) e

Rot(x)Xe=(x1In+x2X...+xnXn1)XeRot(x) X e = (x_1 I_n + x_2 X ... + x_n X^{n-1}) X e

I haven’t read the paper, but MIT lecture (opens new window) says Miccancio showed in 2007 that such hash function is a secure one-way function (difficult to invert).

However, it is not a collision-resistant hash function. Before having a look what’s the reason let’s see the definition of Ring-SIS problem.

Definition: For a ring RR, integer modulus Q2Q \geq 2, and integer l1l \geq 1, the (average-case) Ring-SIS problem is defined as follows. The input is a1,...,alR[q]a_1,...,a_l \in R_{[q]} sampled independently and uniformly at random. The goal is to output e1,...,elR{1,0,1}e_1, ..., e_l \in R_{\{-1, 0, 1\}} not all zero such that a1e1+...+alel=0modqRa_1 e_1 + ... + a_l e_l = 0 \; mod \; qR.

However, Ring-SIS over Z[x]/(xn1)\mathbb{Z}[x]/(x^n-1) is not hard.

It holds:

xn1=(x1)(xn1+...+x+1)x^n - 1 = (x - 1) (x^{n-1} + ... + x + 1)

Let’s denote e~=xn1+...+x+1\tilde{e} = x^{n-1} + ... + x + 1.

We can see that (e~,0,...,0)(\tilde{e}, 0, ..., 0) is a solution to Ring-SIS problem whenever a1a_1 is divisible by x1x-1. The probability that a1a_1 is divisible by x1x-1 is 1q\frac{1}{q} (whenever a1(1)=0modqa_1(1) = 0 \; mod \; q).