Parcourir la source

Issue (#45) - Pre-release changes (#46)

* fix binfhe enums attr shortcut

* add sudo make install on top

* conda preffix commands

* push test

* move examples

* lib/include organization

* cmake lib-includepath

* change lib paths in cmake

* fixed README.md

---------

Co-authored-by: Yuriy Polyakov <ypolyakod@dualitytech.com>
Rener Oliveira il y a 1 an
Parent
commit
21931aedf0

+ 4 - 0
.gitignore

@@ -4,3 +4,7 @@ build/
 .png
 .json
 .txt
+.cproject
+.project
+.settings/
+demoData/

+ 7 - 7
CMakeLists.txt

@@ -8,8 +8,8 @@ find_package(OpenFHE)
 find_package(pybind11 REQUIRED)
 
 set( CMAKE_CXX_FLAGS ${OpenFHE_CXX_FLAGS} )
-set( OpenFHE_Py_SOURCES src)
-set( OpenFHE_Py_INCLUDES include)
+set( OpenFHE_Py_SOURCES src/lib)
+set( OpenFHE_Py_INCLUDES src/include)
 
 include_directories( ${OPENMP_INCLUDES} )
 include_directories( ${OpenFHE_INCLUDE} )
@@ -42,11 +42,11 @@ endif()
 
 ### Pybind Modules
 pybind11_add_module(openfhe 
-                    src/bindings.cpp 
-                    src/binfhe_bindings.cpp
-                    src/binfhe/binfhecontext_wrapper.cpp
-                    src/pke/serialization.cpp 
-                    src/pke/cryptocontext_wrapper.cpp
+                    src/lib/bindings.cpp 
+                    src/lib/binfhe_bindings.cpp
+                    src/lib/binfhe/binfhecontext_wrapper.cpp
+                    src/lib/pke/serialization.cpp 
+                    src/lib/pke/cryptocontext_wrapper.cpp
                     )
 ### Python installation 
 # Allow the user to specify the path to Python executable (if not provided, find it)

+ 23 - 26
README.md

@@ -39,6 +39,7 @@ mkdir build
 cd build
 cmake ..  # Alternatively, cmake .. -DOpenFHE_DIR=/path/to/installed/openfhe
 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.
@@ -59,8 +60,9 @@ To do this, run the following commands:
 ```bash
 mkdir build
 cd build
-cmake ..  # Or cmake .. -DPYTHON_EXECUTABLE_PATH=$CONDA_PREFIX/bin/python
+cmake .. -DPYTHON_EXECUTABLE_PATH=$CONDA_PREFIX/bin/python
 make
+make install  # You may have to run sudo make install
 ```
 
 The CONDA_PREFIX variable is set by conda, and points to the root of your active conda environment.
@@ -77,41 +79,36 @@ which creates a lib folder, moves the built `.so` file into that lib folder, and
 
 **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.
 
-#### System install
-
-```
-make install  # You may have to run sudo make install
-```
-
 ## Code Examples
 
 To get familiar with the OpenFHE Python API, check out the examples:
 
 - FHE for arithmetic over integers (BFV):
-  - [Simple Code Example](src/pke/examples/simple-integers.py)
-  <!-- - [Simple Code Example with Serialization](src/pke/examples/simple-integers-serial.py) -->
+  - [Simple Code Example](examples/pke/simple-integers.py)
+  <!-- - [Simple Code Example with Serialization](examples/pke/simple-integers-serial.py) -->
 - FHE for arithmetic over integers (BGV):
-  - [Simple Code Example](src/pke/examples/simple-integers-bgvrns.py)
-  <!-- - [Simple Code Example with Serialization](src/pke/examples/simple-integers-serial-bgvrns.py) -->
+  - [Simple Code Example](examples/pke/simple-integers-bgvrns.py)
+  <!-- - [Simple Code Example with Serialization](examples/pke/simple-integers-serial-bgvrns.py) -->
 - FHE for arithmetic over real numbers (CKKS):
-  - [Simple Code Example](src/pke/examples/simple-real-numbers.py)
-  - [Advanced Code Example](src/pke/examples/advanced-real-numbers.py)
-  - [Advanced Code Example for High-Precision CKKS](src/pke/examples/advanced-real-numbers-128.py)
-  - [Arbitrary Smooth Function Evaluation](src/pke/examples/function-evaluation.py)
-  - [Simple CKKS Bootstrapping Example](src/pke/examples/simple-ckks-bootstrapping.py)
-  - [Advanced CKKS Bootstrapping Example](src/pke/examples/advanced-ckks-bootstrapping.cpp)
-  - [Double-Precision (Iterative) Bootstrapping Example](src/pke/examples/iterative-ckks-bootstrapping.py)
+  - [Simple Code Example](examples/pke/simple-real-numbers.py)
+  - [Advanced Code Example](examples/pke/advanced-real-numbers.py)
+  - [Advanced Code Example for High-Precision CKKS](examples/pke/advanced-real-numbers-128.py)
+  - [Arbitrary Smooth Function Evaluation](examples/pke/function-evaluation.py)
+  - [Simple CKKS Bootstrapping Example](examples/pke/simple-ckks-bootstrapping.py)
+  - [Advanced CKKS Bootstrapping Example](examples/pke/advanced-ckks-bootstrapping.cpp)
+  - [Double-Precision (Iterative) Bootstrapping Example](examples/pke/iterative-ckks-bootstrapping.py)
 - FHE for Boolean circuits and larger plaintext spaces (FHEW/TFHE):
-  - [Simple Code Example](src/binfhe/examples/boolean.py)
-  - [Truth Table Example](src/binfhe/examples/boolean-truth-table.py)
-  <!-- - [Code with JSON serialization](src/binfhe/examples/boolean-serial-json.py) -->
-  <!-- - [Code with Binary Serialization](src/binfhe/examples/boolean-serial-binary.py) -->
-  <!-- - [Large-Precision Comparison](src/binfhe/examples/eval-sign.py) -->
-  <!-- - [Small-Precison Arbitrary Function Evaluation](src/binfhe/examples/eval-function.py) -->
+  - [Simple Code Example](examples/binfhe/boolean.py)
+  - [Truth Table Example](examples/binfhe/boolean-truth-table.py)
+  <!-- - [Code with JSON serialization](examples/binfhe/boolean-serial-json.py) -->
+  <!-- - [Code with Binary Serialization](examples/binfhe/boolean-serial-binary.py) -->
+  <!-- - [Large-Precision Comparison](examples/binfhe/eval-sign.py) -->
+  <!-- - [Small-Precison Arbitrary Function Evaluation](examples/binfhe/eval-function.py) -->
   <!-- - Threshold FHE:  -->
-  <!-- - [Code Example for BGV, BFV, and CKKS](src/pke/examples/threshold-fhe.py) -->
-  <!-- - [Code Example for BFV with 5 parties](src/pke/examples/threshold-fhe-5p.py) -->
+  <!-- - [Code Example for BGV, BFV, and CKKS](examples/pke/threshold-fhe.py) -->
+  <!-- - [Code Example for BFV with 5 parties](examples/pke/threshold-fhe-5p.py) -->
 
 ## OpenFHE Python Wrapper Documentation
 
 [OpenFHE Python Wrapper API Reference](https://openfheorg.github.io/openfhe-python/html/index.html)
+

+ 0 - 0
src/binfhe/examples/boolean-ap.py → examples/binfhe/boolean-ap.py


+ 0 - 0
src/binfhe/examples/boolean-truth-tables.py → examples/binfhe/boolean-truth-tables.py


+ 0 - 0
src/binfhe/examples/boolean.py → examples/binfhe/boolean.py


+ 0 - 0
src/pke/examples/advanced-real-numbers-128.py → examples/pke/advanced-real-numbers-128.py


+ 0 - 0
src/pke/examples/advanced-real-numbers.py → examples/pke/advanced-real-numbers.py


+ 0 - 0
src/pke/examples/function-evaluation.py → examples/pke/function-evaluation.py


+ 0 - 0
src/pke/examples/iterative-ckks-bootstrapping.py → examples/pke/iterative-ckks-bootstrapping.py


+ 0 - 0
src/pke/examples/polynomial-evaluation.py → examples/pke/polynomial-evaluation.py


+ 0 - 0
src/pke/examples/simple-ckks-bootstrapping.py → examples/pke/simple-ckks-bootstrapping.py


+ 0 - 0
src/pke/examples/simple-integers-bgvrns.py → examples/pke/simple-integers-bgvrns.py


+ 0 - 0
src/pke/examples/simple-integers-serial-bgvrns.py → examples/pke/simple-integers-serial-bgvrns.py


+ 0 - 0
src/pke/examples/simple-integers-serial.py → examples/pke/simple-integers-serial.py


+ 0 - 0
src/pke/examples/simple-integers.py → examples/pke/simple-integers.py


+ 0 - 0
src/pke/examples/simple-real-numbers.py → examples/pke/simple-real-numbers.py


+ 0 - 0
include/bindings.h → src/include/bindings.h


+ 0 - 0
include/binfhe/binfhecontext_wrapper.h → src/include/binfhe/binfhecontext_wrapper.h


+ 0 - 0
include/binfhe_bindings.h → src/include/binfhe_bindings.h


+ 0 - 0
include/docstrings/binfhecontext_docs.h → src/include/docstrings/binfhecontext_docs.h


+ 0 - 0
include/docstrings/ciphertext_docs.h → src/include/docstrings/ciphertext_docs.h


+ 0 - 0
include/docstrings/cryptocontext_docs.h → src/include/docstrings/cryptocontext_docs.h


+ 0 - 0
include/docstrings/cryptoparameters_docs.h → src/include/docstrings/cryptoparameters_docs.h


+ 0 - 0
include/docstrings/plaintext_docs.h → src/include/docstrings/plaintext_docs.h


+ 0 - 0
include/pke/cryptocontext_wrapper.h → src/include/pke/cryptocontext_wrapper.h


+ 0 - 0
include/pke/serialization.h → src/include/pke/serialization.h


+ 0 - 0
src/bindings.cpp → src/lib/bindings.cpp


+ 0 - 0
src/binfhe/binfhecontext_wrapper.cpp → src/lib/binfhe/binfhecontext_wrapper.cpp


+ 7 - 0
src/binfhe_bindings.cpp → src/lib/binfhe_bindings.cpp

@@ -67,7 +67,14 @@ void bind_binfhe_enums(py::module &m)
     m.attr("TOY") = py::cast(BINFHE_PARAMSET::TOY);
     m.attr("MEDIUM") = py::cast(BINFHE_PARAMSET::MEDIUM);
     m.attr("STD128_LMKCDEY") = py::cast(BINFHE_PARAMSET::STD128_LMKCDEY);
+    m.attr("STD128_AP") = py::cast(BINFHE_PARAMSET::STD128_AP);
+    m.attr("STD128") = py::cast(BINFHE_PARAMSET::STD128);
+    m.attr("STD192") = py::cast(BINFHE_PARAMSET::STD192);
+    m.attr("STD256") = py::cast(BINFHE_PARAMSET::STD256);
+    m.attr("STD128Q") = py::cast(BINFHE_PARAMSET::STD128Q);
     m.attr("STD128Q_LMKCDEY") = py::cast(BINFHE_PARAMSET::STD128Q_LMKCDEY);
+    m.attr("STD192Q") = py::cast(BINFHE_PARAMSET::STD192Q);
+    m.attr("STD256Q") = py::cast(BINFHE_PARAMSET::STD256Q);
     m.attr("STD128_3") = py::cast(BINFHE_PARAMSET::STD128_3);
     m.attr("STD128_3_LMKCDEY") = py::cast(BINFHE_PARAMSET::STD128_3_LMKCDEY);
     m.attr("STD128Q_3") = py::cast(BINFHE_PARAMSET::STD128Q_3);

+ 0 - 0
src/pke/cryptocontext_wrapper.cpp → src/lib/pke/cryptocontext_wrapper.cpp


+ 0 - 0
src/pke/serialization.cpp → src/lib/pke/serialization.cpp