Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ project (OpenFHE-Python)

set(OPENFHE_PYTHON_VERSION_MAJOR 1)
set(OPENFHE_PYTHON_VERSION_MINOR 4)
set(OPENFHE_PYTHON_VERSION_PATCH 0)
set(OPENFHE_PYTHON_VERSION_TWEAK 1)
set(OPENFHE_PYTHON_VERSION_PATCH 1)
set(OPENFHE_PYTHON_VERSION_TWEAK 0)
set(OPENFHE_PYTHON_VERSION ${OPENFHE_PYTHON_VERSION_MAJOR}.${OPENFHE_PYTHON_VERSION_MINOR}.${OPENFHE_PYTHON_VERSION_PATCH}.${OPENFHE_PYTHON_VERSION_TWEAK})

# OpenFHE version can be specified externally (-DOPENFHE_REQUIRED_VERSION=1.4.0)
# OpenFHE version can be specified externally (-DOPENFHE_REQUIRED_VERSION=1.4.1)
if(NOT DEFINED OPENFHE_REQUIRED_VERSION)
set(OPENFHE_REQUIRED_VERSION "1.4.0" CACHE STRING "Required OpenFHE version")
set(OPENFHE_REQUIRED_VERSION "1.4.1" CACHE STRING "Required OpenFHE version")
else()
# User provided OPENFHE_REQUIRED_VERSION via -D
message(STATUS "Using user-specified OpenFHE version: ${OPENFHE_REQUIRED_VERSION}")
Expand Down Expand Up @@ -75,13 +75,26 @@ pybind11_add_module(openfhe
# The next line ensures that the installed openfhe module can find its shared library dependencies
# in the 'lib/' subdirectory relative to itself without requiring LD_LIBRARY_PATH.
### target_link_options(openfhe PRIVATE "-Wl,-rpath=$ORIGIN/lib" "-Wl,--disable-new-dtags")
target_link_options(openfhe PRIVATE "-Wl,--enable-new-dtags" "-Wl,-rpath,\$ORIGIN/lib")

# Also set target RPATH properties (survive install/copying)
set_target_properties(openfhe PROPERTIES
BUILD_RPATH "\$ORIGIN/lib"
INSTALL_RPATH "\$ORIGIN/lib"
)
if(UNIX AND NOT APPLE)
target_link_options(openfhe PRIVATE "-Wl,--enable-new-dtags" "-Wl,-rpath,\$ORIGIN/lib")
# Also set target RPATH properties (survive install/copying)
set_target_properties(openfhe PROPERTIES
BUILD_RPATH "\$ORIGIN/lib"
INSTALL_RPATH "\$ORIGIN/lib"
)
elseif(APPLE)
# Enable RPATH use on macOS
set(CMAKE_MACOSX_RPATH ON)
# Set install-time rpath for all targets (unless overridden)
set(CMAKE_INSTALL_RPATH "@loader_path/lib")

target_link_options(openfhe PRIVATE "-Wl,-rpath,@loader_path/lib")
# Also set target RPATH properties (survive install/copying)
set_target_properties(openfhe PROPERTIES
BUILD_RPATH "@loader_path/lib"
INSTALL_RPATH "@loader_path/lib"
)
endif()


### Python installation
Expand Down
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Official Python wrapper for OpenFHE
# OpenFHE-Python

[![License](https://img.shields.io/badge/License-BSD%202--Clause-blue.svg)](https://opensource.org/licenses/BSD-2-Clause)
[![Python Versions](https://img.shields.io/badge/python-3.10%2B-blue)](https://www.python.org/)
[![OpenFHE Version](https://img.shields.io/badge/OpenFHE-1.4.1%2B-green)](https://github.com/openfheorg/openfhe-development)

Python wrapper for the main cryptographic capabilities of the OpenFHE C++ library. `OpenFHE-Python` provides a more user-friendly interface for Python developers, while keeping the efficiency of C++ FHE operations.

## Table of Contents

Expand All @@ -23,20 +29,21 @@ pip install openfhe==<openfhe_package_version>

Once installed, any python example at https://github.com/openfheorg/openfhe-python/tree/main/examples can be executed.

Note that Ubuntu LTS 20.04, 22.04, and 24.04 are currently supported. `pip uninstall` can be used to uninstall the openfhe package.
Note that Ubuntu LTS 22.04 and 24.04 are currently supported. `pip uninstall` can be used to uninstall the openfhe package.

## Running from Docker
## Building from Source

Please see [Instructions for the Docker setup](docker/README.md)
We recommend installing the wrapper from PyPI using `pip`, as this is the simplest method.
If you prefer to build from source, you can use the [openfhe-python-packager](https://github.com/openfheorg/openfhe-python-packager) on Linux or follow the build instructions below. The packager generates a wheel that can be installed with `pip`.

## Building from Source
The legacy build instructions below are for other operating systems where [openfhe-python-packager](https://github.com/openfheorg/openfhe-python-packager) may not work.

### Requirements

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

- [OpenFHE 1.4.0+](https://github.com/openfheorg/openfhe-development) by following the instructions in [OpenFHE Documentation](https://openfhe-development.readthedocs.io/en/latest/sphinx_rsts/intro/installation/installation.html)
- [Python 3.6+](https://www.python.org/)
- [OpenFHE 1.4.1+](https://github.com/openfheorg/openfhe-development) by following the instructions in [OpenFHE Documentation](https://openfhe-development.readthedocs.io/en/latest/sphinx_rsts/intro/installation/installation.html)
- [Python 3.10+](https://www.python.org/)
- [pybind11](https://pybind11.readthedocs.io/en/stable/installing.html)

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
Expand Down
51 changes: 0 additions & 51 deletions build_package.sh

This file was deleted.

58 changes: 0 additions & 58 deletions docker/Dockerfile

This file was deleted.

52 changes: 0 additions & 52 deletions docker/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = 'v1.3.1.0'
release = 'v1.4.1.0'


# -- General configuration ---------------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion src/lib/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ void bind_crypto_context(py::module &m) {
.def("GetCompositeDegree", [](CryptoContext<DCRTPoly>& self) {
return GetParamsRNSChecked(self, "GetCompositeDegree")->GetCompositeDegree();
})
.def("GetKeySwitchTechnique", [](CryptoContext<DCRTPoly>& self) {
return GetParamsRNSChecked(self, "GetKeySwitchTechnique")->GetKeySwitchTechnique();
})
.def("Enable", py::overload_cast<PKESchemeFeature>(&CryptoContextImpl<DCRTPoly>::Enable),
py::arg("feature"),
py::doc(cc_Enable_docs))
Expand Down Expand Up @@ -996,7 +999,8 @@ void bind_crypto_context(py::module &m) {
py::doc(cc_EvalAutomorphismKeyGen_docs))
.def("Compress", &CryptoContextImpl<DCRTPoly>::Compress,
py::arg("ciphertext"),
py::arg("towersLeft"))
py::arg("towersLeft") = 1,
py::arg("noiseScaleDeg") = 1)
.def("EvalMultMany", &CryptoContextImpl<DCRTPoly>::EvalMultMany,
py::arg("ciphertextVec"))
.def("EvalAddMany", &CryptoContextImpl<DCRTPoly>::EvalAddMany,
Expand Down