Huelse / SEAL-Python

Microsoft SEAL 4.X For Python
MIT License
310 stars 66 forks source link

EncryptionParameters setup problem #56

Closed lidh15 closed 3 years ago

lidh15 commented 3 years ago

Hi, I was using BFV with the following setup: ` parms = EncryptionParameters(scheme_type.bfv)

poly_modulus_degree = 2048

parms.set_poly_modulus_degree(poly_modulus_degree)

parms.set_coeff_modulus(CoeffModulus.Create(poly_modulus_degree, [27, 27])) ` My encrypted numbers take part into only addition, no multiplication, so I set two coefficient modulus. Everything was fine, but I still want to make it faster so I cut the poly_modulus_degree to 1024, and I think that means I have to change coefficient modulus from 27, 27 to 13, 13. And then it threw logit error: failed to find enough qualifying primes But I cannot increase that coefficient modulus bit length, right? 14+14=28>27 In the example code 1_bfv_basics.cpp Microsoft said 1024 was a legal poly_modulus_degree, I just wonder how to use it, or Microsoft made a mistake?

Huelse commented 3 years ago

The program is right, it is too small to find enough valid primes, you can use decryptor.invariant_noise_budget(x_encrypted) to get the noise budget. If the poly_modulus_degree is 1024, there is only 6, 6 <<13, but 2048 has 32, large more. By default, I recommend you use CoeffModulus.BFVDefault(poly_modulus_degree) to init the bfv params, it will easily work well.

lidh15 commented 3 years ago

well, I used default coefficient modulus for 1024, printed it I found that it simply set only one coefficient modulus size as 27, and that makes the decryption result a polynomial rather than a number so I think that means I cannot do addition with this setup so I have to use 2048, thank you