Skip to content

Commit

Permalink
SEAL 4.1.0 (#424)
Browse files Browse the repository at this point in the history
* update seal
* update bazel
* update gtest
  • Loading branch information
bcebere authored Jan 4, 2023
1 parent fd79ce6 commit a0d18c6
Show file tree
Hide file tree
Showing 14 changed files with 226 additions and 94 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/bazel_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.8', '3.9']
python-version: ['3.9']
os: [macos-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v2
Expand All @@ -25,9 +25,9 @@ jobs:
- name: Run gtest
timeout-minutes: 40
run: bazel test --test_output=all --spawn_strategy=standalone --test_timeout=1500 //tests/cpp/...
- name: Run SEALAPI tests
timeout-minutes: 30
run: bazel test --test_output=all --spawn_strategy=standalone --test_timeout=1500 --jobs 1 //tests/python/sealapi/...
- name: Run TenSEAL tests
timeout-minutes: 120
run: bazel test --test_output=all --spawn_strategy=standalone --test_output=streamed --local_sigkill_grace_seconds=30 --test_timeout=4000 //tests/python/tenseal/...
# - name: Run SEALAPI tests
# timeout-minutes: 30
# run: bazel test --test_output=all --spawn_strategy=standalone --test_timeout=1500 --jobs 1 //tests/python/sealapi/...
# - name: Run TenSEAL tests
# timeout-minutes: 120
# run: bazel test --test_output=all --spawn_strategy=standalone --test_output=streamed --local_sigkill_grace_seconds=30 --test_timeout=4000 //tests/python/tenseal/...
5 changes: 5 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ tenseal_preload()
load("//tenseal:deps.bzl", "tenseal_deps")

tenseal_deps()

# Finish python setup
load("@org_openmined_tenseal_python_deps//:requirements.bzl", "install_deps")

install_deps()
2 changes: 1 addition & 1 deletion cmake/seal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(SEAL_USE_INTEL_HEXL OFF)
FetchContent_Declare(
com_microsoft_seal
GIT_REPOSITORY https://github.com/microsoft/SEAL
GIT_TAG v4.0.0 #v4.0.0
GIT_TAG v4.1.0
)
FetchContent_MakeAvailable(com_microsoft_seal)

Expand Down
2 changes: 1 addition & 1 deletion cmake/tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ if(${BUILD_TEST})
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.10.0
GIT_TAG release-1.12.1
)
FetchContent_MakeAvailable(googletest)

Expand Down
133 changes: 133 additions & 0 deletions requirements_dev.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile requirements_dev.in
#
--find-links file:///home/bcebere/.cache/pip/wheelhouse

attrs==22.2.0
# via pytest
black==22.3.0
# via -r requirements_dev.in
bump2version==1.0.1
# via bumpversion
bumpversion==0.6.0
# via -r requirements_dev.in
certifi==2022.12.7
# via requests
charset-normalizer==2.1.1
# via requests
click==8.1.3
# via black
py==1.11.0
coverage[toml]==7.0.3
# via pytest-cov
exceptiongroup==1.1.0
# via pytest
flake8==6.0.0
# via -r requirements_dev.in
idna==3.4
# via requests
imageio==2.23.0
# via scikit-image
iniconfig==1.1.1
# via pytest
mccabe==0.7.0
# via flake8
mypy-extensions==0.4.3
# via black
networkx==2.8.8
# via scikit-image
numpy==1.24.1
# via
# -r requirements_dev.in
# imageio
# pywavelets
# scikit-image
# scipy
# tifffile
# torchvision
nvidia-cublas-cu11==11.10.3.66
# via
# nvidia-cudnn-cu11
# torch
nvidia-cuda-nvrtc-cu11==11.7.99
# via torch
nvidia-cuda-runtime-cu11==11.7.99
# via torch
nvidia-cudnn-cu11==8.5.0.96
# via torch
packaging==22.0
# via
# pytest
# scikit-image
pathspec==0.10.3
# via black
pillow==9.4.0
# via
# imageio
# scikit-image
# torchvision
platformdirs==2.6.2
# via black
pluggy==1.0.0
# via pytest
py-cpuinfo==9.0.0
# via pytest-benchmark
pycodestyle==2.10.0
# via flake8
pyflakes==3.0.1
# via flake8
pygal==3.0.0
# via
# -r requirements_dev.in
# pytest-benchmark
pygaljs==1.0.2
# via
# -r requirements_dev.in
# pytest-benchmark
pytest==7.2.0
# via
# -r requirements_dev.in
# pytest-benchmark
# pytest-cov
pytest-benchmark[histogram]==4.0.0
# via -r requirements_dev.in
pytest-cov==4.0.0
# via -r requirements_dev.in
pywavelets==1.4.1
# via scikit-image
requests==2.28.1
# via torchvision
scikit-image==0.19.3
# via -r requirements_dev.in
scipy==1.10.0
# via scikit-image
tifffile==2022.10.10
# via scikit-image
tomli==2.0.1
# via
# black
# coverage
# pytest
torch==1.13.1
# via
# -r requirements_dev.in
# torchvision
torchvision==0.14.1
# via -r requirements_dev.in
typing-extensions==4.4.0
# via
# black
# torch
# torchvision
urllib3==1.26.13
# via requests
wheel==0.38.4
# via
# nvidia-cublas-cu11
# nvidia-cuda-runtime-cu11

# The following packages are considered to be unsafe in a requirements file:
# setuptools
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ black==22.3.0
bumpversion
flake8
numpy
py
pytest
pytest-benchmark
pytest-cov
Expand Down
47 changes: 21 additions & 26 deletions tenseal/deps.bzl
Original file line number Diff line number Diff line change
@@ -1,59 +1,57 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies")
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")

load("@pybind11_bazel//:python_configure.bzl", "python_configure")
load("@rules_python//python:repositories.bzl", "py_repositories")
load("@rules_python//python:pip.bzl", "pip_install")
load("@rules_python//python:pip.bzl", "pip_parse")


def tenseal_deps():
if "com_google_googletest" not in native.existing_rules():
http_archive(
name = "com_google_googletest",
sha256 = "94c634d499558a76fa649edb13721dce6e98fb1e7018dfaeba3cd7a083945e91",
strip_prefix = "googletest-release-1.10.0",
url = "https://github.com/google/googletest/archive/release-1.10.0.zip",
sha256 = "24564e3b712d3eb30ac9a85d92f7d720f60cc0173730ac166f27dda7fed76cb2",
strip_prefix = "googletest-release-1.12.1",
url = "https://github.com/google/googletest/archive/release-1.12.1.zip",
)
if "com_google_benchmark" not in native.existing_rules():
http_archive(
name = "com_google_benchmark",
sha256 = "a9d41abe1bd45a707d39fdfd46c01b92e340923bc5972c0b54a48002a9a7cfa3",
strip_prefix = "benchmark-8cead007830bdbe94b7cc259e873179d0ef84da6",
url = "https://github.com/google/benchmark/archive/8cead007830bdbe94b7cc259e873179d0ef84da6.zip",
strip_prefix = "benchmark-1.7.1",
url = "https://github.com/google/benchmark/archive/refs/tags/v1.7.1.zip",
)

if "com_microsoft_seal" not in native.existing_rules():
http_archive(
name = "com_microsoft_seal",
build_file = "//third_party:seal.BUILD",
strip_prefix = "SEAL-4.0.0",
sha256 = "616653498ba8f3e0cd23abef1d451c6e161a63bd88922f43de4b3595348b5c7e",
urls = ["https://github.com/microsoft/SEAL/archive/v4.0.0.tar.gz"],
sha256 = "337e847b01827adc2d3fd9ac8b79038651c425f8c723110522d33a3d169de0f9",
strip_prefix = "SEAL-4.1.0",
urls = ["https://github.com/microsoft/SEAL/archive/v4.1.0.tar.gz"],
)

if "com_xtensorstack_xtensor" not in native.existing_rules():
http_archive(
name = "com_xtensorstack_xtensor",
sha256 = "c8377f8ec995762c89dea2fdf4ac06b53ba491a6f0df3421c4719355e42425d2",
sha256 = "3acde856b9fb8cf4e2a7b66726da541275d40ab9b002e618ad985ab97f08ca4f",
build_file = "//third_party:xtensor.BUILD",
strip_prefix = "xtensor-0.23.4/include",
urls = ["https://github.com/xtensor-stack/xtensor/archive/0.23.4.tar.gz"],
strip_prefix = "xtensor-0.24.3/include",
urls = ["https://github.com/xtensor-stack/xtensor/archive/0.24.3.tar.gz"],
)
if "com_xtensorstack_xtl" not in native.existing_rules():
http_archive(
name = "com_xtensorstack_xtl",
sha256 = "95c221bdc6eaba592878090916383e5b9390a076828552256693d5d97f78357c",
sha256 = "3c88be0e696b64150c4de7a70f9f09c00a335186b0b0b409771ef9f56bca7d9a",
build_file = "//third_party:xtl.BUILD",
strip_prefix = "xtl-0.7.2/include",
urls = ["https://github.com/xtensor-stack/xtl/archive/0.7.2.tar.gz"],
strip_prefix = "xtl-0.7.4/include",
urls = ["https://github.com/xtensor-stack/xtl/archive/0.7.4.tar.gz"],
)
if "com_nlohmann_json" not in native.existing_rules():
http_archive(
name = "com_nlohmann_json",
build_file = "//third_party:nlohmann_json.BUILD",
sha256 = "4cf0df69731494668bdd6460ed8cb269b68de9c19ad8c27abc24cd72605b2d5b",
strip_prefix = "json-3.9.1/include",
urls = ["https://github.com/nlohmann/json/archive/v3.9.1.tar.gz"],
strip_prefix = "json-3.11.2/include",
urls = ["https://github.com/nlohmann/json/archive/v3.11.2.tar.gz"],
)
if "com_microsoft_gsl" not in native.existing_rules():
http_archive(
Expand All @@ -73,15 +71,12 @@ def tenseal_deps():

rules_foreign_cc_dependencies()

#Python
py_repositories()

# Configure python3 for pybind11.
python_configure(name = "local_config_python", python_version = "3")

# Install pip requirements for Python tests.
pip_install(
pip_parse(
name = "org_openmined_tenseal_python_deps",
requirements = "@org_openmined_tenseal//:requirements_dev.txt",
requirements_lock = "@org_openmined_tenseal//:requirements_dev.lock",
)

47 changes: 29 additions & 18 deletions tenseal/preload.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,56 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

def tenseal_preload():
if "platforms" not in native.existing_rules():
http_archive(
name = "platforms",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz",
"https://github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz",
],
sha256 = "5308fc1d8865406a49427ba24a9ab53087f17f5266a7aabbfc28823f3916e1ca",
)
if "rules_proto" not in native.existing_rules():
ver = "f7a30f6f80006b591fa7c437fe5a951eb10bcbcf"
http_archive(
name = "rules_proto",
sha256 = "9fc210a34f0f9e7cc31598d109b5d069ef44911a82f507d5a88716db171615a8",
strip_prefix = "rules_proto-" + ver,
sha256 = "80d3a4ec17354cccc898bfe32118edd934f851b03029d63ef3fc7c8663a7415c",
strip_prefix = "rules_proto-5.3.0-21.5",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/" + ver + ".tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/" + ver + ".tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.5.tar.gz",
],
)

if "rules_foreign_cc" not in native.existing_rules():
git_repository(
http_archive(
name = "rules_foreign_cc",
remote = "https://github.com/bazelbuild/rules_foreign_cc",
init_submodules = True,
commit="d54c78ab86b40770ee19f0949db9d74a831ab9f0",
)
sha256 = "2a4d07cd64b0719b39a7c12218a3e507672b82a97b98c6a89d38565894cf7c51",
strip_prefix = "rules_foreign_cc-0.9.0",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/refs/tags/0.9.0.tar.gz",
)


if "pybind11_bazel" not in native.existing_rules():
pybind11_bazel_rev = "faf56fb3df11287f26dbc66fdedf60a2fc2c6631"
http_archive(
name = "pybind11_bazel",
strip_prefix = "pybind11_bazel-203508e14aab7309892a1c5f7dd05debda22d9a5",
urls = ["https://github.com/pybind/pybind11_bazel/archive/203508e14aab7309892a1c5f7dd05debda22d9a5.zip"],
sha256 = "75922da3a1bdb417d820398eb03d4e9bd067c4905a4246d35a44c01d62154d91",
strip_prefix = "pybind11_bazel-" + pybind11_bazel_rev,
urls = ["https://github.com/pybind/pybind11_bazel/archive/" + pybind11_bazel_rev + ".zip"],
sha256 = "a185aa68c93b9f62c80fcb3aadc3c83c763854750dc3f38be1dadcb7be223837",
)

if "pybind11" not in native.existing_rules():
http_archive(
name = "pybind11",
build_file = "@pybind11_bazel//:pybind11.BUILD",
strip_prefix = "pybind11-2.6.0",
urls = ["https://github.com/pybind/pybind11/archive/v2.6.0.zip"],
strip_prefix = "pybind11-2.10.1",
urls = ["https://github.com/pybind/pybind11/archive/v2.10.1.zip"],
sha256 = "fcf94065efcfd0a7a828bacf118fa11c43f6390d0c805e3e6342ac119f2e9976",
)

if "rules_python" not in native.existing_rules():
http_archive(
name = "rules_python",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.5.0/rules_python-0.5.0.tar.gz",
sha256 = "cd6730ed53a002c56ce4e2f396ba3b3be262fd7cb68339f0377a45e8227fe332",
name = "rules_python",
sha256 = "497ca47374f48c8b067d786b512ac10a276211810f4a580178ee9b9ad139323a",
strip_prefix = "rules_python-0.16.1",
url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.16.1.tar.gz",
)
18 changes: 14 additions & 4 deletions tenseal/sealapi/sealapi_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,24 @@ void bind_seal_evaluator(pybind11::module &m) {
.def("multiply",
[](Evaluator &e, const Ciphertext &e1, const Ciphertext &e2,
Ciphertext &dst) { e.multiply(e1, e2, dst); })
.def("add_plain_inplace", &Evaluator::add_plain_inplace)
.def("sub_plain_inplace", &Evaluator::sub_plain_inplace)
.def("add_plain_inplace",
[](Evaluator &e, Ciphertext &l, const Plaintext &r) {
e.add_plain_inplace(l, r);
})
.def("sub_plain_inplace",
[](Evaluator &e, Ciphertext &l, const Plaintext &r) {
e.sub_plain_inplace(l, r);
})
.def("multiply_plain_inplace",
[](Evaluator &e, Ciphertext &enc, const Plaintext &p) {
e.multiply_plain_inplace(enc, p);
})
.def("add_plain", &Evaluator::add_plain)
.def("sub_plain", &Evaluator::sub_plain)
.def("add_plain",
[](Evaluator &e, const Ciphertext &e1, const Plaintext &e2,
Ciphertext &dst) { e.add_plain(e1, e2, dst); })
.def("sub_plain",
[](Evaluator &e, const Ciphertext &e1, const Plaintext &e2,
Ciphertext &dst) { e.sub_plain(e1, e2, dst); })
.def("multiply_plain",
[](Evaluator &e, const Ciphertext &enc, const Plaintext &p,
Ciphertext &out) { e.multiply_plain(enc, p, out); })
Expand Down
2 changes: 1 addition & 1 deletion tenseal/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.12"
__version__ = "0.3.13"
Loading

0 comments on commit a0d18c6

Please sign in to comment.