Hi,
Why the output of my program is different from the expected output?
parameters.SetMultiplicativeDepth(3);
parameters.SetEvalAddCount(45);
parameters.SetPlaintextModulus(536903681);
parameters.SetMaxRelinSkDeg(4);
std::vector<int64_t> vectorOfInts1 = {0};
Plaintext plaintext1 = cryptoContext->MakePackedPlaintext(vectorOfInts1);
std::vector<int64_t> vectorOfInts2 = {0};
Plaintext plaintext2 = cryptoContext->MakePackedPlaintext(vectorOfInts2);
Ciphertext<DCRTPoly> ciphertext1;
Ciphertext<DCRTPoly> ciphertext2;
ciphertext1 = cryptoContext->Encrypt(keyPair.publicKey, plaintext1);
ciphertext2 = cryptoContext->Encrypt(keyPair.publicKey, plaintext2);
Plaintext plaintextDecMult;
ciphertext1 = cryptoContext->EvalMult(ciphertext1, ciphertext2);
cryptoContext->ModReduceInPlace(ciphertext1);
ciphertext1 = cryptoContext->EvalMult(ciphertext1, ciphertext2);
cryptoContext->ModReduceInPlace(ciphertext1);
ciphertext1 = cryptoContext->EvalMult(ciphertext1, ciphertext2);
//cryptoContext->ModReduceInPlace(ciphertext1);
cryptoContext->RelinearizeInPlace(ciphertext1);
cryptoContext->Decrypt(keyPair.secretKey, ciphertext1, &plaintextDecMult);
plaintextDecMult->SetLength(plaintext1->GetLength());
std::cout << "\nResult of 3 homomorphic multiplications: \n";
std::cout << plaintextDecMult << std::endl;
for(int i=0; i<=20; i++){
ciphertext1 = cryptoContext->EvalAdd(ciphertext1,ciphertext1);
}
cryptoContext->Decrypt(keyPair.secretKey, ciphertext1, &plaintextDecMult);
plaintextDecMult->SetLength(plaintext1->GetLength());
std::cout << "\n After adding 0 vector 20 times to the result of multiplication: " << std::endl;
std::cout << plaintextDecMult << std::endl;
Output is:
Result of 3 homomorphic multiplications:
( 0 ... )
After adding 0 vector 20 times to the result of multiplication:
( -94411888 ... )
Expected output was ( 0 ... )
Do I need to set EvalAddCount to 2^20?