FullRNS-HEAAN
FullRNS-HEAAN copied to clipboard
Fail on homomorphic multiplication
Hello,
I've found some cases in which the homomorphic multiplication seems to fail. In particular, I got this MWE that tries to compute -22.5 * -22.5:
long logN = 7;
long L = 2;
long logp = 45;
long logSlots = 1;
long K = L + 1;
Context context(logN, logp, L, K);
SecretKey secretKey(context);
Scheme scheme(secretKey, context);
srand(0);
complex<double> mvec1 = {-22.5,0};
complex<double> mvec2 = {-22.5,0};
complex<double> mvecMult;
mvecMult = mvec1 * mvec2;
Ciphertext cipher1 = scheme.encryptSingle(mvec1, L);
Ciphertext cipher2 = scheme.encryptSingle(mvec2, L);
Ciphertext multCipher = scheme.mult(cipher1, cipher2);
scheme.reScaleByAndEqual(multCipher, 1);
complex<double>* dvecMult = scheme.decrypt(secretKey, multCipher);
std::cout << "Expected: " << (mvec1 * mvec2) << std::endl;
std::cout << "Output: " << *dvecMult << std::endl;
This is the output I get:
Expected: (506.25,-0)
Output: (-18073.4,-30416)
Still, it works for 22.5 * 22.5. Any ideas about what is happening here?