openfheorg / openfhe-python

Official Python wrapper for OpenFHE. Current release is v0.8.9 (released on September 10, 2024).
https://openfheorg.github.io/openfhe-python/html/index.html
BSD 2-Clause "Simplified" License
73 stars 21 forks source link

Failed when building openfhe-python #60

Closed xldeng-chn closed 1 year ago

xldeng-chn commented 1 year ago

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

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
IanQS commented 1 year ago

taking a step back, can you run the OpenFHE-development examples? I just want to make sure that your system recognizes the OpenFHE in the first place

reneroliveira commented 1 year ago

The problem is the version of OpenFHE, this functionalities of the error was added in OpenFHE v1.1.0.

Updade your OpenFHE C++ library by navigating to the openfhe-development/build directory, then running git pull to get the latest updates, and finally make and make install to build and install the changes.

With that you can successfully build the python wrapper!

Let us know if you run into any other trouble!

reneroliveira commented 1 year ago

taking a step back, can you run the OpenFHE-development examples? I just want to make sure that your system recognizes the OpenFHE in the first place

No need! The wrapper could build the bindings.cpp file, so it's recognizing OpenFHE correctly. The problem comes when building binfhe enums, the solution is just updating the main library as I sent here.

xldeng-chn commented 1 year ago

The problem is the version of OpenFHE, this functionalities of the error was added in OpenFHE v1.1.0.

Updade your OpenFHE C++ library by navigating to the openfhe-development/build directory, then running git pull to get the latest updates, and finally make and make install to build and install the changes.

With that you can successfully build the python wrapper!

Let us know if you run into any other trouble!

The problem was solved, thank you!