Practical Homomorphic Encryption and Cryptanalysis
Total Page:16
File Type:pdf, Size:1020Kb
Practical Homomorphic Encryption and Cryptanalysis Dissertation zur Erlangung des Doktorgrades der Naturwissenschaften (Dr. rer. nat.) an der Fakult¨atf¨urMathematik der Ruhr-Universit¨atBochum vorgelegt von Dipl. Ing. Matthias Minihold unter der Betreuung von Prof. Dr. Alexander May Bochum April 2019 First reviewer: Prof. Dr. Alexander May Second reviewer: Prof. Dr. Gregor Leander Date of oral examination (Defense): 3rd May 2019 Author's declaration The work presented in this thesis is the result of original research carried out by the candidate, partly in collaboration with others, whilst enrolled in and carried out in accordance with the requirements of the Department of Mathematics at Ruhr-University Bochum as a candidate for the degree of doctor rerum naturalium (Dr. rer. nat.). Except where indicated by reference in the text, the work is the candidates own work and has not been submitted for any other degree or award in any other university or educational establishment. Views expressed in this dissertation are those of the author. Place, Date Signature Chapter 1 Abstract My thesis on Practical Homomorphic Encryption and Cryptanalysis, is dedicated to efficient homomor- phic constructions, underlying primitives, and their practical security vetted by cryptanalytic methods. The wide-spread RSA cryptosystem serves as an early (partially) homomorphic example of a public- key encryption scheme, whose security reduction leads to problems believed to be have lower solution- complexity on average than nowadays fully homomorphic encryption schemes are based on. The reader goes on a journey towards designing a practical fully homomorphic encryption scheme, and one exemplary application of growing importance: privacy-preserving use of machine learning. 1.1 Cryptography Part: Synopsis Fully homomorphic encryption empowers users to delegate arbitrary computations in a private-preserving way on their encrypted data. Surprisingly, in many scenarios the executing party does not actually need to see the private content in order to return a useful result. This part focuses on efficient ways transforming ubiquitously present machine learning models into privacy-friendly algorithmic cognitive models, achieving strong security notions by returning encrypted results later to be decrypted by the user with the secret key only. New algorithmic constructions, laying the foundation to CPU/GPU implementations, and the pre- sented adaptive parameterization are solutions to sensitive real-world applications like evaluating deep neural networks on private inputs. We propose a practical FHE scheme, FHE{DiNN, tailored to homomorphic inference, exhibiting performance that is independent of the number of a given neural network's layers, and give conclusive, experimental results of our implementation. Portions of the work presented in this part were previously published at CRYPTO 2018 [BMMP18]. 1.2 Cryptanalysis Part: Synopsis This part advances algorithms for variants of subset problems. Generalization of the subset-sum problem to sparse, multidimensional cases, and their reductions to the one-dimensional case are given. Impli- cations to the Learning with Errors (LWE) relate the security of practical cryptographic schemes, as studied in the previous part, with classical and quantum theoretic complexity considerations. We introduce the property of equiprobability, when probabilistic solvers return every subset solution with roughly the same probability, and identify which well-known algorithms need be modified to have it. Portions of the work presented in this part were previously published at AQIS18 [BMR18]. 3 Contents 1 Abstract 3 1.1 Cryptography Part: Synopsis.................................3 1.2 Cryptanalysis Part: Synopsis.................................3 I Cryptology and Homomorphic Encryption 13 2 Introduction 15 2.1 Scope of this Thesis and Problem Statement......................... 16 2.1.1 Community Value of provided Solutions....................... 16 2.2 Implementation: From Formulas to working Code...................... 16 2.2.1 The Advantage of Open-Source Software....................... 16 3 Cryptography and Cryptology 17 3.1 Suitable Problems and Algorithms.............................. 18 3.1.1 Definition of the Learning with Errors problem................... 18 3.2 Complexity Theory....................................... 20 3.3 Boolean Gates, Circuits and Functional Completeness................... 22 4 Cryptology 23 4.1 Threat Model.......................................... 23 4.2 Security Definitions....................................... 23 4.3 Sources of Entropy....................................... 26 4.4 NIST's Post-Quantum Cryptography Standardization................... 26 5 Quantum Computing 27 5.1 Quantum Bits.......................................... 27 5.2 Quantum Computer and Quantum Algorithms....................... 28 5.2.1 Grover's Algorithm................................... 28 5.2.2 Shor's Algorithm.................................... 28 5.2.3 Provable Security and the One-Time Pad...................... 29 6 Homomorphic encryption (HE) 31 6.1 Definitions and Examples of Homomorphic encryption (HE)................ 31 6.1.1 The RSA Cryptosystem and the Factorization Problem.............. 31 6.1.2 Paillier Cryptosystem................................. 32 5 II Fully Homomorphic Encryption (FHE) & Artificial Intelligence (AI) 33 7 Cloud Computing 35 7.1 Cloud Computing: Promises, NSA, Chances, Markets................... 35 7.2 Hardware Solution: Secure Computing Enclaves....................... 37 7.3 Software Solution: FHE and FHE{DiNN .......................... 37 7.3.1 Limitations....................................... 37 8 Mathematical Foundations of FHE 39 8.1 Basic Concepts from Algebra and Probability Theory................... 39 8.2 Lattice Problems for Cryptography.............................. 41 8.2.1 Discrete Gaussian distribution on Lattices...................... 41 8.3 Learning With Errors (LWE)................................. 43 8.3.1 Equivalence between the decisional- (dLWE) and search-LWE (sLWE)...... 44 8.4 Homomorphic Encryption................................... 44 8.4.1 Standardization of Homomorphic Encryption.................... 47 8.5 An Efficient FHE-scheme for Artificial Intelligence (AI).................. 47 9 FHE{DiNN 49 9.1 Localization of this Research within the Field........................ 50 9.1.1 Prior Works and Known Concepts.......................... 50 9.2 Preliminaries.......................................... 51 9.2.1 Notation and Notions................................. 51 9.2.2 Fully Homomorphic Encryption over the Torus (TFHE).............. 51 9.2.3 TGSW: Gadget Matrix and Decomposition..................... 53 9.2.4 Homomorphic Ciphertext Addition and Multiplication............... 54 9.3 Artificial Intelligence, Machine learning, Deep Learning.................. 56 9.3.1 Task: Homomorphic Evaluation of Neural Networks................ 56 9.3.2 The MNIST Handwritten Digit Database...................... 57 9.3.3 Cost Functions Measuring Neural Networks' Performance............. 59 9.3.4 Hyperparameters of a Model............................. 60 9.3.5 Training: The Learning Phase of a Model...................... 60 9.4 FHE{DiNN: Framework for Homomorphic Evaluation of Deep Neural Networks.... 61 9.4.1 Beyond the MNIST dataset: Medical Applications of Image Recognition..... 61 9.4.2 Training Neural Networks: Back-Propagation and Stochastic Gradient Descent. 62 9.5 Discretized Neural Networks: Training and Evaluation................... 62 9.5.1 Discretizing and Evaluation of NNs.......................... 63 9.5.2 Training a DiNN.................................... 64 9.6 Homomorphic Evaluation of a DiNN............................. 65 9.6.1 Evaluating the linear Component: The Multisum.................. 65 9.6.2 Homomorphic Computation of the non-linear sign-Function............ 66 9.6.3 Scale-invariance..................................... 66 9.7 Optimizations within FHE{DiNN over TFHE....................... 67 9.7.1 Reducing Bandwidth: Packing Ciphertexts and FFT................ 67 9.7.2 Early KeySwitch Allows Faster Bootstrapping.................... 69 9.7.3 Programming the Wheel................................ 70 9.7.4 Adaptively Changing the Message Space....................... 72 9.7.5 Reducing Communication Bandwidth: Hybrid Encryption............. 72 9.7.6 Alternative BlindRotate Implementation: Trading-Off Run-Time with Space... 75 9.7.7 Support for various Layers of Unlimited Depth................... 77 9.7.8 Neural Networks for Image Classification...................... 78 9.7.9 Interactive Homomorphic Computation of the argmax Function.......... 79 9.7.10 Beyond Artificial Neural Networks: CapsNets.................... 80 9.8 Practical attack vectors against FHE{DiNN using fplll ................. 80 9.8.1 Security Reductions: TLWE to appSVPγ ...................... 80 9.8.2 Theoretical attack vectors against FHE{DiNN .................. 81 9.8.3 Security Evaluation and Parameter Choices..................... 82 9.8.4 General Attacks on Variants of LWE......................... 83 9.9 Experimental Results...................................... 84 9.10 Comparison with Cryptonets................................. 88 9.10.1 Performance of FHE{DiNN on (clear) inputs x .................. 89 9.10.2 Performance of FHE{DiNN on (encrypted) inputs Enc (x)........... 89 10 FHE & AI on GPUs (cuFHE{DiNN) 91 10.1 Practical FHE evaluation of neural networks using CUDA................. 91 III Cryptanalysis