You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that when ciphertext and plaintext created in different contexts are added, unintended errors can occur.
#include "openfhe.h"
using namespace lbcrypto;
int main() {
//c1 in cc1
CCParams<CryptoContextCKKSRNS> parameters;
parameters.SetMultiplicativeDepth(2);
CryptoContext<DCRTPoly> cc1 = GenCryptoContext(parameters);
cc1->Enable(PKE);
cc1->Enable(LEVELEDSHE);
auto keys = cc1->KeyGen();
std::vector<double> x1 = {1};
Plaintext plaintext = cc1->MakeCKKSPackedPlaintext(x1);
auto c1 = cc1->Encrypt(keys.publicKey, plaintext);
//p1 in cc2
CCParams<CryptoContextCKKSRNS> parameters2;
parameters2.SetMultiplicativeDepth(3);
CryptoContext<DCRTPoly> cc2 = GenCryptoContext(parameters2);
std::vector<double> x2 = {1};
Plaintext p1 = cc2->MakeCKKSPackedPlaintext(x2);
// Add(c1,p1) in cc1
c1 = cc1->EvalAdd(c1,p1);
return 0;
}
Result:
libc++abi: terminating due to uncaught exception of type lbcrypto::math_error: /project/openfhe-development/src/core/lib/math/hal/intnat/mubintvecnat.cpp:245 ModAddEq called on NativeVectorT's with different parameters.
libc++abi: terminating due to uncaught exception of type lbcrypto::math_error: /project/openfhe-development/src/core/lib/math/hal/intnat/mubintvecnat.cpp:245 ModAddEq called on NativeVectorT's with different parameters.
I believe there are several possible ways to address the issue:
Throw an exception when plaintext and ciphertext created in different contexts are added.
Check if the coefficient modulus of each context matches when adding plaintext and ciphertext from different contexts, and thrwo an exception if they do not.
The text was updated successfully, but these errors were encountered:
Hi, OpenFHE Team!
I found that when ciphertext and plaintext created in different contexts are added, unintended errors can occur.
Result:
I believe there are several possible ways to address the issue:
The text was updated successfully, but these errors were encountered: