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.14k stars 765 forks source link

Issue while running PSI test #399

Open jatanloya opened 3 years ago

jatanloya commented 3 years ago

Environment: macOS Catalina Version: 10.15.7 (19H2)

Description: While running the ./gen-params.batx -f "generate params" command, the following error is being thrown, the script is creating a temp folder with .info,.params, .pk, .sk files. Screenshot 2020-10-20 at 5 08 08 PM

siddsh commented 3 years ago

It seems that the db13860.enc is not being created, facing the same issue.

jlhcrawford commented 3 years ago

Hi @jatanloya the reason you are seeing this error is because gen-params.batx only generates the algebra, public/secret keys as you mentioned and then encrypts any data you have (both database and query data).

However, it does not generate or encode any data for you and maybe this should have been mentioned in the README.md.

You need to provide the encoded data db13860.enc yourself. This can be done using the utilities which can be found in helib/utils. In particular there is an example encoder/decoder python script provided there. Have a look at helib/utils/README.md for more information on the usage.

Hope that helps.

jatanloya commented 3 years ago

Yep got it, I'll try encoding some data and then running the PSI test again. Thanks for the help.

jatanloya commented 3 years ago

@jlhcrawford Hello, after providing the encoded database and query I was able to generate parameters and encrypt the query and the database. Screenshot 2020-12-19 at 10 05 27 PM After running the test using DEBUG=1 bats . the following error is thrown Screenshot 2020-12-19 at 10 06 17 PM

Can you please provide a sample database, query and params for the same, will be very helpful. Thanks.

jlhcrawford commented 3 years ago

Hi @jatanloya that is an unusual error. It seems like the bats test cannot find the public key file for some reason even though you ran ./gen-params.batx. Have you double checked that the file test_bgv.pk exists and contains a public key?

In terms of an example database/query there is work on a PR that updates the serialisation and also contains an updated misc/psi/README.md with some example data.

This update should happen soon-ish however in the meantime you can have a look at the current misc/psi/README.md here https://github.com/helibproject/HElib/tree/serialization-2.0/misc/psi

Hopefully the updated documentation helps solve your problem. Let me know if you run into any additional problems.

jatanloya commented 3 years ago

Hello @jlhcrawford, the error was occuring due to a path mismatch which has been fixed.

We tried the example database & query on the given link but are not getting expected results and DEBUG=1 bats . also shows failure. The output are large number of random digits.

It seems that the problem is due to inappropiate parameters like nslots, n, p & m. Can you suggest these values and perhpaps tell us how to calculate them for any given data?

Also are there any resources that will have more details on how to structure data into rows and columns for the database and the query?

jlhcrawford commented 3 years ago

If you are getting numbers that can't be represented with the current parameters then you need to increase p to a prime number larger than the largest number you want to be represented.

In terms of the scoring test this will be the final answer. To see what that number is there is a python script gen-expected-mask.py that does the same operations in the clear.

Finding the p that gives you the same nslots = phi(m)/d can be tricky as it is determined by d in the equation p^d mod m == 1.

What parameters are you using in the gen-params.batx script?

The example data I provided is intended to work with "toy parameters". So nslots = 3, p = 13 etc. the function that generates these parameters is create-toy-lookup-params in gen-params.batx so if you comment out line 88 and uncomment line 87 then you can use the "toy parameters".

Note: when making the above change, ensure that the variables modulus and nslots in scoring.bats and lookup.bats are the same as the p and nslots generated in the test_bgv.info file.