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
LWECiphertext BinFHEScheme::EvalBinGate(const std::shared_ptr<BinFHECryptoParams>& params, BINGATE gate,
const RingGSWBTKey& EK, ConstLWECiphertext& ct1,
ConstLWECiphertext& ct2) const {
if (ct1 == ct2)
OPENFHE_THROW(config_error, "Input ciphertexts should be independant");
// By default, we compute XOR/XNOR using a combination of AND, OR, and NOT gates
if ((gate == XOR) || (gate == XNOR)) {
const auto& ctAND1 = EvalBinGate(params, AND, EK, ct1, EvalNOT(params, ct2));
const auto& ctAND2 = EvalBinGate(params, AND, EK, EvalNOT(params, ct1), ct2);
const auto& ctOR = EvalBinGate(params, OR, EK, ctAND1, ctAND2);
// NOT is free so there is not cost to do it an extra time for XNOR
return (gate == XOR) ? ctOR : EvalNOT(params, ctOR);
}
LWECiphertext ctprep = std::make_shared<LWECiphertextImpl>(*ct1);
// the additive homomorphic operation for XOR/NXOR is different from the other gates we compute
// 2*(ct1 - ct2) mod 4 for XOR, me map 1,2 -> 1 and 3,0 -> 0
if ((gate == XOR_FAST) || (gate == XNOR_FAST)) {
LWEscheme->EvalSubEq(ctprep, ct2);
LWEscheme->EvalAddEq(ctprep, ctprep);
}
else {
// for all other gates, we simply compute (ct1 + ct2) mod 4
// for AND: 0,1 -> 0 and 2,3 -> 1
// for OR: 1,2 -> 1 and 3,0 -> 0
LWEscheme->EvalAddEq(ctprep, ct2);
}
auto acc{BootstrapGateCore(params, gate, EK.BSkey, ctprep)};
...
If we fix mapping function of X(N)OR gate like 2(C1 + C2) [q/4, 3q/4] [-q/4, q/4], then we can operate X(N)OR gate with the same failure probability as other gates(AND, OR). And of course, we need only one blind rotation.
The text was updated successfully, but these errors were encountered:
I think that this code is implemented like described in https://eprint.iacr.org/2020/086.
When we use X(N)OR gate, we execute (ct1 && ~ct2) || (~ct1 && ct2). This process need 3 blind rotation so it’s slower then AND, OR gate.
If we use X(N)OR_FAST gate, we use following mapping function.
This process will make a big noise.
If we fix mapping function of X(N)OR gate like 2(C1 + C2) [q/4, 3q/4] [-q/4, q/4], then we can operate X(N)OR gate with the same failure probability as other gates(AND, OR). And of course, we need only one blind rotation.
The text was updated successfully, but these errors were encountered: