Skip to content

Commit

Permalink
Merge pull request #184 from openfheorg/dev
Browse files Browse the repository at this point in the history
Update to v0.8.10
  • Loading branch information
yspolyakov authored Oct 29, 2024
2 parents 2447d37 + 4269e99 commit e45d01c
Show file tree
Hide file tree
Showing 8 changed files with 241 additions and 206 deletions.
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ project (OpenFHE-Python)

set(OPENFHE_PYTHON_VERSION_MAJOR 0)
set(OPENFHE_PYTHON_VERSION_MINOR 8)
set(OPENFHE_PYTHON_VERSION_PATCH 9)
set(OPENFHE_PYTHON_VERSION_PATCH 10)
set(OPENFHE_PYTHON_VERSION ${OPENFHE_PYTHON_VERSION_MAJOR}.${OPENFHE_PYTHON_VERSION_MINOR}.${OPENFHE_PYTHON_VERSION_PATCH})

set(CMAKE_CXX_STANDARD 17)
Expand All @@ -14,10 +14,13 @@ if(APPLE)
set(CMAKE_CXX_VISIBILITY_PRESET default)
endif()

find_package(OpenFHE 1.2.1 REQUIRED)
find_package(OpenFHE 1.2.2 REQUIRED)
find_package(pybind11 REQUIRED)

set( CMAKE_CXX_FLAGS ${OpenFHE_CXX_FLAGS} )
# "CMAKE_INTERPROCEDURAL_OPTIMIZATION ON" (ON is the default value) causes link failure. see
# https://github.com/openfheorg/openfhe-python/actions/runs/11492843373/job/31987579944
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)

set( OpenFHE_Py_SOURCES src/lib)
set( OpenFHE_Py_INCLUDES src/include)

Expand Down
4 changes: 4 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ RUN git clone https://github.com/openfheorg/openfhe-python.git \
&& make -j$(nproc) \
&& make install

# Install openfhe as a pip package
WORKDIR /openfhe-python
RUN python3 setup.py sdist bdist_wheel && pip install dist/openfhe-*.whl

# Expose the port JupyterLab will listen on
EXPOSE 8888

Expand Down
2 changes: 1 addition & 1 deletion examples/pke/simple-ckks-bootstrapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def simple_bootstrap_example():

ciphertext_after = cryptocontext.EvalBootstrap(ciph)

print(f"Number of levels remaining after bootstrapping: {depth - ciphertext_after.GetLevel()}")
print(f"Number of levels remaining after bootstrapping: {depth - ciphertext_after.GetLevel() - (ciphertext_after.GetNoiseScaleDeg() - 1)}")

result = cryptocontext.Decrypt(ciphertext_after,key_pair.secretKey)
result.SetLength(encoded_length)
Expand Down
12 changes: 7 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import glob
import shutil

__version__ = '0.8.4'
__version__ = '0.9.0'
OPENFHE_PATH = 'openfhe/'
OPENFHE_LIB = 'openfhe.so'

class CMakeExtension(Extension):
def __init__(self, name, sourcedir=''):
Expand All @@ -22,7 +24,7 @@ def run(self):
self.build_cmake(ext)

def build_cmake(self, ext):
if os.path.exists('openfhe/openfhe.so'):
if os.path.exists(OPENFHE_PATH + OPENFHE_LIB):
return
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
print(extdir)
Expand All @@ -46,14 +48,14 @@ def build_cmake(self, ext):
raise RuntimeError("Cannot find any built .so file in " + extdir)

src_file = so_files[0]
dst_file = os.path.join('openfhe', 'openfhe.so')
dst_file = os.path.join('openfhe', OPENFHE_LIB)
shutil.move(src_file, dst_file)

# Run build_ext before sdist
class SDist(_sdist):
def run(self):
if os.path.exists('openfhe/openfhe.so'):
os.remove('openfhe/openfhe.so')
if os.path.exists(OPENFHE_PATH + OPENFHE_LIB):
os.remove(OPENFHE_PATH + OPENFHE_LIB)
self.run_command('build_ext')
super().run()

Expand Down
14 changes: 14 additions & 0 deletions src/include/docstrings/binfhecontext_docs.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,18 @@ const char* binfhe_EvalSign_docs = R"pbdoc(
:return: the resulting ciphertext
:rtype: LWECiphertext
)pbdoc";

const char* binfhe_SerializedVersion_docs = R"pbdoc(
Return the serialized version number in use.
:return: the version number
:rtype: uint32_t
)pbdoc";

const char* binfhe_SerializedObjectName_docs = R"pbdoc(
Return the serialized object name
:return: object name
:rtype: std::string
)pbdoc";
#endif // BINFHECONTEXT_DOCSTRINGS_H
4 changes: 3 additions & 1 deletion src/lib/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,9 @@ void bind_ciphertext(py::module &m)
// .def("GetScalingFactor", &CiphertextImpl<DCRTPoly>::GetScalingFactor)
// .def("SetScalingFactor", &CiphertextImpl<DCRTPoly>::SetScalingFactor)
.def("GetSlots", &CiphertextImpl<DCRTPoly>::GetSlots)
.def("SetSlots", &CiphertextImpl<DCRTPoly>::SetSlots);
.def("SetSlots", &CiphertextImpl<DCRTPoly>::SetSlots)
.def("GetNoiseScaleDeg", &CiphertextImpl<DCRTPoly>::GetNoiseScaleDeg)
.def("SetNoiseScaleDeg", &CiphertextImpl<DCRTPoly>::SetNoiseScaleDeg);
}

void bind_schemes(py::module &m){
Expand Down
Loading

0 comments on commit e45d01c

Please sign in to comment.