(Draft) Lattice-based crypto - introduction

Page content

During the Corona situation, I decided to learn something new, and it was lattice-based cryptography.

Intro to LWE from knapsack problem

From this slide

1D (modular) knapsack problem

Given a1,a2,,an and t, q, where all variables are integers. Find {xi}i=1n{0,1}n s.t. ,

t=i=1nx1aimodq.

Vector modular knapsack problem

Given aa1,aa2,,aan and tt, q, where aa,ttZm×1 and qZ. Find xx={xi}i=1n{0,1}m×1 s.t. ,

tt=i=1nxiaaimodq.

We can extend the value of xi from {0,1} to xiZ where xiq. This extension is 01 kanpsack problem -> BKP (Bounded Knapsack Problem) -> UKP (Unbounded Knapsack Problem)

Vector modular knapsack problem in Matrix format

The equation can be expressed in Matrix form. Let aij be “i-th element of the vector $\pmb{a}j.Hencet_j = \displaystyle\sum{i=1}^{n} a_{ji}x_i\bmod q,ifwedefineamatrix\pmb{A} = (\pmb{a}_1, \pmb{a}_2,\cdots,\pmb{a}_n)$, the vector knapsack problem can be expressed as follows:

Given AAZm×n, ttZm×1, and qZ. Find xxZn×1, s.t.,

AAxx=ttmodq.

How hard to solve the vector knapsack problem

  • If n=m, the problems can be solved easily by Gaussian elimination (O(n3)).
  • If nm, the unbounded knapsack problem (integer knapsack problem) is NP-complete.
  • Some are solavble in polynomial times. There is an algorithm (LLL lattice basis reduction) to get an approximate answer (or an exact answer sometimes) of this problem in polinomial time (O(n5mlog3a) where A is the longest length of aai under the Euclidean norm), under som conditions (refer to Wikipedia).
  • So, in case of nm, the time complecitiy is NP.

Example of LLL:

From knapsack to LWE

We can lead LWE from vector knapsack problem.Here is the step by step instructions. (I omitted all modq.)

This is a visualized vector knapsack problem:

alt text
Vector knapsack problem.

Split the Matrix AA as follows:

alt text
Split the matrix.

It can be written AA=[AA BB].

Multiply BB1 from left:

alt text
Multibly B^(-1).

Redefine BB1AA as AA, and BB1tt as tt:

alt text
Redefine name.

Split the vector xx into xx= t[ss ee]:

alt text
Split the vector x.

Split the multiplication:

alt text
Split the multiplication.

And finally, redfine nm as n:

alt text
LWE.

This is the LWE (Learning With Errors).

Notes

The complexity of finding the inverse BB1 is P (Gaussian elimination), but the complexity of “finding ss and ee” is NP, because the complexity of a vector knapsack problem is NP.

LWE problem

The first definition of LWE appears in the famous paper from Regev.

You can find a free version from https://cims.nyu.edu/~regev/papers/qcrypto.pdf.

First, Regev introduced “learning from parity with error problem” as follows:

Let ssZ2n, aaiZ2n, and 0ε1.

Find ss from given pairs (aai,bi), s.t.,

ssaa1εb1(mod2) ssaa2εb2(mod2)      
where ε means “the result is wrong (error) with probability ε”.

This problem is one of the simplest 0-1 modular knapsack problem, if there is no error (ε=0).

From this problem we can extend:

  • mod2 to modp, where p is a prime integer, and ppoly(n).
  • ε to an error distribution function Ψ.

This extended problem is called LWEp,Ψ problem.

Application to public key encryption

At the end of the paper from Regev, they propose how to apply this LWE problem into public key encryption.


Examples

https://www.esat.kuleuven.be/cosic/blog/introduction-to-lattice-based-cryptography-part-2-lwe-encryption/ <- contains some errors.

entities

  • Plain text: mZ
  • Prime number q
  • Dimention n
  • AAU(Zqn×n)
  • ssZqn×1
  • eeZqn×1
  • ssZqn×1
  • eeZqn×1
  • eZq

The ss is a secret key.

How to create public key:

(AA,bb=AAss+eemodq)

How to encrypt m:

bb=AAtss+eemodq v=bbtss+e+q2mmodq
I don’t innerproducts.

How to decrypt v:

Δv:=vbbtssmodq
It is
Δv=(bbtss+e+q2m)(sstAAss+eetss)modq =(sstAAss+eetss+e+q2m)(sstAAss+eetss)modq

real value example

  • Prime number: 17
  • Dimention: 3
  • AA=(31112 1627 901)
  • sst=(110)
  • eet=(010)

https://www.slideserve.com/felcia/lattice-based-cryptography <- actual values.


LWE definition (Wiki) -> decisional LWE -> RLWE (polynomial) -> NTRU


From Regev’s paper

O~: soft-O notation,

f(n)O~(g(n))k:f(n)O(g(n)logkg(n))