(To get a better experience with math symbols and view, you can read at: https://hackmd.io/@Giapppp/BJ4wfpZST)
Students:
- Vũ Tiến Giáp - 22520367
- Nguyễn Viết Duy - 22520336
Lecturer: Nguyễn Ngọc Tự
In the ever-evolving landscape of technology, the government agency recognizes the imperative to fortify its communication infrastructure against the looming threat of quantum advancements. As quantum computers inch closer to reality, the conventional cryptographic protocols currently safeguarding sensitive governmental information become susceptible to rapid decryption. In response to this imminent challenge, the agency contemplates the adoption of lattice-based cryptographic algorithms for post-quantum secure communications.
Lattice-based cryptography offers a unique and promising solution tailored to the agency's security needs. The inherent resilience of lattice-based algorithms to quantum attacks aligns seamlessly with the agency's mandate to ensure the confidentiality and integrity of classified information, even in the face of quantum computational capabilities. In this project, we will talk about lattice - introduction, lattice reduction algorithms and lattice problems. We will also discuss about Learning With Error (LWE) problems and cryptosystems using it
A lattice [1] is a set of points in
The vectors
The most well known computational problems on lattices are the following:
-
Shortest Vector Problem (SVP): Given a lattice basis
$\bf{B}$ , find the shortest nonzero vector in$\mathcal{L}(\bf{B})$
-
Closest Vector Problem (CVP): Given a lattice basis
$\bf{B}$ and a target vector$\bf{t}$ (not necessarily in the lattice), find the lattice point$\bf{v} \in \mathcal{L}(\bf{B})$ closest to$\bf{t}$
-
Shortest Independent Vectors Problem (SIVP): Given a lattice basis
$\bf{B} \in \mathbb{R}^{n \times n}$ , find$n$ linearity independent lattice vectors$\bf{S} = [s_1, s_2,...,s_n]$ (where$s_i \in \mathcal{L}(\bf{B})$ for all$i$ ) so that$max||v_i|| \le max||b_i||$ , where$||x|| = \sqrt{x_1^2 + x_2^2 +...+ x_n^2}$
We will give an introduction of LWE:
Definition: Let
We have two computational problems in LWE:
Decision LWE: The problem of deciding whether pairs $(\bf{a}, c) \in \mathbb{Z}_q^n \times \mathbb{Z}q$ are sampled according to $L{s, \mathcal{X}}$ or the uniform distribution on
Search LWE: The problem of recovering
In this project, we will implicitly assume that
The hardness of LWE problems are the same as SVP and CVP
We will focus on the LWE-based public key cryptosystem:
Parameter: We let
- Prime
$q > 2 \in (n^2, 2n^2)$ -
$m = (1 + \varepsilon)(n + 1) \log q$ for some arbitrary constant$\varepsilon > 0$ - The probability distribution
$\mathcal{X}$ is taken to be$\Psi_{\alpha(n)}$ for$\alpha(n) = o(1/\sqrt{n}\log n)$ , i.e.,$\alpha(n)$ is such that$\lim\limits_{n \to \infty} \alpha(n) * \sqrt{n}\log n = 0$ . For example, we can choose$\alpha(n) = 1/(\sqrt{n}\log n)$
Private Key: Choose
Public Key: For
Encryption: In order to encrypt a bit we choose a random set
Decryption: The decryption of a pair
-
C/C++, Python 3.x
-
Number Theory Library (NTL): NTL is a C++ library for doing number theory. NTL supports arbitrary length integer and arbitrary precision floating point arithmetic, finite fields, vectors, matrices, polynomials, lattice basis reduction and basic linear algebra. NTL is free software released under the GNU Lesser General Public License v2.1.
-
Sagemath: SageMath is a computer algebra system with features covering many aspects of mathematics, including algebra, combinatorics, graph theory, group theory, differentiable manifolds, numerical analysis, number theory, calculus and statistics. Stein realized when designing Sage that there were many open-source mathematics software packages already written in different languages, namely C, C++, Common Lisp, Fortran and Python.
-
Numpy: NumPy is a library for the Python programming language, adding support for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays.
We will focus on LWE cryptosystem [2]. When the parameters didn't verify condition at Key Generation and Collection part, this cryptosystem is vulnerable.
This is an attack due to Arora and Ge [3]. The basic idea is to view a LWE sample
where
When
-
We get a reasonable chance that all equations have error bounded by
$k.s$ if$m.e^{-O(k^2)} \ll 1$ . -
On the other hand, we need
$m > {n \choose k.s}$ for linearization to work.
This is an attack originally due to Blum, Kalai and Wasserman[4]. A similar version was later discovered by Wagner[5].
The basic idea is to find small-weight linear combinations $\textbf{x}{i, j}$ of the columns of $\textbf{A}$ that sums up to the fixed vector, say the unit vectors $\textbf{u}i$, that is $\textbf{Ax}{i, j} = \textbf{u}i \mod q$. Once we find such vectors, we compute $$\textbf{b}^T \textbf{x}{i, j} = (\textbf{s}^T \textbf{A} + \textbf{e}^T)\textbf{x}{i, j} = s_i + \textbf{e}^T\textbf{x}_{i, j} \mod q$$
which, give many copies and averaging, gives us
The BKW algorithm – when applied to Search-LWE – can be viewed as consisting of three stages somewhat analogous to those of linear system solving:
- Sample reduction is a form of Gaussian elimination which, instead of treating each component independently, considers ‘blocks’ of
$b$ components per iteration, where$b$ is a parameter of the algorithm. - Hypothesis testing tests candidate sub-solutions to recover components of the secret vector
$s$ . - Back substitution such that the whole process can be continued on a smaller LWE instance.
This is an attack that follows using the LLL algorithm[6] and (building on LLL) the BKZ algorithm[7] that find approximately short vectors in integer lattices.
The attack use the fact that LWE is, at its core, a problem of finding short vectors in integer lattices. Taking
Now, the vector
The primal attack[8] is a kind of classical and useful attack model for the search-LWE problem and it only requires polynomial LWE samples. The core idea is that transforming the search-LWE instance into a unique-SVP and solving the unique shortest vector by lattice reduction with appropriate root-Hermite factor
Given an LWE instance
(1). The Kannan's embedding[9] reduces the BDD problem to SVP. The corresponding embedding lattice is $$\mathcal{L}_K = \Bigg{\textbf{y} \in \mathbb{Z}^{m + 1}: \textbf{y = Ax} \mod q, \forall \textbf{x} \in \mathbb{Z}^{n+1}, \textbf{A} = \begin{bmatrix} \textbf{A} & \textbf{b} \ \textbf{0} & \mu \end{bmatrix} \in \mathbb{Z}^{(m+1) \times (n+1)} \Bigg}$$
and in practice it is preferable to use
(2). The dual embedding proposed by Bai and Galbraith [10] constructs a lattice related to both secret
The vector
(3). The Bai-Galbraith embedding improves dual embedding for such LWE instance that secret and error are chosen from different distributions, its core idea is to balance the size of the error and the secret. Specially, the short vector in lattice $\mathcal{L}D$ can be re-balanced as $\textbf{v} = (\textbf{e} \ | \ \omega \textbf{s} \ | \ \omega)$ with scaling factor $\omega = {\sigma_e \over \sigma_s}$ and the new embedding lattice is: $$\mathcal{L}\omega={\textbf{x} \in \mathbb{Z}^{m+n+1}: (\textbf{I}_m|{1 \over \omega}\textbf{A}| - {1 \over \omega}\textbf{b})\textbf{x = 0} \mod q},$$
Algorithm | (Some) Broken Parameter setting |
---|---|
Arora-Ge |
|
Blum-Kalai-Wasserman |
|
Lattice Reduction |
|
Primal Attack |
|
Tool and resources | Description |
---|---|
lwe-estimator | Estimating the concrete security of Learning with Errors instances |
Python 3.x | Use to solve some CTF challenges related to LWE, using some techniques below |
BKW-Algorithm | An implementation of the Blum-Kalai-Wasserman algorithm for solving the Learning with Errors problem. |
All scripts can be found at this
Lattice-based cryptography is regarded as the rival to a quantum computer attack and the future of post-quantum cryptography. So, cryptographic protocols based on lattices have a variety of benefits, such as security, efficiency, lower energy consumption, and speed
We will see that if the parameters are chosen carefully, there won't be any strategy can attack on LWE, so it is widely used in cryptography to create secure encryption algorithms.
Some selected schemes for the purpose of key exchange, based on LWE problem:
- CRYSTALS-Kyber, [12] which is built upon module learning with errors (module-LWE). Kyber was selected for standardization by the NIST in 2023. [13] In August 2023, NIST published FIPS 203 (Initial Public Draft), and started calling their Kyber version as Module-Lattice-based Key Encapsulation Mechanism (ML-KEM)
- FrodoKEM, [14] a scheme based on the learning with errors (LWE) problem. FrodoKEM joined the standardization call conducted by the National Institute of Standards and Technology (NIST), [11] and lived up to the 3rd round of the process. It was then discarded due to low performance reasons.
- NewHope [15] is based on the ring learning with errors (RLWE) problem.
[1]. Wikipedia
[2]. https://people.csail.mit.edu/vinodv/CS294/lecture2.pdf
[3]. S. Arora and R. Ge. New algorithms for learning in presence of errors. In L. Aceto, M. Henzinger, and J. Sgall, editors, ICALP, volume 6755 of Lecture Notes in Computer Science, pages 403–415. Springer Verlag, 2011.
[4]. Avrim Blum, Adam Kalai, and Hal Wasserman. Noise-tolerant learning, the parity problem, and the statistical query model. J. ACM, 50(4):506–519, 2003.
[5]. Wagner, D. (2002). A Generalized Birthday Problem. In: Yung, M. (eds) Advances in Cryptology — CRYPTO 2002. CRYPTO 2002. Lecture Notes in Computer Science, vol 2442. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-45708-9_19
[6]. Lenstra, A. K.; Lenstra, H. W. Jr.; Lovász, L. (1982). "Factoring polynomials with rational coefficients". Mathematische Annalen. 261 (4): 515–534. CiteSeerX 10.1.1.310.318.
[7]. C.P. Schnorr, A hierarchy of polynomial time lattice basis reduction algorithms, Theoretical Computer Science,Volume 53, Issues 2–3,1987, Pages 201-224,ISSN 0304-3975, https://doi.org/10.1016/0304-3975(87)90064-8.
[8]. Xue Zhang; Zhongxiang Zheng; Xiaoyun Wang; (2021). A detailed analysis of primal attack and its variants . Science China Information Sciences, (), –. doi:10.1007/s11432-020-2958-9
[9]. Kannan R. Minkowski’s convex body theorem and integer programming. Math Oper Res, 1987, 12: 415–440
[10]. Bai S, Galbraith S D. Lattice decoding attacks on binary LWE. In: Proceedings of Australasian Conference on Information Security and Privacy, 2014. 322–337
[11]. MATZOV. (2022). Report on the Security of LWE: Improved Dual Lattice Attack. Zenodo. https://doi.org/10.5281/zenodo.6493704
[12]. Albrecht, M.R. On Dual Lattice Attacks Against Small-Secret LWE and Parameter Choices in HElib and SEAL. In Advances inCryptology—EUROCRYPT 2017; Springer International Publishing: Berlin/Heidelberg, Germany, 2017; pp. 103–129
[13]. https://pq-crystals.org/
[14]. https://csrc.nist.gov/Projects/post-quantum-cryptography/selected-algorithms-2022
[15]. https://newhopecrypto.org/index.shtml
[16]. https://csrc.nist.gov/events/2019/second-pqc-standardization-conference
[17]. https://frodokem.org/
[18]. Martin R. Albrecht, Rachel Player and Sam Scott. On the concrete hardness of Learning with Errors. Journal of Mathematical Cryptology. Volume 9, Issue 3, Pages 169–203, ISSN (Online) 1862-2984, ISSN (Print) 1862-2976 DOI: 10.1515/jmc-2015-0016, October 2015
[19]. https://www.maths.ox.ac.uk/system/files/attachments/lattice-reduction-and-attacks.pdf