On Dual Lattice Attacks Against Small-Secret LWE and Parameter Choices in Helib and SEAL
Total Page:16
File Type:pdf, Size:1020Kb
On dual lattice attacks against small-secret LWE and parameter choices in HElib and SEAL Martin R. Albrecht Information Security Group, Royal Holloway, University of London Learning with Errors The Learning with Errors (LWE) problem was defined by Oded Regev.1 2 Zm×n 2 Zn 2 Zm Given (A;(c) with) uniform A q , uniform s q and small e U Zm is c $ q or 0 1 0 1 0 1 n ! B C B C B C B C B C B C B C B C 0 1 B C B C B C B C B C B C B C B C B C B C B C B c C = B A C · @ s A + B e C : B C B C B C B C B C B C B C B C B C @ A @ A @ A 1Oded Regev. On lattices, learning with errors, random linear codes, and cryptography. In: 37th ACM STOC. ed. by Harold N. Gabow and Ronald Fagin. ACM Press, May 2005, pp. 84–93. FHE-schemes based on LWE BGV Zvika Brakerski, Craig Gentry, and Vinod Vaikuntanathan. (Leveled) fully homomorphic encryption without bootstrapping. In: ITCS 2012. Ed. by Shafi Goldwasser. ACM, Jan. 2012, pp. 309–325, implemented HELib FV Junfeng Fan and Frederik Vercauteren. Somewhat Practical Fully Homomorphic Encryption. Cryptology ePrint Archive, Report 2012/144. http://eprint.iacr.org/2012/144. 2012, implemented in SEAL v2 Small Secrets • HElib typically chooses s such that w = 64 entries are 1 and all remaining entries are 0, regardless of dimension n. {− g • SEAL chooses si $ 1; 0; 1 . How many bits of security does this cost? Hardness: Reductions v Constructions “A major part of our reduction […] is therefore dedicated to showing reduction from LWE (in dimension n) with arbitrary Zn secret in q to LWE (in dimension n log2 q) with a secret chosen uniformly over f0; 1g.”2 “This brings up the question of whether one can get better attacks against LWE instances with a very sparse secret (much smaller than even the noise). […] it seems that the very sparse secret should only add maybe one bit to the modulus/noise ratio.”3 2Zvika Brakerski et al. Classical hardness of learning with errors. In: 45th ACM STOC. ed. by Dan Boneh, Tim Roughgarden, and Joan Feigenbaum. ACM Press, June 2013, pp. 575–584. 3Craig Gentry, Shai Halevi, and Nigel P. Smart. Homomorphic Evaluation of the AES Circuit. Cryptology ePrint Archive, Report 2012/099. http://eprint.iacr.org/2012/099. 2012. Lattice Attacks Primal Attack solve Bounded Distance Decoding problem (BDD), i.e. 0 0 find s s.t. kw − ckis minimised, with w = A · s using • uSVP embedding or • Babai’s nearest planes resp. enumeration. Dual Attack solve Short Integer Solutions problem (SIS) in the left kernel of A, i.e. find a short w such that w · A = 0 and check if hw; ci = w · (A · s + e) = hw; ei is short. Dual Attack A reduced lattice basis contains short vectors. In particular, the first k k ≈ m · n=m vector is short: v δ0 q . 1. Construct a basis of the dual lattice from A. 2. Run lattice reduction algorithm to obtain short vectors vi. h i 4 3. Check if vi; c are small. 4Daniele Micciancio and Oded Regev. Lattice-based Cryptography. In: Post-Quantum Cryptography. Ed. by Daniel J. Bernstein, Johannes Buchmann, and Erik Dahmen. Berlin, Heidelberg, New York: Springer, Heidelberg, 2009, pp. 147–191. 1. Amortising Costs Dual Attack: Trade-off Given an LWE instance characterised by n, α, q and a vector v of length kvk such that v · A ≡ 0 (mod q), the advantage " of distinguishing hv; ci from random is close to5 exp(−π(kvk · α)2). 400 ) 350 BKZ cost ( 2 300 log 250 0 10 20 30 40 50 60 " = 1=2i 5Richard Lindner and Chris Peikert. Better Key Sizes (and Attacks) for LWE-Based Encryption. In: CT-RSA 2011. Ed. by Aggelos Kiayias. Vol. 6558. LNCS. Springer, Heidelberg, Feb. 2011, pp. 319–339. Amplifying Advantage To achieve constant advantage, repeat experiment ≈ 1="2 times for majority vote. ) 400 BKZ cost · i 2 2 350 ( 2 log 0 10 20 30 40 50 60 " = 1=2i Just do it™ Amortising Costs Avoiding 1="2 calls to BKZ in block size β. 1. L basis for fy 2 Zm : y · A ≡ 0 mod qg 2. R BKZ-β reduced basis for L 3. Repeat: 3.1 U $ a sparse unimodular matrix with small entries 0 · 3.2 Ri BKZ-β reduced basis for U R 3.3 yi shortest row vector in Ri h i 3.4 wi yi; c 4. Decide if wi is uniform or not. We give empirical evidence that the quality of Ri isn’t “too bad”: for 0 · m · n=m β = 2, they are < 2 δ0 q with δ0 for BKZ-β. 2. Scaling Scaling for Dual Attack • We do not need to find v · A ≡ 0 mod q, but any short v such that v · A = w is short suffices. • Consider the normal form of the dual attack on LWE Λ(A) = f(x; y) 2 Zm × Zn : x · A ≡ y mod qg • Given a short vector (v; w) 2 Λ(A) compute hv; ci = v · (A · s + e) = hw; si + hv; ei Scaling for Dual Attack • Aim is to balance k hw; si k ≈ k hv; ei k when ksk is small. • Scale the lattice6 Λ(A) = f(x; y=c) 2 Zm × (1=c · Z)n : x · A ≡ y mod qg for some constant c. • Lattice reduction produces a vector (v; w) with k k ≈ (m+n) · n=(m+n) (v; w) δ0 (q=c) : • The final error we aim to distinguish from uniform is v · A · s + hv; ei = hc · w; si + hv; ei : 6Shi Bai and Steven D. Galbraith. Lattice Decoding Attacks on Binary LWE. In: ACISP 14. Ed. by Willy Susilo and Yi Mu. Vol. 8544. LNCS. Springer, Heidelberg, July 2014, pp. 322–337. doi: 10.1007/978-3-319-08344-5_21. Scaling for Dual Attack From v · A · s + hv; ei = hc · w; si + hv; ei : we find c by solving α q p c = p · m − n 2 π h which equalises the noise contributions of both parts of the sum. 3. Sparse Secrets Ignoring Components • When the secret is sparse, most columns of A are irrelevant. • The probability of getting lucky (si = 0) when ignoring k random 6 components in dimension n with in total h entries si = 0 follows a hypergeometric distribution ( ) ( ) kY−1 n−h h P = 1 − = (k ) k n − i n i=0 k ≈ • Solving (with high enough probability) 1=Pk instances in dimension n − k solves our instance at dimension n. Ignoring Components in Dual Attack 0 v 1 0 A 1 0 s 1 v a ; ··· a − a ··· a ; − B 0 C B 0 0 0;k 1 0;k 0 n 1 C s0 B v C B a ··· a − a ··· a − C B C B 1 C B 1;0 1;k 1 1;k 1;n 1 C B . C B C B ··· ··· C B . C B v2 C B a2;0 a2;k−1 a2;k a2;n−1 C B C ? B C B C B C ≈ B . C · B . C · Bsk−1C 0 B . C B . .. .. C B C B C B C B sk C B C B ··· ··· C B C Bvm−3C B am−3;0 am−3;k−1 am−3;k am−3;n−1 C B . C @ A @ ··· ··· A @ . A vm−2 am−2;0 am−2;k−1 am−2;k am−2;n−1 . ··· ··· − vm−1 am−1;0 am−1;k−1 am−1;k am−1;n−1 sn 1 0 1 s0 B C B . C B . C B . C ( ) B C ? 0 ··· 0 ··· Bsk−1C ≈ a a − 0 0 · B C 0;0 0;k 1 B s C B k C B C . @ . A sn−1 Ignoring Components in Dual Attack 0 v 1 0 A 1 0 s 1 v a ; ··· a − a ··· a ; − B 0 C B 0 0 0;k 1 0;k 0 n 1 C 0 B v C B a ··· a − a ··· a − C B C B 1 C B 1;0 1;k 1 1;k 1;n 1 C B . C B C B ··· ··· C B . C B v2 C B a2;0 a2;k−1 a2;k a2;n−1 C B C B C B C B C ≈ B . C · B . C · B 0 C 0 B . C B . .. .. C B C B C B C B sk C B C B ··· ··· C B C Bvm−3C B am−3;0 am−3;k−1 am−3;k am−3;n−1 C B . C @ A @ ··· ··· A @ . A vm−2 am−2;0 am−2;k−1 am−2;k am−2;n−1 . ··· ··· − vm−1 am−1;0 am−1;k−1 am−1;k am−1;n−1 sn 1 0 1 0 B C B . C B . C B . C ( ) B C 0 ··· 0 ··· B 0 C = a a − 0 0 · B C 0;0 0;k 1 B s C B k C B C . @ . A sn−1 h · i h i c wk:; sk: + v; e Postprocessing 0 v 1 0 A 1 0 s 1 v a ; ··· a − a ··· a ; − B 0 C B 0 0 0;k 1 0;k 0 n 1 C 1 B v C B a ··· a − a ··· a − C B C B 1 C B 1;0 1;k 1 1;k 1;n 1 C B .