Issue with reliniarization to compute a geometric serie
Hello, I'm trying to compute a geometric serie with encrypted constant ratio x_encrypted_example for a fixed N iterations, however i noticed that the noise budget before and after the reliniarisation remain the same ( in encrypted_resultt), what do you think the problem came from ? Bellow the snippet `RelinKeys relin_keyss; keygen.create_relin_keys(relin_keyss);
print_line(__LINE__);
cout << " Evaluation of a multiplicative progression, we'll evaluate the overhead later "<<endl;
x = 5 ;
Plaintext x_plain_example(to_string(x));
Ciphertext x_encrypted_example;
encryptor.encrypt(x_plain_example,x_encrypted_example);
int sum =0;
Plaintext sum_plain(to_string(sum));
Ciphertext sum_encrypt;
encryptor.encrypt(sum_plain,sum_encrypt);
int prod =1;
Plaintext prod_plain(to_string(prod));
Ciphertext prod_encrypt;
encryptor.encrypt(prod_plain,prod_encrypt);
Ciphertext encrypted_resultt;`
`
int N = 3;
for (int cmp=0;cmp<N;cmp++)
{
evaluator.add_inplace(sum_encrypt,prod_encrypt);
evaluator.multiply(x_encrypted_example,prod_encrypt,encrypted_resultt);
cout << " + size of encrypted_resultt: " << encrypted_resultt.size() << endl;
cout << " + noise budget in encrypted_resultt: " << decryptor.invariant_noise_budget(encrypted_resultt) << " bits"
<< endl;
evaluator.relinearize_inplace(encrypted_resultt, relin_keyss);
cout << " + size of encrypted_resultt (after relinearization): " << encrypted_resultt.size() << endl;
cout << " + noise budget in encrypted_resultt: " << decryptor.invariant_noise_budget(encrypted_resultt) << " bits"
<< endl;
prod_encrypt = Ciphertext(encrypted_resultt);
}
`
Edit : when i omit the line of relinearization, i can't go to higher iterations compared to the snippet with the line in question. So , i think that relinearization is working fine. But how can we go to higher number of possible iterations, i set the poly_modulos_degree to 16384, and i got 32 possible multiplications, if i want for example 100 iterations, how can i do it , any suggestions ?
the noise budget before and after the relinearization remain the same
This looks expected. Relinearization helps reducing encrypted_resultt.size() back to 2. It helps save noise budget in the long run but might not increase noise budget instantly.
but how can we go to higher number of possible iterations
There are a number of things that you can try:
- Instead of multiplying in a serial pattern, use a balanced multiplicative tree.
- Using
encrypt_symmetricinstead ofencryptcan help if you only need symmetric encryption. - Reducing
plain_modulus. - At last, you can always increase
poly_modulus_degreeandcoeff_modulus.