Efficient Evaluation of Activation Functions Over Encrypted Data

Efficient Evaluation of Activation Functions Over Encrypted Data

Efficient Evaluation of Activation Functions over Encrypted Data Patricia Thaine Sergey Gorbunov Gerald Penn Department of Computer Science Cheriton School of Computer Science Department of Computer Science University of Toronto University of Waterloo University of Toronto Toronto, Canada Waterloo, Canada Toronto, Canada [email protected],edu [email protected] [email protected] Abstract—We describe a method for approximating any machine learning models relying on the sigmoid function for bounded activation function given encrypted input data. The predicting probabilities would fail. utility of our method is exemplified by simulating it within two Finally, a special purpose activation function that has been typical machine learning tasks: namely, a Variational Autoen- 2 coder that learns a latent representation of MNIST data, and an proposed in f(x) = x , which is not guaranteed to converge. MNIST image classifier. Homomorphic encryption has also featured in machine Index Terms—machine learning, homomorphic encryption, learning protocols for fully homomorphic random forests, fully privacy, security, activation function, non-polynomial function homomorphic na¨ıve Bayes, and fully homomorphic logistic regression [5]. Secure random forests have been used to create I. INTRODUCTION language models [33]. [19] design low-degree polynomial algorithms that classify encrypted data. There has also been Efficiently calculating non-linear activation functions is work on applying differential privacy [13] to neural networks essential for deep learning algorithms. These are the com- in order to preserve input privacy [1], [26], [27], and on using binations and distortions of a neural unit’s inputs, using GANs to train neural networks so that sensitive information functions such as hyperbolic tangents and sigmoids, that give cannot be inferred from the model’s weights [11]. neural networks their real applicability. Various techniques Contributions. (1) We show how to represent the value have previously claimed to compute these functions securely of any function over a defined and bounded interval, given over encrypted data, but use either Secure Two-Party Compu- encrypted input data, without needing to decrypt any inter- tation (2PC) [23], [28], distantly approximated functions [21], mediate values before obtaining the function’s output. The or special-purpose activation functions [18] as approaches. encrypted representation itself is accurate to within any spec- Unfortunately, the proposed approaches are not realistic in ified precision tolerance. Functions to which this method many real-world use cases. is applicable include sigmoid functions, Rectified Linear First, in the case of 2PC-based solutions, a client must Units (ReLU), tanh, logarithms, sines, cosines, tangents, and remain online to communicate with the remote server over encrypted lookup tables. We propose a method with also multiple rounds and might incur substantial computational log(N) + 2 multiplications over encrypted integers (where N costs on small devices. More specifically, in [28], [29], is the size of the lookup table), which is a natural fit for ap- methods are described for running Gaussian mixture models plications within the NLP and ML domains. This differs from and hidden Markov models on encrypted data that employ [32], in which a function requiring log(N) multiplications is an ingenious way of calculating logarithms using oblivious proposed, that works for values encoded as binary strings. It transfer, randomization, and homomorphic encryption. Making also differs from the naive approach of performing lookups use of 2PC as well, [23] use garbled circuits to compute non- via polynomial interpolation. For instance, one can construct a polynomial functions. The main limitations of these protocols polynomial of degree N to perform 1 of N lookups. However, are communication costs and network availability; a user’s net- multiplication in (F)HE is very “expensive” (as it introduces a work capacity might be overwhelmed by too many calculation lot of noise and affects the underlying parameters for FHE requests, or their device might require computations to be ciphertext size). Minimizing the degree of the polynomial performed when they are offline. This could be particularly and the total number of multiplications is therefore necessary arduous for users with lower computational capacity or low for efficiency. (2) We compare our method on calculating Internet bandwidth. ReLUs with the alternative activation function suggested in Second, in the case for distant approximations of non- [18], within a Variational Autoencoder task that learns latent polynomial functions, Chebyshev polynomials have been used representations of MNIST images, as well as within an MNIST to approximate the sigmoid function within the encrypted image classifier itself. For both of these tasks, we compute domain [21], [22]. A drawback to these approximations is the losses and accuracies that result from varying the floating that their outputs are not bound between [0; 1], meaning that point precision of the inputs to the non-polynomial activation functions within both of these networks. Finally, we analyse D. Optimization: Single Instruction Multiple Data (SIMD) the results of these numerical precision experiments. Single Instruction Multiple Data (SIMD) is explained in II. BACKGROUND [17], [32]. Using the Chinese Remainder Theorem, an op- eration between two SIMD-encoded lists of encrypted num- A. Homomorphic Encryption bers can be performed by the same operations between two Homomorphic encryption schemes allow for computations regularly-encoded encrypted numbers2. We denote a SIMD- to be performed on encrypted data without needing to decrypt encoded encrypted vector by E(a) = E(ha1; :::; aN i). the data. For this work, we use Brakerski-Fan-Vercauteren (BFV) III. OUR SETTING AND SECURITY MODEL encryption, a fully homomorphic scheme based upon ring- We describe our setting as a few phases between a client learning with errors (RLWE) [7], [14], with the encryption and a remote (potentially untrusted) server. and homomorphic multiplication improvements of [20]1. • Setup phase. In our model, a client runs an FHE setup B. Notation and Scheme Overview algorithm and generates a pair of public and secret keys To describe the BFV scheme, we will use the same notation (pk; sk). It sends the public key to the server and keeps as [14], but, because we provide here only a brief overview the secret key private. of the homomorphic encryption scheme, the specific optimiza- A server performs a preprocessing step where it is given tions introduced in [14], [20] will not be discussed. a collection of functions ff : D ! Rg with small bounded-size domains D and it pre-computes all of the Let R = Z[x]=(g(x)) be an integer ring, where g(x) 2 Z[x] is a monic irreducible polynomial of degree d. Bold lowercase outputs. That is, for all functions f and all inputs to letters denote elements of R and their coefficients will be the function v 2 D, the server pre-computes fv. It then Pd−1 i stores a key-value mapping set Lf := f(v; fv)g. (It may, denoted by indices (e.g., a = i=0 ai · x ). Zq denotes the set of integers (−q=2; q=2], where q > 1 is a power of 2. The optionally, encrypt the mapping using the client’s public secret key is called sk = (1; s), where s R2. The public key to protect against future server compromises). key is called pk = ([−(a·s+e)]q; a), where a Rq, e χ. • Online phase. In the online phase, a client has an input The plaintext space is taken as Rp for some integer modulus v and it wants the server to compute E(fv) without p > 1. Let ∆ = bq=pc and denote q mod p by rp(q) then we learning anything about v. It encrypts v with pk, and clearly have q = ∆ · p + rp(q). sends the resulting ciphertext E(v) to the server. The • Encrypt(pk,m): message m 2 R , p = pk[0], p = p 0 1 server performs Eval(pk;E(v);L ) to obtain E(f ). pk[1], u R , e ; e χ: f v 2 1 2 The server may either send the result to the client or ct = [p0 · u + e1 + ∆ · m]q; [p1 · u + e2]q continue to run various functions on the result to learn a model. Eventually, the server sends a ciphertext to the • Decrypt(sk, ct): s = sk, c0 = ct[0], c1 = ct[1]. client who decrypts it to learn the results in the clear. hjp · [c0 + c1 · s]q mi The online phase may be repeated multiple times. Alterna- q p tively, a client may batch and send a vector of inputs to the server for computation. • Add(ct1; ct2): ([ct1[0] + ct2[0]]q; [ct1[1] + ct2[1]]q) Correctness. For any input v and its associated encryption • Mul(ct1; ct2): For this paper, we use component- wise multiplication, a simplified description of which is: transmitted by the client, the server learns a valid encryption E(fv). We prove this in Section IV-A. ([ct1[0]·ct2[0]]q; [ct1[1]·ct2[1]]q). We omit the details for obtaining this result [14]. Security. First, we distinguish between malicious and semi- honest servers. A malicious server may arbitrarily deviate from Using homomorphic encryption, we are able to perform linear the scheme to learn something about the inputs, while a semi- and, depending on the encryption scheme, polynomial opera- honest server follows the scheme but tries to learn something tions on encrypted data (i.e., multiplication, addition, or both). about the inputs from the execution trace alone. We can neither divide a ciphertext, nor exponentiate using an We protect against a malicious server (or an adversary that encrypted exponent. However, we can separately keep track compromises the server) that tries to learn information about of a numerator and a corresponding denominator. For clarity, inputs v, intermediary values of computation or the output we shall refer to the encrypted version of a value ∗ as E(∗).

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    7 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us