Hello,
I have a question about the minimum required level of ciphertexts to evaluate a homomorphic circuit. Specifically, I am wondering if constant multiplication in homomorphic encryption consumes a level.
When performing homomorphic multiplication between ciphertexts, it is understood that this requires a level. However, does constant multiplication also always require rescaling after the operation?
When setting the level of ciphertext to evaluate a homomorphic circuit, should I take constant multiplication into account, or can I skip rescaling in some cases?
(Or are the cases where I just multiply a constant to a ciphertext and the case where I multiply a packed plaintext to a ciphertext different?)
Thank you.
- In below code, why the output is as the screenshot instead of decryption failure or the vector with all entries 1?
parameters.SetSecurityLevel(HEStd_NotSet);
parameters.SetRingDim(1 << 12);
usint scalingModSize = 50;
uint32_t multDepth = 0;
parameters.SetScalingModSize(scalingModSize);
parameters.SetMultiplicativeDepth(multDepth);
CryptoContext<DCRTPoly> cc = GenCryptoContext(parameters);
cc->Enable(PKE);
cc->Enable(KEYSWITCH);
cc->Enable(LEVELEDSHE);
cc->Enable(ADVANCEDSHE);
cc->Enable(FHE);
auto keyPair = cc->KeyGen();
cc->EvalMultKeyGen(keyPair.secretKey);
std::vector<double> input;
for(int i=0; i <16; i++){
input.push_back(0.5);
}
Plaintext plaintext = cc->MakeCKKSPackedPlaintext(input);
auto ciphertext = cc->Encrypt(keyPair.publicKey, plaintext);
std::cout << "before eval ciph level: " << ciphertext->GetLevel() << std::endl;
double c = 2.0;
auto cmult = cc->EvalMult(ciphertext, c);
std::cout << "after constant multiplication level: " << cmult->GetLevel() << std::endl;
Plaintext plaintextDec;
cc->Decrypt(keyPair.secretKey, cmult, &plaintextDec);
plaintextDec->SetLength(16);
std::vector<double> finalResult = plaintextDec->GetRealPackedValue();
std::cout << "output: " << finalResult << std::endl << std::endl;
Result was:
before eval ciph level: 0
after constant multiplication level: 1
output: [ -8.67362e-19 -8.67362e-19 -8.67362e-19 -8.67362e-19 -8.67362e-19 -8.67362e-19 -8.67362e-19 -8.67362e-19 -8.67362e-19 -8.67362e-19 -8.67362e-19 -8.67362e-19 -8.67362e-19 -8.67362e-19 -8.67362e-19 -8.67362e-19 ]