Skip to content
Microsoft SEAL 3.X For Python
C++ Python CMake Shell Batchfile C
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Fix a head file defect Jan 9, 2020
LICENSE Initial commit Jul 15, 2019 Fix a head file defect Jan 9, 2020

Microsoft SEAL For Python

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.

This is a python binding for MS SEAL library.



  • Environment

    SEAL (3.3.2), pybind11 (2.4.3)

    CMake (>= 3.10), GNU G++ (>= 6.0) or Clang++ (>= 5.0), Python (>=3.6.8)

    sudo apt-get update && sudo apt-get install g++ make cmake git python3 python3-dev python3.6-pip

    git clone

  • SEAL

    cd SEAL/native/src
    cmake .
    sudo make install
  • pybind11

    cd src
    pip3 install -r requirements.txt
    cd pybind11
    mkdir build
    cd build
    cmake ..
    make check -j 4
    sudo make install # or not
  • SEAL-Python

    # Check the path at first
    # Building with setuptools
    cd src
    python3 build_ext -i
    # Building with CMake
    cmake .
  • Others

    If you clone a new SEAL lib from the Github, do not forget add a function set_scale in seal/ciphertext.h line 632, like this:

    Set the scale.
    inline void set_scale(double scale)
      scale_ = scale;

    The dynamic link library name:

    The path is very important, please check it before you do anything.


cd tests

python3 [example_name].py

  • The .so file must be in the same folder, or you had install it already.

Getting Started

C++ Python Description Progress
1_bfv_basics.cpp Encrypted modular arithmetic using the BFV scheme Finished
2_encoders.cpp Encoding more complex data into Microsoft SEAL plaintext objects Finished
3_levels.cpp Introduces the concept of levels; prerequisite for using the CKKS scheme Finished
4_ckks_basics.cpp Encrypted real number arithmetic using the CKKS scheme Finished
5_rotation.cpp Performing cyclic rotations on encrypted vectors in the BFV and CKKS schemes Finished
6_performance.cpp Performance tests for Microsoft SEAL Finished


  • Visual Studio build (for windows)
  • SEAL 3.4 or higher support
  • Remove the dependency on wrapped data types (like IntVector)


This project is still testing now, if any problem, Issue



You can’t perform that action at this time.