I have a CKKs ciphertext in OpenFHE and I have carried out a handful of operations on it.
I am trying to evaluate a EvalChebyshevFunction function for the second time but I am getting the following error:
dcrtpoly-impl.h:l.695:DropLastElement(): DropLastElement: Removing last element of DCRTPoly renders it invalid.
I understand that this error comes from a large noise budget.
I have done
auto boots_second_cph = context->EvalBootstrap(cph, 2);
before trying to evaluate again. The function I am trying to evaluate with EvalChebyshevFunction is a simple greater than function which I believe takes 5 multiplicative levels to evaluate.
Trying to evaluate the boots_second_cph still give the error above. How can I bootstrap more efficiently or fix this issue if it is not a bootstrapping issue?
My context is with the following parameters:
CCParams<CryptoContextCKKSRNS> parameters;
num_slots = 1 << 12;
parameters.SetSecretKeyDist(SPARSE_TERNARY);
parameters.SetSecurityLevel(lbcrypto::HEStd_NotSet);
parameters.SetNumLargeDigits(3);
parameters.SetRingDim(1 << 14);
parameters.SetBatchSize(num_slots);
level_budget = {4, 4};
ScalingTechnique rescaleTech = FLEXIBLEAUTO;
int dcrtBits = 47;
int firstMod = 52;
parameters.SetScalingModSize(dcrtBits);
parameters.SetScalingTechnique(rescaleTech);
parameters.SetFirstModSize(firstMod);
uint32_t approxBootstrapDepth = 2 + 2;
uint32_t levelsUsedBeforeBootstrap = 4;
circuit_depth = levelsUsedBeforeBootstrap + FHECKKSRNS::GetBootstrapDepth(approxBootstrapDepth, level_budget, SPARSE_TERNARY);
parameters.SetMultiplicativeDepth(circuit_depth);
context = GenCryptoContext(parameters);
context->Enable(PKE);
context->Enable(KEYSWITCH);
context->Enable(LEVELEDSHE);
context->Enable(ADVANCEDSHE);
context->Enable(FHE);
keyPair = context->KeyGen();
context->EvalMultKeyGen(keyPair.secretKey);
std::vector<uint32_t> levelBudget = {2, 2};
std::vector<uint32_t> bsgsDim = {0, 0};
usint numSlots = context->GetRingDimension() / 2;
usint halfnumSlots = numSlots/2;
context->EvalBootstrapSetup(levelBudget, bsgsDim, numSlots);
context->EvalBootstrapKeyGen(keyPair.secretKey, numSlots);
context->EvalBootstrapSetup(levelBudget, bsgsDim, halfnumSlots);
context->EvalBootstrapKeyGen(keyPair.secretKey, halfnumSlots);