Hello,
I made a simple program to calculate the sum of all the values in all the plaintexts using Packed Encoding. Now I wanted to compare the performance with Coefficient Packed Encoding. I’m using BFVrns, and the code is the following:
/...../
for(int i = 0; i < number_vectors; i++){
begin = i * number_vectors + i;
end = size_vectors * (i + 1);
Plaintext plaintext = cryptoContext->MakeCoefPackedPlaintext(std::vector<int64_t>(all_numbers.begin() + begin, all_numbers.begin() + end));
ciphertexts.push_back(cryptoContext->Encrypt(keyPair.publicKey, plaintext));
}
TOC(t);
processingTime = TOC(t);
std::cout << "Time spend during encryption " << processingTime << "ms" << std::endl;
TIC(t);
auto ciphertextAdd = cryptoContext->EvalAddMany(ciphertexts);
auto ciphertextRot = ciphertextAdd;
for(int i = 0; i < size_vectors; i++){
ciphertextRot = cryptoContext->EvalRotate(ciphertextRot, 1);
ciphertextAdd = cryptoContext->EvalAdd(ciphertextAdd, ciphertextRot);
}
/...../
If I use Plaintext plaintext = cryptoContext->MakePackedPlaintext(.....);
everything works but with the code above I get the following error:
Time spend during encryption 71ms
terminate called after throwing an instance of 'lbcrypto::type_error'
what(): /usr/local/include/openfhe/pke/encoding/plaintext.h:361 not a packed coefficient vector
Aborted (core dumped)
I assume that I cannot use cryptoContext->EvalAddMany()
, but I can’t find anything in the documentation that mentions it. Do I need to set up anything during the context?
Thanks for the help in advance