I tried out SEAL, a library for homomorphic encryption published by Microsoft. The idea is to install it on a laptop and run a simple example.
The SEAL library is written in C++.
I'm following the instructions for MacOS and Linux in the SEAL README.md.
Prerequisites are cmake
and a new compiler, a modern version of GNU G++ (>= 6.0) or Clang++ (>= 5.0) is needed. In macOS the Xcode toolchain (>= 9.3) will work. Microsoft SEAL compiled with Clang++ has much better runtime performance than that compiled with GNU G++.
-
Install helper tools on MacOS:
- Xcode Command Line Tools
xcode-select --install
- cmake >= 3.17.3
brew install cmake
- Apple clang
$ clang -v Apple clang version 12.0.0 (clang-1200.0.32.2) Target: x86_64-apple-darwin19.6.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin
-
Install helper tools on Ubuntu:
sudo apt-get update sudo apt-get install g++ cmake
-
Clone repo
git clone git@github.com:microsoft/SEAL.git
-
Compile the library including examples (on either MacOS or Ubuntu):
cd SEAL/ cmake . -DSEAL_BUILD_EXAMPLES=ON
-
Compile
make -j # on MacOS
or
make # on Ubuntu (otherwise it hangs on my machine)
-
Then install the library system wide (requires root access).
sudo make install
The sealexamples
executable is located in native/bin/
.
- Write your first program with SEAL following these instructions.
- Create a test repo and a file called
sealdemo.cpp
.with the following content:mkdir SEALdemo vi sealdemo.cpp
#include "seal/seal.h" #include <iostream> using namespace std; using namespace seal; int main() { EncryptionParameters parms(scheme_type::BFV); return 0; }
- Create a cmake file
CMakeLists.txt
.cmake_minimum_required(VERSION 3.12) cmake_minimum_required(VERSION 3.10) project(SEALDemo VERSION 1.0) add_executable(sealdemo sealdemo.cpp) find_package(SEAL) target_link_libraries(sealdemo SEAL::seal)
- Compile and run.
Obviously there's no output. But it's a first minimal program using the SEAL library.
cmake . make ./sealdemo
Responsible for the content of the page is Christiane Peters.