Path: blob/main/frontier/11-homomorphic-encryption/connect/seal-google-fhe.ipynb
483 views
Connect: Microsoft SEAL and Google FHE Compiler
Module 11 | Real-World Connections
FHE has moved from theory to production libraries. We survey the ecosystem and show how Module 11's math maps to real API calls.
Introduction
In Module 11 we built toy FHE schemes from scratch: Paillier, BGV-like, BFV-like, and CKKS-like constructions. Production FHE requires much more engineering:
Number Theoretic Transforms (NTT) for fast polynomial multiplication
Relinearization to keep ciphertext size manageable after multiplication
Modulus switching and rescaling for noise management
Batching (SIMD) to encrypt and process many values at once
Several production-quality libraries handle all of this. In this notebook, we survey the major ones and show how Module 11's concepts map to their APIs.
The Major FHE Libraries
| Library | Maintainer | Schemes | Language | License |
|---|---|---|---|---|
| Microsoft SEAL | Microsoft Research | BFV, CKKS | C++ (Python/C# wrappers) | MIT |
| OpenFHE | Duality Technologies / DARPA | BGV, BFV, CKKS, TFHE | C++ (Python wrapper) | BSD |
| HElib | IBM Research | BGV, CKKS | C++ | Apache 2.0 |
| TFHE | Zama | TFHE (gate bootstrapping) | C/C++/Rust | Apache 2.0 |
| Concrete | Zama | TFHE-based | Rust/Python | BSD |
| Lattigo | EPFL/Tune Insight | BGV, BFV, CKKS | Go | Apache 2.0 |
Plus compilers that transpile high-level code to FHE circuits:
Google FHE Compiler: C++ to FHE circuits via TFHE
Concrete ML (Zama): scikit-learn/PyTorch models to FHE
EVA (Microsoft): optimizing compiler for CKKS programs
Microsoft SEAL: BFV and CKKS
SEAL is the most widely used FHE library. It supports two schemes from Module 11:
BFV (exact integer arithmetic):
Plaintexts are integers mod
Operations are exact: (exactly)
Noise budget decreases with each operation (especially multiplication)
Use case: counting, voting, exact database queries
CKKS (approximate real-number arithmetic):
Plaintexts are real/complex numbers
Operations are approximate: result has a small rounding error
Use case: machine learning, scientific computing, statistics
Google's FHE Compiler
Google's transpiler takes standard C++ code and automatically compiles it to FHE circuits. The programmer writes normal code; the compiler handles the cryptography.
Example: an encrypted string capitalization function.
The compiler transforms this into a Boolean circuit using TFHE gates, where each bit of the input and output is encrypted separately. The if statement becomes a multiplexer circuit.
Performance Reality
FHE is dramatically slower than cleartext computation. The overhead comes from:
Large ciphertexts: a single BFV ciphertext is ~32 KB (vs 4 bytes for an int)
Polynomial arithmetic: every operation involves polynomial multiplication mod
NTT transforms: each polynomial multiply needs forward NTT, pointwise multiply, inverse NTT
Relinearization: after each ciphertext-ciphertext multiply, need to reduce ciphertext size
Bootstrapping: the most expensive operation, needed to refresh noise
Detailed Library Comparison
Each library has different strengths depending on your use case.
Concept Map
| Module 11 Concept | Production Library Feature |
|---|---|
| BGV/BFV (integer FHE) | SEAL scheme_type::bfv, OpenFHE BGV |
| CKKS (approximate FHE) | SEAL scheme_type::ckks, Lattigo CKKS |
| Bootstrapping | TFHE (every gate), OpenFHE (configurable) |
| Noise budget | SEAL invariant_noise_budget() |
| Relinearization | SEAL evaluator.relinearize() |
| Modulus switching | SEAL evaluator.mod_switch_to_next() |
| NTT | Used internally by all libraries for fast polynomial multiply |
| SIMD batching | SEAL BatchEncoder, HElib EncryptedArray |
| Plaintext modulus | SEAL set_plain_modulus() |
| Polynomial degree | SEAL set_poly_modulus_degree() |
Summary
| Aspect | Detail |
|---|---|
| SEAL | Microsoft's BFV/CKKS library, most popular, MIT license |
| OpenFHE | DARPA-funded, supports all schemes, most comprehensive |
| TFHE/Concrete | Zama's gate-level bootstrapping, best for Boolean circuits |
| Google FHE | Compiler that transpiles C++ to FHE circuits automatically |
| Performance | 10,000x--1,000,000x overhead, improving rapidly |
| Hardware | DARPA DPRIVE and Intel accelerators aim for 10--100x speedup |
| Key insight | Module 11's math (BGV/BFV/CKKS/noise) is exactly what these libraries implement |
FHE has transitioned from a theoretical curiosity to an engineering discipline. The math from Module 11 --- polynomial rings, noise budgets, modulus switching, bootstrapping --- is the foundation that every production library builds on. Understanding the theory lets you be an informed user of these tools, not just a black-box consumer.