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

BGV with m a power of two #445

Open n-samar opened 3 years ago

n-samar commented 3 years ago

Running the following within utils/bin:

./create-context ~/bgv.txt --bootstrap THICK

where ~/bgv.txt contains:

p=257
m=32768
r=1
c=2
Qbits=400
mvec=[32768]
gens=[16383,3]
ords=[2,64]

gives an error:

Could not parse params file: '~/bgv2.txt'. Not a valid value '[16383,3]'

I suspect this error is triggered because mvec has length equal to one, while gens has length equal to two. Nonetheless, these parameters seem correct. Specifically, the quotient field Z^*_m/(p) actually has two generators (because m is a power of two), yet mvec cannot contain more than one value, because its only devisor is two. This means gens should be bigger than mvec in this case.

One way to go around this is to set p so that Z^*_m/(p) has exactly one generator. However, that generator will have to be -1 (i.e. the "other" generator of Z^*_m). This means that Z^*_m/(p) = Z_2 and thus |Z^*_m/(p)|=2, meaning we have only two plaintext slots to work with. I would like to work with more than two slots.

What is the right way of getting a BGV context with m a power of two?