22.04.2014 Views

a590003

a590003

a590003

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

void addPrimes(const IndexSet& s);<br />

Expand the index set by s. It is assumed that s is disjoint from the current index set. This is<br />

an expensive operation, as it needs to convert to coefficient representation and back, in order<br />

to determine the values in the added rows.<br />

double addPrimesAndScale(const IndexSet& S);<br />

Expand the index set by S, and multiply by q diff = ∏ i∈S p i. The set S is assumed to be<br />

disjoint from the current index set. Returns log(q diff ). This operation is typically much faster<br />

than addPrimes, since we can fill the added rows with zeros.<br />

void removePrimes(const IndexSet& s);<br />

Remove the primes p i with i ∈ s from the current index set.<br />

void scaleDownToSet(const IndexSet& s, long ptxtSpace);<br />

This is a modulus-switching operation. Let ∆ be the set of primes that are removed,<br />

∆ = getIndexSet() \ s, and q diff = ∏ i∈∆ p i. This operation removes the primes p i , i ∈ ∆,<br />

scales down the polynomial by a factor of q diff , and rounds so as to keep a mod ptxtSpace<br />

unchanged.<br />

We provide some conversion routines to convert polynomials from coefficient-representation<br />

(NTL’s ZZX format) to DoubleCRT and back, using the constructor<br />

DoubleCRT(const ZZX&, const FHEcontext&, const IndexSet&);<br />

and the conversion function ZZX to ZZX(const DoubleCRT&). We also provide translation routines<br />

between SingleCRT and DoubleCRT.<br />

We support the usual set of arithmetic operations on DoubleCRT objects (e.g., addition, multiplication,<br />

etc.), always working in A q for some modulus q. We only implemented the “destructive”<br />

two-argument version of these operations, where one of the input arguments is modified to return<br />

the result. These arithmetic operations can only be applied to DoubleCRT objects relative to the<br />

same FHEcontext, else an error is raised.<br />

On the other hand, the DoubleCRT class supports operations between objects with different<br />

IndexSet’s, offering two options to resolve the differences: Our arithmetic operations take a boolean<br />

flag matchIndexSets, when the flag is set to true (which is the default), the index-set of the result is<br />

the union of the index-sets of the two arguments. When matchIndexSets=false then the index-set<br />

of the result is the same as the index-set of *this, i.e., the argument that will contain the result<br />

when the operation ends. The option matchIndexSets=true is slower, since it may require adding<br />

primes to the two arguments. Below is a list of the arithmetic routines that we implemented:<br />

DoubleCRT& Negate(const DoubleCRT& other); // *this = -other<br />

DoubleCRT& Negate();<br />

// *this = -*this;<br />

DoubleCRT& operator+=(const DoubleCRT &other); // Addition<br />

DoubleCRT& operator+=(const ZZX &poly); // expensive<br />

DoubleCRT& operator+=(const ZZ &num);<br />

DoubleCRT& operator+=(long num);<br />

DoubleCRT& operator-=(const DoubleCRT &other); // Subtraction<br />

DoubleCRT& operator-=(const ZZX &poly); // expensive<br />

11<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!