Question about Many Multiplications.
I tried to do many multiplication in BFV example(simple-integer.cpp) as below. But, if I do multiplication over 5 times, the result is weird. And also, the result is strange even if I used EvalMultAndRelinearize() in the middle. Please check whether I used EvalMult() incorrectly or not.
Additionally, in this regard, when it needs to relinearize during an operation, I wonder which part of the PALISADE is the noise calculation.
Code:
TIC(t);
auto ciphertextMult12 = cryptoContext->EvalMult(ciphertext1, ciphertext2);
processingTime = TOC(t);
std::cout << "Multiplication 2 ciphertexts time(1,2): " << processingTime << "ms" << std::endl;
/*
TIC(t);
auto ciphertextMult123 = cryptoContext->EvalMultAndRelinearize(ciphertextMult12, ciphertext3);
processingTime = TOC(t);
std::cout << "Multiplication 3 ciphertexts time(1,2,3): " << processingTime << "ms" << std::endl;
*/
TIC(t);
auto ciphertextMult123 = cryptoContext->EvalMult(ciphertextMult12, ciphertext3);
processingTime = TOC(t);
std::cout << "Multiplication 3 ciphertexts time(1,2,3): " << processingTime << "ms" << std::endl;
TIC(t);
auto ciphertextMult1234 = cryptoContext->EvalMult(ciphertextMult123, ciphertext4);
processingTime = TOC(t);
std::cout << "Multiplication 4 ciphertexts time(1,2,3,4): " << processingTime << "ms" << std::endl;
TIC(t);
auto ciphertextMult12345 = cryptoContext->EvalMult(ciphertextMult1234, ciphertext5);
processingTime = TOC(t);
std::cout << "Multiplication 5 ciphertexts time(1,2,3,4,5): " << processingTime << "ms" << std::endl;
TIC(t);
auto ciphertextMult123456 = cryptoContext->EvalMult(ciphertextMult12345, ciphertext5);
// auto ciphertextMultManyResult = cryptoContext->EvalMultAndRelinearize(ciphertextMult12345, ciphertext5);
processingTime = TOC(t);
std::cout << "Multiplication 6 ciphertexts time(1,2,3,4,5,6): " << processingTime << "ms" << std::endl;
TIC(t);
auto ciphertextMultManyResult = cryptoContext->EvalMult(ciphertextMult123456, ciphertext7);
processingTime = TOC(t);
std::cout << "Multiplication 5 ciphertexts time(1,2,3,4,5,6,7): " << processingTime << "ms" << std::endl;
// processingTime = TOC(t);
// std::cout << "Multiplication 7 ciphertexts time: " << processingTime << "ms" << std::endl;
Plaintext plaintextMultManyResult;
cryptoContext->Decrypt(keyPair.secretKey, ciphertextMultManyResult, &plaintextMultManyResult);
plaintextMultManyResult->SetLength(vectorOfInts1.size());
std::cout << "#1 * #2 * #3 * #4 * #5 * #6 * #7: " << plaintextMultManyResult << std::endl;
Edited by Ian Quah