homenc / HElib

HElib is an open-source software library that implements homomorphic encryption. It supports the BGV scheme with bootstrapping and the Approximate Number CKKS scheme. HElib also includes optimizations for efficient homomorphic evaluation, focusing on effective use of ciphertext packing techniques and on the Gentry-Halevi-Smart optimizations.
https://homenc.github.io/HElib
Other
3.11k stars 760 forks source link

problems about BuildModChain in helib #278

Open sarah0813 opened 5 years ago

sarah0813 commented 5 years ago

Hi, everyone! I met a strange error with helib.

  1. If I setup up the parameter m,p as follows (without using FindM): m=32768, p=1021, L=27 or L=28, I am getting the following error happening in BuildModChain funciton.

################################################ FHEContext.cpp:250: double AddManyPrimes(FHEcontext&, double, bool, bool): Assertion `twoM > (long)context.zMStar.getM()' failed. ################################################

2.On the other hand, if I setup up parameters m=32768,p=1021, L<=26 or L>=29, no errors occur.

Why does L=27 or L=28 result in the incorrect result ? Why does a larger or smaller level L lead to a correct result? Any suggestions whould be highly appreciated.

boev commented 5 years ago

Hey sarah,

I am fairly new to HElib, but using p=1021 is not really practical. With such large p the noise growth increases fast. Also initializing context would require a lot of time. Instead try p=2 and r=10 meaning your modulus would be 1024. Would you please tell me what your computation aim at, so I can help a bit with parameters and suggestions. Also I think L parameter has to be significantly higher. Maybe 300-600.