nucypher / nufhe

NuCypher fully homomorphic encryption (NuFHE) library implemented in Python
https://nufhe.readthedocs.io/en/latest/
GNU General Public License v3.0
441 stars 53 forks source link

Readme test doesn't pass #16

Open seniorjoinu opened 5 years ago

seniorjoinu commented 5 years ago

Problem

Usage example test doesn't pass

Steps to reproduce

python examples/gate_nand.py

Environment

nuFHE 0.0.2 python 3.6 ubuntu 18.04

Details

I've also printed out some variables when size = 4

bits1 = [True, True, False, True]
bits2 = [True, False, True, True]
bits1 NAND bits2 = [False, True, True, False]
decrypted_bits1 GATE_NAND decrypted_bits2 = [True, True, True, True]
fjarri commented 5 years ago

What videocard and platform (CUDA/OpenCL) do you use?

Could you run the tests for the package? You'll have to clone the repo, install py.test and run

py.test -v -m "not perf"

(the last option skips performance tests which take a lot of time)

seniorjoinu commented 5 years ago

I'm using OpenCL with Intel Corporation Xeon E3-1200 v5/v6 / E3-1500 v5 / 6th/7th Gen Core Processor Gaussian Mixture Model. OpenCL runtime was installed from here: https://github.com/intel/compute-runtime/releases/tag/19.15.12831

Here's complete pytest output: https://pastebin.com/eEC2HDnH

fjarri commented 5 years ago

So, from the logs it seems that:

Therefore, for a workaround you can use transform_type="FFT" as a keyword to NuFHEParameters, Context.make_secret_key() or Context.make_key_pair.

As for the reasons for the error, it's hard to say without debugging on a machine with this specific device and drivers. Based on my previous experience with OpenCL implementations, I would guess it's the driver compiling some code construct incorrectly. Most of OpenCL drivers I've seen are surprisingly buggy, the only exception being (ironically) the nVidia one.

The way to debug it would be to take the kernel producing incorrect results (the one from TGswTransformedExternalMul in this case) and progressively simplify it, checking if the bug is still there (by comparing it with the reference code simplified accordingly).

I will leave this open in case I manage to get my hands on a Xeon.

seniorjoinu commented 5 years ago

Thank you. I'm able to pass gate_nand.py now.