I modified a public code for encrypted inference using CNN (with CKKS scheme). Actually it only needs depth 6 for the inference. But I am just experimenting to put bootstrapping there to test my understanding. I plan to call the bootstrapping in the middle of the inference (like after 3 multiplications)
I set the parameters as below:
parameters.SetSecurityLevel(HEStd_128_classic);
SecretKeyDist secretKeyDist = UNIFORM_TERNARY;
uint32_t levelsAvailableAfterBootstrap = 5;
std::vector<uint32_t> levelBudget = {4, 4};
usint depth = levelsAvailableAfterBootstrap + FHECKKSRNS::GetBootstrapDepth(levelBudget, secretKeyDist);
parameters.SetMultiplicativeDepth(depth);
std::cout << "CKKS parameter level required for bootstrap: " << FHECKKSRNS::GetBootstrapDepth(levelBudget, secretKeyDist) << std::endl;
parameters.SetScalingModSize(59);
parameters.SetFirstModSize(60);
parameters.SetBatchSize(num_slots); // num_slots=16384
m_cc = GenCryptoContext(parameters);
m_cc->Enable(PKE);
m_cc->Enable(KEYSWITCH);
m_cc->Enable(LEVELEDSHE);
m_cc->Enable(ADVANCEDSHE);
m_cc->Enable(FHE);
m_cc->EvalBootstrapSetup(levelBudget);
KeyPair<DCRTPoly> key_pair = m_cc->KeyGen();
m_SecretKey = key_pair.secretKey;
m_PublicKey = key_pair.publicKey;
vector<int32_t> rotations = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 32, 33, 34, 64, 65, 66, 128, 256, 512, 1024, 2048, 4096, 8192};
m_cc->EvalBootstrapKeyGen(m_SecretKey, num_slots);
m_cc->EvalRotateKeyGen(m_SecretKey, rotations);
m_cc->EvalMultKeyGen(m_SecretKey);
...
And when I run, I keep getting this error while generating keys:
/ckksrns-fhe.cpp:l.756:FindBootstrapRotationIndices(): Precomputations for 16384 slots were not generated Need to call EvalBootstrapSetup to proceed
I don’t really understand what happened here. Can someone help explain why it happened and what I should do. Thanks in advance.