Microsoft SEAL is the leading open-source homomorphic encryption library, providing production-ready implementations of the BFV, BGV, and CKKS HE schemes with a developer-friendly C++ and Python API. This tutorial covers SEAL from installation through to practical HE implementations for the enterprise use cases where homomorphic encryption is currently practical — private ML inference, encrypted aggregation, and secure multi-party computations. Benchmarks included so you can assess feasibility before committing engineering resources.
Microsoft SEAL Overview
seal pip package. SEAL is maintained by Microsoft Research, used in production by financial institutions for private computation, and is the most documented HE library available.Installation
Clone: git clone https://github.com/microsoft/SEAL. Build: cmake -S . -B build -DSEAL_BUILD_EXAMPLES=ON && cmake --build build --parallel. CMake options: -DSEAL_USE_INTEL_HEXL=ON for Intel hardware acceleration (recommended on Intel CPUs — 2–4× performance improvement). Run examples: ./build/bin/sealexamples. Link your application against SEAL::seal in CMakeLists.txt. Requires: CMake 3.13+, C++17 compiler (GCC 7+, Clang 5+, MSVC 2019+).
Python bindings via TenSEAL (easier) or the official seal-python package: pip install tenseal. TenSEAL wraps SEAL with a tensor-friendly API and direct PyTorch integration for ML workloads. Import: import tenseal as ts. Create CKKS context: context = ts.context(ts.SCHEME_TYPE.CKKS, poly_modulus_degree=8192, coeff_mod_bit_sizes=[60,40,40,60]). TenSEAL is the recommended entry point for ML/data science teams new to HE.
CKKS for ML Inference: Code Pattern
CKKS is the most practical HE scheme for ML because it supports approximate real-number arithmetic — the only scheme that can execute neural network inference on encrypted data.
| CKKS Parameter | Effect | Enterprise Recommendation |
|---|---|---|
| poly_modulus_degree | Security and capacity — higher = more secure + more computation | 8192 for low depth; 16384 for deep networks; 32768 for very deep |
| coeff_mod_bit_sizes | Multiplicative depth budget — number of layers you can evaluate | [60,40,40,60] for 2 multiplications; add 40s for more depth |
| scale | Precision of floating-point encoding | 2^40 for good precision; 2^20 for faster computation |
| Batch size | Number of values encrypted together (SIMD) | poly_modulus_degree / 2 — maximise for throughput |
- Linear and polynomial regression inference on encrypted data
- Simple neural networks with polynomial activation approximations
- Statistical aggregation (mean, variance) on encrypted datasets
- Encrypted salary/medical data surveys
- Deep neural networks (ResNet, transformers) — too many multiplication levels
- Real-time inference (<100ms) — HE computation too slow
- Large batch sizes — memory requirements scale with poly_modulus_degree
Our software development and ML development teams assess HE feasibility for specific enterprise use cases and implement SEAL/TenSEAL solutions for private computation. Book a free advisory session.