Hi OpenFHE team!
I want to know if this operation is incorrect
and if there should be a warning if it is wrong.
In my code, the first parameter BinFHE::BTKeyGen
uses the secret key generated by the second parameter, but there is no warning. Then, I used the secret key from the first parameter for computation and decryption, but the result was incorrect.
I want to know if you think this is a bug?
Here is the MWE:
#include "binfhecontext.h"
using namespace lbcrypto;
int main() {
auto cc = BinFHEContext();
cc.GenerateBinFHEContext(STD128_LMKCDEY, LMKCDEY);
auto cc1 = BinFHEContext();
cc1.GenerateBinFHEContext(STD128);
cc.GenerateBinFHEContext(STD128);
cc1 = cc;
auto sk = cc.KeyGen();
auto sk1 = cc1.KeyGen();
cc.BTKeyGen(sk1);
auto ct1 = cc.Encrypt(sk, 1);
auto ct2 = cc.Encrypt(sk, 1);
auto ctAND1 = cc.EvalBinGate(AND, ct1, ct2);
auto ct2Not = cc.EvalNOT(ct2);
auto ctAND2 = cc.EvalBinGate(AND, ct2Not, ct1);
auto ctResult = cc.EvalBinGate(OR, ctAND1, ctAND2);
LWEPlaintext result;
cc.Decrypt(sk, ctResult, &result);
std::cout << "Result of encrypted computation of (1 AND 1) OR (1 AND (NOT 1)) = " << result << std::endl;
return 0;
}
And the result will be
Result of encrypted computation of (1 AND 1) OR (1 AND (NOT 1)) = 2