kimandrik / IDASH2017

Other
25 stars 10 forks source link

Division by zero when running examples #9

Open davidmerand opened 3 years ago

davidmerand commented 3 years ago

Hi, I built the software successfully but get the following error: Start Enc NLGD division by zero in _ntl_gdiv

It occurs just after the "enc NLGD" message in iteration 5 of the first example in your Readme. Versions of software are: NTL 11.4.3 and GMP 6.2.0 - on both Manjaro 5.10.2 and Kubuntu 20.04 (different machines)

If I reduce the polynomial degree from 5 to 3 I get a few iterations further If I try an example with a larger dataset, I get a few iterations further. I see that the logq values are decreasing, they get to 168 before the crash.

Do you have any ideas as to an approach to solve this. Many thanks

kimandrik commented 3 years ago

Hello, there is no bootstrapping in this example, and at each iteration logq decreases so we are limited in number of iterations. To be able to do as many iterations as you want you have to do bootstrapping every several iterations. Maybe you can also take a look at https://github.com/KyoohyungHan/HELR

davidmerand commented 3 years ago

Many thanks for your feedback. I am exploring the bootstrapping in the above mentioned repository. Can you please explain to me how one can evaluate when bootstrapping is required. You say "every several iterations". Can you be more explicit? I am struggling to get to grips with the theory so would appreciate your help in this regard.

kimandrik commented 3 years ago

Every iteration reduces the ciphertext modulus by some logT bits. If the initial modulus is logQ, then after first iteration we have logQ - logT modulus bits, after second logQ - 2logT modulus bits, etc. We can do about logQ/logT iterations. But we cannot have number of modulus bits of ciphertext too small, so we need to keep the modulus higher than some threshold (60 bits is always enough). Then the number of iterations before bootstrapping is (logQ - 60)/logT.