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.
*** Perform homomorphic operations ***/<br />
c1.multiplyBy(c0);<br />
c0.addConstant(const1_poly);<br />
c2.multByConstant(const2_poly);<br />
// also does mod-switching, key-switching<br />
Ctxt tmp(c1); // tmp = c1<br />
long amt = R<strong>and</strong>omBnd(2*(nslots/2)+1)-(nslots/2); // in [-nslots/2..nslots/2]<br />
ea.shift(tmp, amt); // rotate tmp by amt<br />
c2 += tmp;<br />
// then add to c2<br />
amt = R<strong>and</strong>omBnd(2*nslots-1) - (nslots-1);<br />
ea.rotate(c2, amt);<br />
// in [-(nslots-1)..nslots-1]<br />
c1.negate();<br />
c3.multiplyBy(c2);<br />
c0 -= c3;<br />
/*** Decrypt the results <strong>of</strong> the computation ***/<br />
ea.decrypt(c0, secretKey, pp0);<br />
ea.decrypt(c1, secretKey, pp1);<br />
ea.decrypt(c2, secretKey, pp2);<br />
ea.decrypt(c3, secretKey, pp3);<br />
5.2 <strong>Homomorphic</strong> Operations over Z 2 5<br />
This example is almost identical to the previous one, except that the FHEcontext is initialized<br />
also with the paremeter r = 5, we use EncryptedArrayMod2r instead <strong>of</strong> EncryptedArray <strong>and</strong><br />
vector instead <strong>of</strong> vector, <strong>and</strong> we do not need the polynomial G.<br />
/*** Determine the parameters (cf. [5, Appendix C]) ***/<br />
long r = 5;<br />
long ptxtSpace = 1L