Skip to content

Commit

Permalink
bug fix for BinFHEScheme::BootstrapFunc()
Browse files Browse the repository at this point in the history
  • Loading branch information
pascoec committed Oct 1, 2024
1 parent 7fb8ab4 commit bce9cfc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/binfhe/lib/binfhe-base-scheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ LWECiphertext BinFHEScheme::EvalFunc(const std::shared_ptr<BinFHECryptoParams>&
NativeInteger dq{q << 1};
// raise the modulus of ct1 : q -> 2q
ct1->GetA().SetModulus(dq);

auto ct2 = std::make_shared<LWECiphertextImpl>(*ct1);
LWEscheme->EvalAddConstEq(ct2, beta);

// this is 1/4q_small or -1/4q_small mod q
auto f0 = [](NativeInteger x, NativeInteger q, NativeInteger Q) -> NativeInteger {
if (x < (q >> 1))
Expand Down Expand Up @@ -594,7 +594,14 @@ LWECiphertext BinFHEScheme::BootstrapFunc(const std::shared_ptr<BinFHECryptoPara
accVec[1].SetFormat(Format::COEFFICIENT);

auto ctExt = std::make_shared<LWECiphertextImpl>(std::move(accVec[0].GetValues()), accVec[1][0]);
return LWEscheme->SwitchCTtoqn(params->GetLWEParams(), EK.KSkey, ctExt);

auto& LWEParams = params->GetLWEParams();
// Modulus switching to a middle step Q'
auto ctMS = LWEscheme->ModSwitch(LWEParams->GetqKS(), ctExt);
// Key switching
auto ctKS = LWEscheme->KeySwitch(LWEParams, EK.KSkey, ctMS);
// Modulus switching
return LWEscheme->ModSwitch(fmod, ctKS);
}

}; // namespace lbcrypto

0 comments on commit bce9cfc

Please sign in to comment.