08.01.2015 Views

Design and Implementation of a Homomorphic ... - Researcher

Design and Implementation of a Homomorphic ... - Researcher

Design and Implementation of a Homomorphic ... - Researcher

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

On subsequent calls with the same powers <strong>and</strong> Rb, these arrays are not computed again but taken<br />

from the pre-computed arguments. If the powers <strong>and</strong> Rb arguments are initialized, then it is<br />

assumed that they were computed correctly from root. The behavior is undefined when calling<br />

with initialized powers <strong>and</strong> Rb but a different root. (In particular, to compute the inverse-FFT<br />

using root −1 , one must provide different powers <strong>and</strong> Rb arguments than those that were given<br />

when computing in the forward direction using root.) This procedure cannot be used for in-place<br />

FFT, calling BluesteinFFT(x, x, · · · ) will just zero-out the polynomial x.<br />

The classes Cmodulus <strong>and</strong> CModulus. These classes provide an interface layer for the FFT<br />

routines above, relative to a single prime (where Cmodulus is used for smallint primes <strong>and</strong> CModulus<br />

for bigint primes). They keep the NTL “current modulus” structure for that prime, as well as the<br />

powers <strong>and</strong> Rb arrays for FFT <strong>and</strong> inverse-FFT under that prime. They are constructed with the<br />

constructors<br />

Cmodulus(const PAlgebra& ZmStar, const long& q, const long& root);<br />

CModulus(const PAlgebra& ZmStar, const ZZ& q, const ZZ& root);<br />

where ZmStar described the structure <strong>of</strong> Z ∗ m (see Section 2.4), q is the prime modulus <strong>and</strong> root<br />

is a primitive 2m−’th root <strong>of</strong> unity modulo q. (If the constructor is called with root = 0 then it<br />

computes a 2m-th root <strong>of</strong> unity by itself.) Once an object <strong>of</strong> one <strong>of</strong> these classes is constructed, it<br />

provides an FFT interfaces via<br />

void Cmodulus::FFT(vec long& y, const ZZX& x) const; // y = FFT(x)<br />

void Cmodulus::iFFT(ZZX& x, const vev long& y) const; // x = FFT −1 (y)<br />

(And similarly for CModulus using vec ZZ instead <strong>of</strong> vec long). These method are inverses <strong>of</strong><br />

each other. The methods <strong>of</strong> these classes affect the NTL “current modulus”, <strong>and</strong> it is the responsibility<br />

<strong>of</strong> the caller to backup <strong>and</strong> restore the modulus if needed (using the NTL constructs<br />

zz pBak/ZZ pBak).<br />

2.4 PAlgebra: The Structure <strong>of</strong> Z ∗ m <strong>and</strong> Z ∗ m/ 〈2〉<br />

The class PAlgebra is the base class containing the structure <strong>of</strong> Z ∗ m, as well as the quotient group<br />

Z ∗ m/ 〈2〉. We represent Z ∗ m as Z ∗ m = 〈2〉 × 〈g 1 , g 2 , . . .〉 × 〈h 1 , h 2 , . . .〉, where the g i ’s have the same<br />

order in Z ∗ m as in Z ∗ m/ 〈2〉, <strong>and</strong> the h i ’s generate the group Z ∗ m/ 〈2, g 1 , g 2 , . . .〉 <strong>and</strong> they do not have<br />

the same order in Z ∗ m as in Z ∗ m/ 〈2〉.<br />

We compute this representation in a manner similar (but not identical) to the pro<strong>of</strong> <strong>of</strong> the fundamental<br />

theorem <strong>of</strong> finitely generated abelian groups. Namely we keep the elements in equivalence<br />

classes <strong>of</strong> the “quotient group so far”, <strong>and</strong> each class has a representative element (called a pivot),<br />

which in our case we just choose to be the smallest element in the class. Initially each element<br />

is in its own class. At every step, we choose the highest order element g in the current quotient<br />

group <strong>and</strong> add it as a new generator, then unify classes if their members are a factor <strong>of</strong> g from each<br />

other, repeating this process until no further unification is possible. Since we are interested in the<br />

quotient group Z ∗ m/ 〈2〉, we always choose 2 as the first generator.<br />

One twist in this routine is that initially we only choose an element as a new generator if its<br />

order in the current quotient group is the same as in the original group Z ∗ m. Only after no such<br />

elements are available, do we begin to use generators that do not have the same order as in Z ∗ m.<br />

Once we chose all the generators (<strong>and</strong> for each generator we compute its order in the quotient<br />

group where it was chosen), we compute a set <strong>of</strong> “slot representatives” as follows: Putting all the<br />

5

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

Saved successfully!

Ooh no, something went wrong!