MCPcopy Create free account
hub / github.com/Huelse/SEAL-Python

github.com/Huelse/SEAL-Python @v4.1.2.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v4.1.2.1 ↗ · + Follow
33 symbols 138 edges 12 files 1 documented · 3% updated 33d agov4.1.2.1 · 2026-03-28★ 349

Browse by type

Functions 32 Types & classes 1
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Microsoft SEAL For Python

This is a python binding for the Microsoft SEAL library.

Microsoft SEAL is an easy-to-use open-source (MIT licensed) homomorphic encryption library developed by the Cryptography Research group at Microsoft.

pybind11 is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code.

Supported Versions

Contents

Install

SEAL-Python is available on PyPI:

python -m pip install seal-python

Build

On macOS, use the same deployment target for both the SEAL static library and the Python extension to avoid linker warnings about mismatched macOS versions:

export MACOSX_DEPLOYMENT_TARGET=$(python3 - <<'PY'
import sysconfig
print(sysconfig.get_config_var("MACOSX_DEPLOYMENT_TARGET") or "15.0")
PY
)
  • Linux

Recommend: Clang++ (>= 10.0) or GNU G++ (>= 9.4), CMake (>= 3.16)

```shell # Optional sudo apt-get install git build-essential cmake python3 python3-dev python3-pip

# Get the repository or download from the releases git clone https://github.com/Huelse/SEAL-Python.git cd SEAL-Python

# Install dependencies pip3 install numpy pybind11

# Pull the SEAL git submodule update --init --recursive # Get the newest repositories (dev only) # git submodule update --remote

# Build the SEAL lib without the msgsl zlib and zstandard compression cd SEAL cmake -S . -B build -DSEAL_USE_MSGSL=OFF -DSEAL_USE_ZLIB=OFF -DSEAL_USE_ZSTD=OFF # macOS: cmake -S . -B build -DSEAL_USE_MSGSL=OFF -DSEAL_USE_ZLIB=OFF -DSEAL_USE_ZSTD=OFF -DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} cmake --build build cd ..

# Run the setup.py, the dynamic library will be generated in the current directory python3 setup.py build_ext -i

# Test cp seal.*.so examples cd examples python3 4_bgv_basics.py ```

Build examples: -DSEAL_BUILD_EXAMPLES=ON

More cmake options

  • Windows

Visual Studio 2019 or newer is required. x64 support only! And use the x64 Native Tools Command Prompt for VS command prompt to configure and build the Microsoft SEAL library. It's usually can be found in your Start Menu.

```shell # Run in "x64 Native Tools Command Prompt for VS" command prompt cmake -S . -B build -G Ninja -DSEAL_USE_MSGSL=OFF -DSEAL_USE_ZLIB=OFF -DSEAL_USE_ZSTD=OFF cmake --build build --config Release

# Build pip install numpy pybind11 python setup.py build_ext -i

# Test cp seal.*.pyd examples cd examples python 4_bgv_basics.py ```

Microsoft SEAL official docs.

  • Docker

requires: Docker

To build source code into a docker image (from this directory): shell docker build -t huelse/seal -f Dockerfile .

To use the image by running it as an interactive container: shell docker run -it huelse/seal

Note

  • Serialize

See more in examples/7_serialization.py, here is a simple example:

python cipher.save('cipher') load_cipher = Ciphertext() load_cipher.load(context, 'cipher') # work if the context is valid.

Supported classes: EncryptionParameters, Ciphertext, Plaintext, SecretKey, PublicKey, RelinKeys, GaloisKeys

  • Other

There are a lot of changes in the latest SEAL lib, we try to make the API in python can be used easier, but it may remain some problems unknown, if any problems or bugs, report issues.

Email: topmaxz@protonmail.com

FAQ

  1. ImportError: undefined symbol

Build a shared SEAL library cmake . -DBUILD_SHARED_LIBS=ON, and get the libseal.so,

then change the path in setup.py, and rebuild.

  1. ImportError: libseal.so... cannot find

a. sudo ln -s /path/to/libseal.so /usr/lib

b. add /usr/local/lib or the SEAL/native/lib to /etc/ld.so.conf and refresh it sudo ldconfig

c. build in cmake.

  1. BuildError:

  2. C++17 at least

  3. x86_64 is required, which x86_32 is not supported

  4. ModuleNotFoundError: No module named 'seal'

The .so or .pyd file must be in the current directory, or you have install it already.

  1. Windows Error LNK2001, RuntimeLibrary and MT_StaticRelease mismatch

Only x64 is supported, Choose x64 Native Tools Command Prompt for VS.

  1. Warning about building the dynamic library with static library in MacOS, etc.

  2. Build a shared SEAL library by adding a CMake option -DBUILD_SHARED_LIBS=ON

  3. Edit extra_objects in setup.py to *.dylib or else.

Typing

This project now ships seal.pyi and py.typed for Python type checking (PEP 561).

After build/install, editors such as Pylance/Pyright/mypy can use these hints for autocomplete and static analysis.

Release

Use RELEASE.md for the full PyPI release checklist.

Quick commands:

python3 setup.py sdist bdist_wheel
python3 -m twine check dist/*
python3 -m twine upload dist/*

Contributing

Core symbols most depended-on inside this repo

Shape

Function 30
Method 2
Class 1

Languages

Python97%
C++3%

Modules by API surface

examples/matrix_operations.py12 symbols
setup.py3 symbols
examples/seal_helper.py3 symbols
examples/7_serialization.py3 symbols
examples/8_performance.py2 symbols
examples/6_rotation.py2 symbols
examples/4_bgv_basics.py2 symbols
examples/2_encoders.py2 symbols
src/wrapper.cpp1 symbols
examples/5_ckks_basics.py1 symbols
examples/3_levels.py1 symbols
examples/1_bfv_basics.py1 symbols

For agents

$ claude mcp add SEAL-Python \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page