22.04.2014 Views

a590003

a590003

a590003

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

void sampleGaussian(double stdev=3.2);<br />

Draws a random polynomial with coefficients −1, 0, 1, and converts it to DoubleCRT format.<br />

Each coefficient is chosen at random from a Gaussian distribution with zero mean and variance<br />

stdev 2 , rounded to an integer.<br />

In addition to the above, we also provide the following methods:<br />

DoubleCRT& SetZero(); // set to the constant zero<br />

DoubleCRT& SetOne(); // set to the constant one<br />

const FHEcontext& getContext() const; // access to context<br />

const IndexSet& getIndexSet() const; // the current set of primes<br />

void breakIntoDigits(vector&, long) const; // used in key-switching<br />

The method breakIntoDigits above is described in Section 3.1.6, where we discuss key-switching.<br />

The SingleCRT class. SingleCRT is a helper class, used to gain some efficiency in expensive<br />

DoubleCRT operations. A SingleCRT object is also defined relative to a fixed FHEcontext and a<br />

dynamic subset S of the small primes. This SingleCRT object holds an IndexMap of polynomials<br />

(in NTL’s ZZX format), where the i’th polynomial contains the coefficients modulo the ith small<br />

prime in our list.<br />

Although SingleCRT and DoubleCRT objects can interact in principle, translation back and<br />

forth are expensive since they involve FFT (or inverse FFT) modulo each of the primes. Hence<br />

support for interaction between them is limited to explicit conversions.<br />

3 The Crypto Layer<br />

The third layer of our library contains the implementation of the actual BGV homomorphic cryptosystem,<br />

supporting homomorphic operations on the “native plaintext space” of polynomials in A 2<br />

(or more generally polynomials in A 2 r for some parameter r). We partitioned this layer (somewhat<br />

arbitrarily) into the Ctxt module that implements ciphertexts and ciphertext arithmetic, the FHE<br />

module that implements the public and secret keys, and the key-switching matrices, and a helper<br />

KeySwitching module that implements some common strategies for deciding what key-switching<br />

matrices to generate. Two high-level design choices that we made in this layer is to implement<br />

ciphertexts as arbitrary-length vectors of polynomials, and to allow more than one secret-key per<br />

instance of the system. These two choices are described in more details in Sections 3.1 and 3.2<br />

below, respectively.<br />

3.1 The Ctxt module: Ciphertexts and homomorphic operations<br />

Recall that in the BGV cryptosystem, a “canonical” ciphertext relative to secret key s ∈ A is a<br />

vector of two polynomials (c 0 , c 1 ) ∈ Aq<br />

2 (for the “current modulus” q), such that m = [c 0 + c 1 s] q is<br />

a polynomial with small coefficients, and the plaintext that is encrypted by this ciphertext is the<br />

binary polynomial [m] 2 ∈ A 2 . However the library has to deal also with “non-canonical” ciphertexts:<br />

for example when multiplying two ciphertexts as above we get a vector of three polynomials<br />

(c 0 , c 1 , c 2 ), which is encrypted by setting m = [c 0 + c 1 s + c 2 s 2 ] q and outputting [m] 2 . Also, after a<br />

13<br />

16. Design and Implementation of a Homomorphic-Encryption Library

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!