PyCrCNN icon indicating copy to clipboard operation
PyCrCNN copied to clipboard

Encryption parameters are not set correctly

Open nrakurniawan opened this issue 3 years ago • 6 comments

Hi, I try to run your example code of HE-ML_CKKS.ipynb

encryption_parameters = { 'm': n, # For CKKS, n/2 values can be encoded in a single ciphertext 'scale': 2**scale_power, # Each multiplication grows the final scale 'qi': [34]+ [scale_power]*n_mults +[34] # One intermdiate for each multiplication }

HE_Client = CKKSPyfhel(**encryption_parameters) HE_Client.generate_keys() HE_Client.generate_relin_keys()

got this errors:

Exception ignored in: 'Pyfhel.Pyfhel.Pyfhel.keyGen' Traceback (most recent call last): File "../pycrcnn/he/HE.py", line 221, in generate_keys ValueError: encryption parameters are not set correctly

I have tried to change the parameters setting: n_mults, n, scale_power, it did not works. How to solve this problem?

I'm using Pyfhel version 3.3.0

Thanks before

nrakurniawan avatar Oct 14 '22 06:10 nrakurniawan

Hi nrakurniawan,

We are sorry for these bugs, we have interesting plans for PyCrCNN but it still needs some work. However, I've fixed the problem you faced. Now the notebook should work.

Please note that you need to install Pyfhel with the SEAL_THROW_ON_TRANSPARENT_CIPHERTEXT flag set to off. You can read about this here: https://github.com/ibarrond/Pyfhel/issues/124

It's not difficult, though. You just need to clone Pyfhel in local (as shown in their readme file), change the flag in pyproject.toml, and install it.

AlexMV12 avatar Oct 14 '22 09:10 AlexMV12

Hi AlexMV12, Thank you for your reply and explanation.

I tried to install the Pyfhel library with SEAL_THROW_ON_TRANSPARENT_CIPHERTEXT flag set to OFF.

I got the following error, do you know how to solve it? Thanks before.

Processing /home/hendra/Pyfhel-master
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting numpy==1.21
  Using cached numpy-1.21.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.7 MB)
Building wheels for collected packages: Pyfhel
  Building wheel for Pyfhel (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for Pyfhel (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [18 lines of output]
      running bdist_wheel
      running build
      running build_py
      copying Pyfhel/__init__.py -> build/lib.linux-x86_64-3.8/Pyfhel
      running build_clib
      building 'SEAL' cmake-based library
      CMake Error: The source directory "/home/hendra/Pyfhel-master/Pyfhel/backend/SEAL" does not appear to contain CMakeLists.txt.
      Specify --help for usage, or press the help button on the CMake GUI.
      Error: could not load cache
      building 'Afhel' shared library
      gcc -pthread -B /home/hendra/anaconda3/envs/pyfhel/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/hendra/Pyfhel-master/Pyfhel/Afhel -I/home/hendra/Pyfhel-master/build/temp.linux-x86_64-3.8/Pyfhel/SEAL/native/src -I/home/hendra/Pyfhel-master/Pyfhel/backend/SEAL/native/src -I/home/hendra/Pyfhel-master/Pyfhel/backend/SEAL/thirdparty/msgsl-src/include -c /home/hendra/Pyfhel-master/Pyfhel/Afhel/Afseal.cpp -o build/temp.linux-x86_64-3.8/home/hendra/Pyfhel-master/Pyfhel/Afhel/Afseal.o -std=c++17 -O3 -fopenmp
      cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
      In file included from /home/hendra/Pyfhel-master/Pyfhel/Afhel/Afseal.cpp:32:0:
      /home/hendra/Pyfhel-master/Pyfhel/Afhel/Afseal.h:47:10: fatal error: seal/dynarray.h: No such file or directory
       #include "seal/dynarray.h"
                ^~~~~~~~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for Pyfhel
Failed to build Pyfhel
ERROR: Could not build wheels for Pyfhel, which is required to install pyproject.toml-based projects

nrakurniawan avatar Oct 17 '22 10:10 nrakurniawan

When you cloned Pyfhel, did you do it with git clone --recursive https://github.com/ibarrond/Pyfhel.git ?

AlexMV12 avatar Oct 17 '22 12:10 AlexMV12

Previously I just download and install it. Now, I tried to clone the Pyfhel with git clone --recursive https://github.com/ibarrond/Pyfhel.git, and get this error. I installed it on WSL2 (under Windows 11).

[100%] Building CXX object CMakeFiles/seal.dir/native/src/seal/util/ztools.cpp.o
      [100%] Linking CXX static library lib/libseal-3.7.a
      [100%] Built target seal
      building 'Afhel' shared library
      creating build/temp.linux-aarch64-3.9/workspaces
      creating build/temp.linux-aarch64-3.9/workspaces/Pyfhel
      creating build/temp.linux-aarch64-3.9/workspaces/Pyfhel/Pyfhel
      creating build/temp.linux-aarch64-3.9/workspaces/Pyfhel/Pyfhel/Afhel
      gcc -pthread -B /opt/conda/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -n1 .2-a+fp16+rcpc+dotprod+crypto -isystem /opt/conda/include -I/opt/conda/include -fPIC -O2 -n1 .2-a+fp16+rcpc+dotprod+crypto -isystem /opt/conda/include -fPIC -I/workspaces/Pyfhel/Pyfhel/Afhel -I/workspaces/Pyfhel/build/temp.linux-aarch64-3.9/Pyfhel/SEAL/native/src -I/workspaces/Pyfhel/Pyfhel/backend/SEAL/native/src -I/workspaces/Pyfhel/Pyfhel/backend/SEAL/thirdparty/msgsl-src/include -c /workspaces/Pyfhel/Pyfhel/Afhel/Afseal.cpp -o build/temp.linux-aarch64-3.9/workspaces/Pyfhel/Pyfhel/Afhel/Afseal.o -std=c++17 -O3 -fopenmp
      gcc: error: .2-a+fp16+rcpc+dotprod+crypto: No such file or directory
      gcc: error: .2-a+fp16+rcpc+dotprod+crypto: No such file or directory
      gcc: error: unrecognized command-line option ‘-n1’; did you mean ‘-n’?
      gcc: error: unrecognized command-line option ‘-n1’; did you mean ‘-n’?
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for Pyfhel
Failed to build Pyfhel
ERROR: Could not build wheels for Pyfhel, which is required to install pyproject.toml-based projects

nrakurniawan avatar Oct 17 '22 14:10 nrakurniawan

Mhm, honestly, I don't know how to solve it. You should look at the Pyfhel repo to see if someone had this problem. Maybe you may try to use Google Colab to run the notebook.

AlexMV12 avatar Oct 17 '22 14:10 AlexMV12

Thank you for your suggestion. I will post it here if I have solved it.

nrakurniawan avatar Oct 17 '22 14:10 nrakurniawan

I have solved this issue by updating and upgrading apt-get and also updating build-essential. Thanks for your help.

nrakurniawan avatar Nov 01 '22 21:11 nrakurniawan

You're welcome! Let me know if you need anything else.

AlexMV12 avatar Nov 02 '22 09:11 AlexMV12