microsoft / SEAL

Microsoft SEAL is an easy-to-use and powerful homomorphic encryption library.
https://www.microsoft.com/en-us/research/group/cryptography-research/
MIT License
3.51k stars 700 forks source link

Issue with reliniarization to compute a geometric serie #539

Open abdell0000 opened 2 years ago

abdell0000 commented 2 years ago

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 ?

WeiDaiWD commented 2 years ago

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: