Design and Implementation of a Homomorphic ... - Researcher
Design and Implementation of a Homomorphic ... - Researcher
Design and Implementation of a Homomorphic ... - Researcher
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
void addPrimes(const IndexSet& s);<br />
Exp<strong>and</strong> 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 <strong>and</strong> back, in order<br />
to determine the values in the added rows.<br />
double addPrimesAndScale(const IndexSet& S);<br />
Exp<strong>and</strong> the index set by S, <strong>and</strong> 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 <strong>of</strong> primes that are removed,<br />
∆ = getIndexSet() \ s, <strong>and</strong> q diff = ∏ i∈∆ p i. This operation removes the primes p i , i ∈ ∆,<br />
scales down the polynomial by a factor <strong>of</strong> q diff , <strong>and</strong> 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 <strong>and</strong> back, using the constructor<br />
DoubleCRT(const ZZX&, const FHEcontext&, const IndexSet&);<br />
<strong>and</strong> the conversion function ZZX to ZZX(const DoubleCRT&). We also provide translation routines<br />
between SingleCRT <strong>and</strong> DoubleCRT.<br />
We support the usual set <strong>of</strong> 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 <strong>of</strong> these operations, where one <strong>of</strong> 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 h<strong>and</strong>, the DoubleCRT class supports operations between objects with different<br />
IndexSet’s, <strong>of</strong>fering 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 <strong>of</strong> the result is<br />
the union <strong>of</strong> the index-sets <strong>of</strong> the two arguments. When matchIndexSets=false then the index-set<br />
<strong>of</strong> the result is the same as the index-set <strong>of</strong> *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 <strong>of</strong> 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