Giter VIP home page Giter VIP logo

openfhe-python's Introduction

Official Python wrapper for OpenFHE

Table of Contents

Running from Docker

Please see Instructions for the Docker setup

Building from Source

Requirements

Before building, make sure you have the following dependencies installed:

We recommend following OpenFHE C++ installation instructions first (which covers Linux, Windows and MacOS) and then getting back to this repo. See notes on installing pybind11 below

Linux

System-level installation

To install OpenFHE-python directly to your system, ensure the dependencies are set up. Then clone the repository, open a terminal in the repo folder and run the following commands:

pip install "pybind11[global]" 
mkdir build
cd build
cmake ..  # Alternatively, cmake .. -DOpenFHE_DIR=/path/to/installed/openfhe if you installed OpenFHE elsewhere
make
make install  # You may have to run sudo make install

At this point the .so file has been built. Your exact installation process will depend on your virtual environment. Cmake will automatically find the python installation path, if unwanted, you can specify the python path by adding -DPYTHON_EXECUTABLE_PATH=/path/to/python to the cmake command.

If you see an error saying that one of OpenFHE .so files cannot be found when running a Python example (occurs only for some environments), add the path where the .so files reside to the PYTHONPATH environment variable:

export PYTHONPATH=(path_to_OpenFHE_so_files):$PYTHONPATH

In some environments (this happens rarely), it may also be necessary to add the OpenFHE libraries path to LD_LIBRARY_PATH.

Conda

Alternatively you can install the library and handle the linking via Conda. Clone the repository, open a terminal in the repo folder and run the following commands:

conda create -n ${ENV_NAME} python=3.{X} anaconda

where ${ENV_NAME} should be replaced with the name of your environment, and {X} should be replaced with your desired python version. For example you might have conda create -n openfhe_python python=3.9 anaconda. Now, you would install pybind11 either via:

pip install "pybind11[global]" or via conda install -c conda-forge pybind11, but for now we recommend using the first method, with pip. Some users have reported issues when using the conda pybind11

Now, you would clone the repository, and run the following commands to install :

mkdir build
cd build
cmake .. # Add in -DOpenFHE_DIR=/path/to/installed/openfhe if you installed OpenFHE elsewhere
make
make install  # You may have to run sudo make install

Then, you can develop the library to link

cd ..
mkdir lib
mv *.so lib
conda develop lib

which creates a lib folder, moves the built .so file into that lib folder, and tells conda where to look for external libraries.

Note You may wish to copy the .so file to any projects of your own, or add it to your system path to source from.

Running Tests

Run tests with pytest, which may be called pytest-3 on your system. See the testing readme for more information.

pytest [--run-long]

Code Examples

To get familiar with the OpenFHE Python API, check out the examples:

OpenFHE Python Wrapper Documentation

OpenFHE Python Wrapper API Reference

Contributing Guide

OpenFHE Development - Contributing Guide

openfhe-python's People

Contributors

adolgert avatar arcturusannamalai avatar dsuponitskiy-duality avatar g-arakelov avatar gpujana avatar ianqs avatar iquah1 avatar mctriplett avatar reneroliveira avatar sei-adolgert avatar thadah avatar yspolyakov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

openfhe-python's Issues

Failed when building openfhe-python

I have got some errors when building openfhe-python.
My environments:

  • OS: Ubuntu 20.04
  • CMake 3.16.3
  • OpenFHE v1.0.4
  • pybind11 2.11.1

The error I got is shown as follow:

spinal@f4a34a602339:~/Software/openfhe-python/build$ make -j32
Scanning dependencies of target openfhe
[ 16%] Building CXX object CMakeFiles/openfhe.dir/src/lib/bindings.cpp.o
[ 33%] Building CXX object CMakeFiles/openfhe.dir/src/lib/binfhe_bindings.cpp.o
[ 50%] Building CXX object CMakeFiles/openfhe.dir/src/lib/binfhe/binfhecontext_wrapper.cpp.o
[ 66%] Building CXX object CMakeFiles/openfhe.dir/src/lib/pke/serialization.cpp.o
[ 83%] Building CXX object CMakeFiles/openfhe.dir/src/lib/pke/cryptocontext_wrapper.cpp.o
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp: In function ‘void bind_binfhe_enums(pybind11::module&)’:
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:45:51: error: ‘STD128_LMKCDEY’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   45 |         .value("STD128_LMKCDEY", BINFHE_PARAMSET::STD128_LMKCDEY)
      |                                                   ^~~~~~~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:51:52: error: ‘STD128Q_LMKCDEY’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   51 |         .value("STD128Q_LMKCDEY", BINFHE_PARAMSET::STD128Q_LMKCDEY)
      |                                                    ^~~~~~~~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:54:45: error: ‘STD128_3’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   54 |         .value("STD128_3", BINFHE_PARAMSET::STD128_3)
      |                                             ^~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:55:53: error: ‘STD128_3_LMKCDEY’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   55 |         .value("STD128_3_LMKCDEY", BINFHE_PARAMSET::STD128_3_LMKCDEY)
      |                                                     ^~~~~~~~~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:56:46: error: ‘STD128Q_3’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   56 |         .value("STD128Q_3", BINFHE_PARAMSET::STD128Q_3)
      |                                              ^~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:57:54: error: ‘STD128Q_3_LMKCDEY’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   57 |         .value("STD128Q_3_LMKCDEY", BINFHE_PARAMSET::STD128Q_3_LMKCDEY)
      |                                                      ^~~~~~~~~~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:58:46: error: ‘STD192Q_3’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   58 |         .value("STD192Q_3", BINFHE_PARAMSET::STD192Q_3)
      |                                              ^~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:59:46: error: ‘STD256Q_3’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   59 |         .value("STD256Q_3", BINFHE_PARAMSET::STD256Q_3)
      |                                              ^~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:60:45: error: ‘STD128_4’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   60 |         .value("STD128_4", BINFHE_PARAMSET::STD128_4)
      |                                             ^~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:61:53: error: ‘STD128_4_LMKCDEY’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   61 |         .value("STD128_4_LMKCDEY", BINFHE_PARAMSET::STD128_4_LMKCDEY)
      |                                                     ^~~~~~~~~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:62:46: error: ‘STD128Q_4’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   62 |         .value("STD128Q_4", BINFHE_PARAMSET::STD128Q_4)
      |                                              ^~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:63:54: error: ‘STD128Q_4_LMKCDEY’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   63 |         .value("STD128Q_4_LMKCDEY", BINFHE_PARAMSET::STD128Q_4_LMKCDEY)
      |                                                      ^~~~~~~~~~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:64:46: error: ‘STD192Q_4’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   64 |         .value("STD192Q_4", BINFHE_PARAMSET::STD192Q_4)
      |                                              ^~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:65:46: error: ‘STD256Q_4’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   65 |         .value("STD256Q_4", BINFHE_PARAMSET::STD256Q_4)
      |                                              ^~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:69:58: error: ‘STD128_LMKCDEY’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   69 |     m.attr("STD128_LMKCDEY") = py::cast(BINFHE_PARAMSET::STD128_LMKCDEY);
      |                                                          ^~~~~~~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:75:59: error: ‘STD128Q_LMKCDEY’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   75 |     m.attr("STD128Q_LMKCDEY") = py::cast(BINFHE_PARAMSET::STD128Q_LMKCDEY);
      |                                                           ^~~~~~~~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:78:52: error: ‘STD128_3’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   78 |     m.attr("STD128_3") = py::cast(BINFHE_PARAMSET::STD128_3);
      |                                                    ^~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:79:60: error: ‘STD128_3_LMKCDEY’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   79 |     m.attr("STD128_3_LMKCDEY") = py::cast(BINFHE_PARAMSET::STD128_3_LMKCDEY);
      |                                                            ^~~~~~~~~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:80:53: error: ‘STD128Q_3’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   80 |     m.attr("STD128Q_3") = py::cast(BINFHE_PARAMSET::STD128Q_3);
      |                                                     ^~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:81:61: error: ‘STD128Q_3_LMKCDEY’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   81 |     m.attr("STD128Q_3_LMKCDEY") = py::cast(BINFHE_PARAMSET::STD128Q_3_LMKCDEY);
      |                                                             ^~~~~~~~~~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:82:53: error: ‘STD192Q_3’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   82 |     m.attr("STD192Q_3") = py::cast(BINFHE_PARAMSET::STD192Q_3);
      |                                                     ^~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:83:53: error: ‘STD256Q_3’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   83 |     m.attr("STD256Q_3") = py::cast(BINFHE_PARAMSET::STD256Q_3);
      |                                                     ^~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:84:52: error: ‘STD128_4’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   84 |     m.attr("STD128_4") = py::cast(BINFHE_PARAMSET::STD128_4);
      |                                                    ^~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:85:60: error: ‘STD128_4_LMKCDEY’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   85 |     m.attr("STD128_4_LMKCDEY") = py::cast(BINFHE_PARAMSET::STD128_4_LMKCDEY);
      |                                                            ^~~~~~~~~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:86:53: error: ‘STD128Q_4’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   86 |     m.attr("STD128Q_4") = py::cast(BINFHE_PARAMSET::STD128Q_4);
      |                                                     ^~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:87:61: error: ‘STD128Q_4_LMKCDEY’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   87 |     m.attr("STD128Q_4_LMKCDEY") = py::cast(BINFHE_PARAMSET::STD128Q_4_LMKCDEY);
      |                                                             ^~~~~~~~~~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:88:53: error: ‘STD192Q_4’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   88 |     m.attr("STD192Q_4") = py::cast(BINFHE_PARAMSET::STD192Q_4);
      |                                                     ^~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:89:53: error: ‘STD256Q_4’ is not a member of ‘lbcrypto::BINFHE_PARAMSET’
   89 |     m.attr("STD256Q_4") = py::cast(BINFHE_PARAMSET::STD256Q_4);
      |                                                     ^~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:100:15: error: ‘KEYGEN_MODE’ was not declared in this scope
  100 |     py::enum_<KEYGEN_MODE>(m, "KEYGEN_MODE")
      |               ^~~~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:100:26: error: template argument 1 is invalid
  100 |     py::enum_<KEYGEN_MODE>(m, "KEYGEN_MODE")
      |                          ^
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:101:31: error: ‘KEYGEN_MODE’ is not a class, namespace, or enumeration
  101 |         .value("SYM_ENCRYPT", KEYGEN_MODE::SYM_ENCRYPT)
      |                               ^~~~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:102:31: error: ‘KEYGEN_MODE’ is not a class, namespace, or enumeration
  102 |         .value("PUB_ENCRYPT", KEYGEN_MODE::PUB_ENCRYPT);
      |                               ^~~~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:103:38: error: ‘KEYGEN_MODE’ is not a class, namespace, or enumeration
  103 |     m.attr("SYM_ENCRYPT") = py::cast(KEYGEN_MODE::SYM_ENCRYPT);
      |                                      ^~~~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:104:38: error: ‘KEYGEN_MODE’ is not a class, namespace, or enumeration
  104 |     m.attr("PUB_ENCRYPT") = py::cast(KEYGEN_MODE::PUB_ENCRYPT);
      |                                      ^~~~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp: In function ‘void bind_binfhe_context(pybind11::module&)’:
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:164:38: error: ‘SYM_ENCRYPT’ was not declared in this scope
  164 |              py::arg("keygenMode") = SYM_ENCRYPT)
      |                                      ^~~~~~~~~~~
/home/spinal/Software/openfhe-python/src/lib/binfhe_bindings.cpp:178:141: error: invalid static_cast from type ‘lbcrypto::LWECiphertext (lbcrypto::BinFHEContext::*)(lbcrypto::BINGATE, ConstLWECiphertext, ConstLWECiphertext) const’ {aka ‘std::shared_ptr<lbcrypto::LWECiphertextImpl> (lbcrypto::BinFHEContext::*)(lbcrypto::BINGATE, std::shared_ptr<const lbcrypto::LWECiphertextImpl>, std::shared_ptr<const lbcrypto::LWECiphertextImpl>) const’} to type ‘lbcrypto::LWECiphertext (lbcrypto::BinFHEContext::*)(lbcrypto::BINGATE, lbcrypto::ConstLWECiphertext&, lbcrypto::ConstLWECiphertext&) const’ {aka ‘std::shared_ptr<lbcrypto::LWECiphertextImpl> (lbcrypto::BinFHEContext::*)(lbcrypto::BINGATE, const std::shared_ptr<const lbcrypto::LWECiphertextImpl>&, const std::shared_ptr<const lbcrypto::LWECiphertextImpl>&) const’}
  178 |         static_cast<LWECiphertext (BinFHEContext::*)(BINGATE, ConstLWECiphertext &, ConstLWECiphertext &) const>(&BinFHEContext::EvalBinGate),
      |                                                                                                                                             ^
make[2]: *** [CMakeFiles/openfhe.dir/build.make:76: CMakeFiles/openfhe.dir/src/lib/binfhe_bindings.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/openfhe.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Serialization not working in macOS

While running openfhe-python/examples/pke/simple-integers-serial.py

RuntimeError: Trying to save an unregistered polymorphic type (lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint>>>).
Make sure your type is registered with CEREAL_REGISTER_TYPE and that the archive you are using was included (and registered with CEREAL_REGISTER_ARCHIVE) prior to calling CEREAL_REGISTER_TYPE.
If your type is already registered and you still see this error, you may need to use CEREAL_REGISTER_DYNAMIC_INIT.

Environment: Prepared a Conda environment on Apple M2 Pro, and able to run other examples.

However, it worked for me, in Linux environment.

installation error

cmake is successfull

When I try to make the project, I met these problem,how can I solve it?

pavanr@central-server:~/Downloads/openfhe-python/build$ cmake .. -DPYTHON_EXECUTABLE_PATH=/usr/bin/python3 -Dpybind11_DIR=/home/pavanr/.local/lib/python3.8/site-packages/pybind11/share/cmake/pybind11 -DOpenFHE_DIR=/usr/local/include/openfhe
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3.6")
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.8.so
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- Found pybind11: /home/pavanr/.local/lib/python3.8/site-packages/pybind11/include (found version "2.11.1")
-- Python site packages directory: /usr/lib/python3/dist-packages
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pavanr/Downloads/openfhe-python/build
pavanr@central-server:~/Downloads/openfhe-python/build$ make
Scanning dependencies of target openfhe
[ 16%] Building CXX object CMakeFiles/openfhe.dir/src/lib/bindings.cpp.o
In file included from /home/pavanr/Downloads/openfhe-python/src/lib/bindings.cpp:1:
/home/pavanr/.local/lib/python3.8/site-packages/pybind11/include/pybind11/pybind11.h: In instantiation of ‘void pybind11::cpp_function::initialize(Func&&, Return (*)(Args ...), const Extra& ...) [with Func = pybind11::cpp_function::cpp_function(Return (Class::*)(Arg ...), const Extra& ...) [with Return = void; Class = lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > >; Arg = {std::vector<unsigned int, std::allocator<unsigned int> >, std::vector<unsigned int, std::allocator<unsigned int> >, unsigned int, unsigned int, bool}; Extra = {pybind11::name, pybind11::is_method, pybind11::sibling, const char*, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v}]::<lambda(lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > >*, std::vector<unsigned int>, std::vector<unsigned int>, unsigned int, unsigned int, bool)>; Return = void; Args = {lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > >*, std::vector<unsigned int, std::allocator<unsigned int> >, std::vector<unsigned int, std::allocator<unsigned int> >, unsigned int, unsigned int, bool}; Extra = {pybind11::name, pybind11::is_method, pybind11::sibling, const char*, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v}]’:
/home/pavanr/.local/lib/python3.8/site-packages/pybind11/include/pybind11/pybind11.h:110:9:   required from ‘pybind11::cpp_function::cpp_function(Return (Class::*)(Arg ...), const Extra& ...) [with Return = void; Class = lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > >; Arg = {std::vector<unsigned int, std::allocator<unsigned int> >, std::vector<unsigned int, std::allocator<unsigned int> >, unsigned int, unsigned int, bool}; Extra = {pybind11::name, pybind11::is_method, pybind11::sibling, const char*, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v}]’
/home/pavanr/.local/lib/python3.8/site-packages/pybind11/include/pybind11/pybind11.h:1575:22:   required from ‘pybind11::class_<type_, options>& pybind11::class_<type_, options>::def(const char*, Func&&, const Extra& ...) [with Func = void (lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > >::*)(std::vector<unsigned int>, std::vector<unsigned int>, unsigned int, unsigned int, bool); Extra = {const char*, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v}; type_ = lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > >; options = {std::shared_ptr<lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > > >}]’
/home/pavanr/Downloads/openfhe-python/src/lib/bindings.cpp:587:45:   required from here
/home/pavanr/.local/lib/python3.8/site-packages/pybind11/include/pybind11/pybind11.h:219:40: error: static assertion failed: The number of argument annotations does not match the number of function arguments
  219 |             expected_num_args<Extra...>(
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~^
  220 |                 sizeof...(Args), cast_in::args_pos >= 0, cast_in::has_kwargs),
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/pavanr/.local/lib/python3.8/site-packages/pybind11/include/pybind11/attr.h:14,
                 from /home/pavanr/.local/lib/python3.8/site-packages/pybind11/include/pybind11/detail/class.h:12,
                 from /home/pavanr/.local/lib/python3.8/site-packages/pybind11/include/pybind11/pybind11.h:13,
                 from /home/pavanr/Downloads/openfhe-python/src/lib/bindings.cpp:1:
/home/pavanr/.local/lib/python3.8/site-packages/pybind11/include/pybind11/cast.h:1453:57: error: ‘std::enable_if_t<std::is_void<_Yp>::value, pybind11::detail::void_type> pybind11::detail::argument_loader<Args>::call(Func&&) && [with Return = void; Guard = pybind11::detail::void_type; Func = pybind11::cpp_function::cpp_function(Return (Class::*)(Arg ...), const Extra& ...) [with Return = void; Class = lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > >; Arg = {std::vector<unsigned int, std::allocator<unsigned int> >, std::vector<unsigned int, std::allocator<unsigned int> >, unsigned int, unsigned int, bool}; Extra = {pybind11::name, pybind11::is_method, pybind11::sibling, const char*, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v}]::<lambda(lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > >*, std::vector<unsigned int>, std::vector<unsigned int>, unsigned int, unsigned int, bool)>&; Args = {lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > >*, std::vector<unsigned int, std::allocator<unsigned int> >, std::vector<unsigned int, std::allocator<unsigned int> >, unsigned int, unsigned int, bool}; std::enable_if_t<std::is_void<_Yp>::value, pybind11::detail::void_type> = pybind11::detail::void_type]’, declared using local type ‘pybind11::cpp_function::cpp_function(Return (Class::*)(Arg ...), const Extra& ...) [with Return = void; Class = lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > >; Arg = {std::vector<unsigned int, std::allocator<unsigned int> >, std::vector<unsigned int, std::allocator<unsigned int> >, unsigned int, unsigned int, bool}; Extra = {pybind11::name, pybind11::is_method, pybind11::sibling, const char*, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v}]::<lambda(lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > >*, std::vector<unsigned int>, std::vector<unsigned int>, unsigned int, unsigned int, bool)>’, is used but never defined [-fpermissive]
 1453 |     enable_if_t<std::is_void<Return>::value, void_type> call(Func &&f) && {
      |                                                         ^~~~
make[2]: *** [CMakeFiles/openfhe.dir/build.make:63: CMakeFiles/openfhe.dir/src/lib/bindings.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/openfhe.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Additional information

Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.6 LTS
Release:	20.04
Codename:	focal

Pycharm IDE autocompletion

I tried installing openfhe-python both on system-level linux and in Conda environment, then setting the pycharm workspace with that interpreter. The files run without errors, however pycharm doesn't recognize the library, hence autocompletion doesn't work properly.
image

windows issue

Hi,

Can openfhe and openfhe-python be installed on windows like Win10?

BR

Install issue on Linux Ubuntu

Hi all! These are the exact commands I'm running:

Installation

Installing Openfhe-dev

git clone [email protected]:openfheorg/openfhe-development.git
cd openfhe-development
mkdir build
cd build
make -j N  # number of processors - 26 in my case
sudo make install

I then verify that it is installed by running

cd bin/examples/pke
./simple-real-numbers

Installing OpenFHE-python (within a conda env)

git clone [email protected]:openfheorg/openfhe-python.git
cd openfhe-python
mkdir build
cd build
cmake .. -DPYTHON_EXECUTABLE_PATH=$CONDA_PREFIX/bin/python
make -j 26
sudo make install

then, within build, I run

mkdir lib
mv *.so lib
conda develop lib

I have verified that Openfhe-python's SO files have been "linked"

import sys
for p in sys.path:
    print(p)

which outputs

/home/iq/anaconda3/lib/python311.zip
/home/iq/anaconda3/lib/python3.11
/home/iq/anaconda3/lib/python3.11/lib-dynload
/home/iq/anaconda3/lib/python3.11/site-packages
/home/iq/openfhe-python/build/lib

The issue

When I run something like python function-evaluation.py I see

File "/home/iq/openfhe-python/examples/pke/function-evaluation.py", line 1, in <module>
    from openfhe import *
ImportError: libOPENFHEpke.so.1: cannot open shared object file: No such file or directory

It's not clear to me what the issue is and if it is an issue on the OpenFHE-dev end. I don't think it is, just because I managed to run an example specifically a PKE example


Additional Information

Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:        22.04
Codename:       jammy

Segmentation Fault on GenerateLUTViaFunction

When trying to run FuncViaSchemeSwitching function from scheme-swithing.py example, the code apparently runs fine, but it throws a segmentation fault at the end.
image

By debugging it, the cause of the problem is at the line:

lut = ccLWE.GenerateLUTviaFunction(fp, pLWE)

if i comment the rest of the code after it, segmentation fault still occurs. But if I comment also the above line, no error occurrs!

cmake error by CMakeList.txt

When I try to cmake the project, I met these problem,how can I solve it?
I use conda envs, and I have installed the pybind-global.

CMake Warning at CMakeLists.txt:14 (find_package):
  By not providing "FindOpenFHE.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "OpenFHE", but
  CMake did not find one.

  Could not find a package configuration file provided by "OpenFHE" with any
  of the following names:

    OpenFHEConfig.cmake
    openfhe-config.cmake

  Add the installation prefix of "OpenFHE" to CMAKE_PREFIX_PATH or set
  "OpenFHE_DIR" to a directory containing one of the above files.  If
  "OpenFHE" provides a separate development package or SDK, be sure it has
  been installed.


-- Found pybind11: /home/zhouchengxin/anaconda3/envs/openFHE/include (found version "2.11.1")
CMake Error at CMakeLists.txt:65 (find_package):
  By not providing "FindPython.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Python", but
  CMake did not find one.

  Could not find a package configuration file provided by "Python" with any
  of the following names:

    PythonConfig.cmake
    python-config.cmake

  Add the installation prefix of "Python" to CMAKE_PREFIX_PATH or set
  "Python_DIR" to a directory containing one of the above files.  If "Python"
  provides a separate development package or SDK, be sure it has been
  installed.

Fatal Error

Please guide me to solve this problem. I have followed all the steps to install it but getting this error.
fatal error: openfhe.h: No such file or directory
10 | #include "openfhe.h"
| ^~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/openfhe.dir/build.make:63: CMakeFiles/openfhe.dir/src/lib/bindings.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/openfhe.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

cmake issue

Hi,
Following:
image

I have below error, any ideas?

vboxuser@ubuntu18:~/openfhe-python/build$ cmake ..
-- The C compiler identification is Clang 11.1.0
-- The CXX compiler identification is Clang 11.1.0
-- Check for working C compiler: /usr/bin/clang-11
-- Check for working C compiler: /usr/bin/clang-11 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/clang++-11
-- Check for working CXX compiler: /usr/bin/clang++-11 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /usr/bin/python3.6 (found suitable version "3.6.9", minimum required is "3.6")
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.6m.so
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- Performing Test HAS_FLTO_THIN
-- Performing Test HAS_FLTO_THIN - Success
-- Found pybind11: /home/vboxuser/.local/include (found version "2.11.1")
CMake Error at CMakeLists.txt:57 (find_package):
By not providing "FindPython.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Python", but
CMake did not find one.

Could not find a package configuration file provided by "Python" with any
of the following names:

PythonConfig.cmake
python-config.cmake

Add the installation prefix of "Python" to CMAKE_PREFIX_PATH or set
"Python_DIR" to a directory containing one of the above files. If "Python"
provides a separate development package or SDK, be sure it has been
installed.

-- Configuring incomplete, errors occurred!
See also "/home/vboxuser/openfhe-python/build/CMakeFiles/CMakeOutput.log".

BR

Add Serialize() Method for Direct Binary Data Handling

Issue: Currently, the Python wrapper for OpenFHE includes the SerializeToFile() method, which allows saving ciphertext or keys into a file. However, in many projects, it is often necessary to work with binary data directly in variables for uploading to a database or for other management purposes, rather than storing it in a file.

For instance, when storing encrypted data in a database, I encountered an issue where I had to first create a file to store the data, then read the file contents to get the data into a variable, and finally use the variable to upload to the database. This process introduces unnecessary overhead and complexity.

OpenFHE Python has the potential to be a part of many complex projects, and this limitation poses a significant setback for working on large-scale projects. The overhead can be completely avoided, and it would be much easier if we had a Serialize() method, similar to the one in the C++ OpenFHE project.

Potential Solution: Implement a Serialize() method in the OpenFHE Python wrapper that allows direct serialization of ciphertext or keys into a binary data variable.

By adding this feature, we can streamline workflows and enhance the usability of OpenFHE Python for large-scale projects.

DeserializeEvalMultKey overwrites keymap content

In my application, I'm receiving CryptoContext objects from multiple origins, along with a EvalMultKey.
When "ingesting" (through DeserializeEvalMultKey) the EvalMultKeys, it seems earlier ingested keys are overridden.

A minimal example demonstrating the issue:

from openfhe import *

# NOTE:
# If running locally, you may want to replace the "hardcoded" datafolder with
# the datafolder location below which gets the current working directory
datafolder = 'demoData'

# Save-Load locations for keys
multKeyLocation1 = datafolder + '/key_mult1.txt'
multKeyLocation2 = datafolder + '/key_mult2.txt'

# Generate CC params
# Settings are arbitrarily chosen
parameters = CCParamsCKKSRNS()
parameters.SetMultiplicativeDepth(5)
parameters.SetScalingModSize(40)
parameters.SetBatchSize(32)

# Generate CC
cc = GenCryptoContext(parameters)
cc.Enable(PKE)
cc.Enable(KEYSWITCH)
cc.Enable(LEVELEDSHE)
# ... with keypair
kp1 = cc.KeyGen()
cc.EvalMultKeyGen(kp1.secretKey)   

# Generate an second, identical, context
cc2 = GenCryptoContext(parameters)
cc2.Enable(PKE)
cc2.Enable(KEYSWITCH)
cc2.Enable(LEVELEDSHE)
# ... with different keypair
kp2 = cc2.KeyGen()
cc2.EvalMultKeyGen(kp2.secretKey)    

# Encrypt some data, ONLY UNDER KP1
vec1 = [1.0, 2.0, 3.0, 4.0]
vec2 = [12.5, 13.5, 14.5, 15.5]
p1 = cc.MakeCKKSPackedPlaintext(vec1)
p2 = cc.MakeCKKSPackedPlaintext(vec2)
c1 = cc.Encrypt(kp1.publicKey, p1)
c2 = cc.Encrypt(kp1.publicKey, p2)

# Serialize the relinearlization keys of both contexts
assert CryptoContext.SerializeEvalMultKey(multKeyLocation1, BINARY, kp1.secretKey.GetKeyTag())
assert CryptoContext.SerializeEvalMultKey(multKeyLocation2, BINARY, kp2.secretKey.GetKeyTag())

# Release context, i.e. drop the relinearization keys from memory
cc.ClearEvalMultKeys()
ReleaseAllContexts()

# Deserialize the first relinearization keys
assert CryptoContext.DeserializeEvalMultKey(multKeyLocation1, BINARY)
cc.EvalMult(c1, c2) # this works, no problem

# Now, we deserialize the second key.
assert CryptoContext.DeserializeEvalMultKey(multKeyLocation2, BINARY)
cc.EvalMult(c1, c2) # raises RuntimeError

The error raised:

RuntimeError: cryptocontext.cpp:l.183:GetEvalMultKeyVector(): Call EvalMultKeyGen() to have EvalMultKey available for ID [...]

Note here that c1 and c2 were encrypted under cc. Before deserializing the EvalMultKey for cc2, there is no problem executing cc.EvalMult on these ciphertexts, but afterwards the key seems to be gone.

To further support the claim that the keys are OVERRIDDEN, I present the following code.

EXPORT_ALL_KEYS = ""
multKeyLocation3 = datafolder + '/key_mult3.txt'
assert CryptoContext.SerializeEvalMultKey(multKeyLocation3, BINARY, EXPORT_ALL_KEYS)

import hashlib
def get_digest(file):
    with open(file, 'rb') as fp:
        return hashlib.sha1(fp.read()).hexdigest()
        
print(f"keydigest CC/KP1  : {get_digest(multKeyLocation1)}")
print(f"keydigest CC2/KP2 : {get_digest(multKeyLocation2)}")
print(f"keydigest ALL_KEYS: {get_digest(multKeyLocation3)}")

When replace the statement that raised an exception with this code and execute, I see that the second and third hash that are printed are identical:

keydigest CC/KP1  : 6cdeda8a12afc1dfecb0f7724c803f6ea392a03a
keydigest CC2/KP2 : 2a18578c6db5c5056550df3e6587dc558771d89f
keydigest ALL_KEYS: 2a18578c6db5c5056550df3e6587dc558771d89f

This suggests that the second key is the only one stored.

All was executed using the latest main branches of openfhe-development and openfhe-python.

Am I doing something wrong? Any clue how I should resolve this?

how to seralize openfhe binfhecontext

from openfhe import *
import pickle5 as pickle

Sample Program: Step 1: Set CryptoContext

cc = BinFHEContext()
file_name = 'std1.pkl'

Writing the student object to a file using pickle

with open(file_name, 'wb') as file:
pickle.dump(cc, file,protocol=pickle.HIGHEST_PROTOCOL)
print(f'Object successfully saved to "{file_name}"')

openfhe-python in colab

@reneroliveira There is only Linux install in the repo. Can’t we use openfhe-python wrapper on windows?What should I do to use openfhe-python as windows user?

Missing EvalAdd functionality

EvalAdd doesn't work with ciphertext and plaintext as input. This is something mapped out in the main library but not in Python version.

Suggestions on how to install using Conda

conda develop lib command doesn't work for me after struggling for a long time.
Bugs as follows:

Channels:

 - defaults
 - conda-forge
Platform: linux-64
Collecting package metadata (repodata.json): done
Solving environment: failed
PackagesNotFoundError: The following packages are not available from current channels:
  - lib
Current channels:
  - defaults
  - https://conda.anaconda.org/conda-forge/linux-64
  - https://conda.anaconda.org/conda-forge/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
    https://anaconda.org
and use the search bar at the top of the page.

Found out using pip install -e . helps!

Pre-release changes

  1. Update README.md to better describe the installation process
  2. Move py. examples to the root, i.e.., use examples/pke and examples/binfhe.
  3. Make sure all py examples work
  4. Move include inside src. Use src/include for header files and src/lib for cpp files.

'openfhe.h' file not found by building make

Hallo
i use wsl Ubuntu 22.04
i build openfhe-development and want to build make python wrapper
my structure is:
/home/andre/openfhe-development
/home/andre/openfhe-python

i do these steps by installing:
cmake .. -Dpybind11_DIR=/home/andre/.local/lib/python3.10/site-packages/pybind11/share/cmake/pybind11
mkdir build
cd build
cmake .. -DOpenFHE_DIR=/home/andre/openfhe-development
make

but i get Error:

/home/evgen/openfhe-python/src/lib/bindings.cpp:10:10: fatal error: 'openfhe.h' file not found
#include "openfhe.h"
^~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/openfhe.dir/build.make:76: CMakeFiles/openfhe.dir/src/lib/bindings.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/openfhe.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

What can i do?

EvalKey serialization and deserialization

Our federated machine learning project involves Proxy Re-Encryption. In order to support multiple data owners and proxies, we need a way to serialize the EvalKeys, so that they can be stored and accessed by the parties involved. We also need a way to deserialize the EvalKeys from files and load them into memory, so that they can be used for re-encryption.

HEXL support: Conda Installation Failure at make

Hello,

I'm getting the error below when trying to build the python binding. I have OpenFHE installed with HEXL enabled. That works with the c++ examples, but I can't build the python binding. Based on the error, I'm not sure where to start. Any insights?

(openfhe) dangerginger@homecompute ~/code/openfhe-python/build$ make                                                                                    ✹main 
Consolidate compiler generated dependencies of target openfhe
[ 16%] Building CXX object CMakeFiles/openfhe.dir/src/lib/bindings.cpp.o
In file included from /home/dangerginger/code/openfhe-python/src/lib/bindings.cpp:1:
/home/dangerginger/code/miniconda3/envs/openfhe/include/pybind11/pybind11.h: In instantiation of ‘void pybind11::cpp_function::initialize(Func&&, Return (*)(Args ...), const Extra& ...) [with Func = pybind11::cpp_function::cpp_function<void, lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > >, std::vector<unsigned int, std::allocator<unsigned int> >, std::vector<unsigned int, std::allocator<unsigned int> >, unsigned int, unsigned int, pybind11::name, pybind11::is_method, pybind11::sibling, const char*, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v>(void (lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > >::*)(std::vector<unsigned int>, std::vector<unsigned int>, unsigned int, unsigned int), const pybind11::name&, const pybind11::is_method&, const pybind11::sibling&, const char* const&, const pybind11::arg_v&, const pybind11::arg_v&, const pybind11::arg_v&, const pybind11::arg_v&, const pybind11::arg_v&)::<lambda(lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > >*, std::vector<unsigned int>, std::vector<unsigned int>, unsigned int, unsigned int)>; Return = void; Args = {lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > >*, std::vector<unsigned int, std::allocator<unsigned int> >, std::vector<unsigned int, std::allocator<unsigned int> >, unsigned int, unsigned int}; Extra = {pybind11::name, pybind11::is_method, pybind11::sibling, const char*, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v}]’:
/home/dangerginger/code/miniconda3/envs/openfhe/include/pybind11/pybind11.h:110:19:   required from ‘pybind11::cpp_function::cpp_function(Return (Class::*)(Arg ...), const Extra& ...) [with Return = void; Class = lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > >; Arg = {std::vector<unsigned int, std::allocator<unsigned int> >, std::vector<unsigned int, std::allocator<unsigned int> >, unsigned int, unsigned int}; Extra = {pybind11::name, pybind11::is_method, pybind11::sibling, const char*, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v}]’
/home/dangerginger/code/miniconda3/envs/openfhe/include/pybind11/pybind11.h:1575:22:   required from ‘pybind11::class_<type_, options>& pybind11::class_<type_, options>::def(const char*, Func&&, const Extra& ...) [with Func = void (lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > >::*)(std::vector<unsigned int>, std::vector<unsigned int>, unsigned int, unsigned int); Extra = {const char*, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v}; type_ = lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > >; options = {std::shared_ptr<lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > > >}]’
/home/dangerginger/code/openfhe-python/src/lib/bindings.cpp:582:13:   required from here
/home/dangerginger/code/miniconda3/envs/openfhe/include/pybind11/pybind11.h:219:40: error: static assertion failed: The number of argument annotations does not match the number of function arguments
  219 |             expected_num_args<Extra...>(
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~^
  220 |                 sizeof...(Args), cast_in::args_pos >= 0, cast_in::has_kwargs),
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/dangerginger/code/miniconda3/envs/openfhe/include/pybind11/pybind11.h:219:40: note: ‘pybind11::detail::expected_num_args<pybind11::name, pybind11::is_method, pybind11::sibling, const char*, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v>(5, (((int)pybind11::detail::argument_loader<lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > >*, std::vector<unsigned int, std::allocator<unsigned int> >, std::vector<unsigned int, std::allocator<unsigned int> >, unsigned int, unsigned int>::args_pos) >= 0), ((int)((bool)pybind11::detail::argument_loader<lbcrypto::CryptoContextImpl<lbcrypto::DCRTPolyImpl<bigintdyn::mubintvec<bigintdyn::ubint<long unsigned int> > > >*, std::vector<unsigned int, std::allocator<unsigned int> >, std::vector<unsigned int, std::allocator<unsigned int> >, unsigned int, unsigned int>::has_kwargs)))’ evaluates to false
cc1plus: note: unrecognized command-line option ‘-Wno-unknown-warning-option’ may have been intended to silence earlier diagnostics
cc1plus: note: unrecognized command-line option ‘-Wno-unknown-warning’ may have been intended to silence earlier diagnostics
make[2]: *** [CMakeFiles/openfhe.dir/build.make:76: CMakeFiles/openfhe.dir/src/lib/bindings.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/openfhe.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

binfhe examples are not working

I am getting the following error

~/git/openfhe-python$ python3 examples/binfhe/boolean.py
Generating the bootstrapping keys...

Traceback (most recent call last):
  File "examples/binfhe/boolean.py", line 23, in <module>
    cc.BTKeyGen(sk)
TypeError: BTKeyGen(): incompatible function arguments. The following argument types are supported:
    1. (self: openfhe.BinFHEContext, arg0: lbcrypto::LWEPrivateKeyImpl, arg1: lbcrypto::KEYGEN_MODE) -> None

Invoked with: <openfhe.BinFHEContext object at 0x7f79c09cd5b0>, <openfhe.LWEPrivateKey object at 0x7f79c0a552f0>

Python cannot find .so after using pip install

To recreate this problem:

  1. Checkout openfhe-python source code and its dependencies.
  2. Make a new virtual environment in another directory.
  3. pip install directory-of/openfhe-python
  4. python -c "import('openfhe')"

Cause of the problem:

The openfhe-python library uses an init.py file that has a local import statement. When you run that local import from a different location on disk, it looks in a place relative to that different location, so it doesn't find the .so.

The relative import that is currently there:

from .openfhe import *

Suggested fix:

Use an absolute import statement, so that it is relative to the base of the library, not the current directory.

from openfhe.openfhe import *

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.