HEIR
An MLIR-based compiler toolchain that compiles high-level programs into fully homomorphic encryption (FHE) equivalents.
At a Glance
About HEIR
HEIR (Homomorphic Encryption Intermediate Representation) is an open-source, MLIR-based compiler toolchain for fully homomorphic encryption. The HEIR codebase and documentation are maintained by Google, though the README notes it is not an officially supported Google product. It targets application developers, compiler engineers, hardware designers, and cryptography researchers.
What It Is
HEIR is a compiler infrastructure for FHE. Its stated goal is to compile high-level programs into encrypted equivalents and to generate code for standard FHE libraries and hardware accelerators. The project describes a path where a developer writes a program in Python, annotates types to mark which are secret, and HEIR compiles the rest.
Backends and Schemes
The README lists supported backend libraries and the schemes each handles: OpenFHE and Lattigo support BGV, BFV and CKKS, while tfhe-rs and Jaxite support CGGI. The documentation also covers a set of dialects (including BGV, CKKS, CGGI, LWE, Polynomial, ModArith and RNS) and compiler passes, along with design notes on ciphertext management, packing, noise analysis and relinearization optimization.
Setup Path
There are three documented ways to use HEIR: use Bazel with rules_heir and the OpenFHE or Lattigo backends; install OpenFHE and use the heir_py Python package; or build from source and invoke the heir-opt and heir-translate binaries directly, integrating the generated backend code manually. Building from source uses Bazel and depends on LLVM.
Research and Community
HEIR is also positioned as a platform for FHE research and benchmarking, implementing standard optimizations from the literature. The project holds monthly meetings and weekly office hours, and accepts contributions through GitHub.
Community Discussions
Be the first to start a conversation about HEIR
Share your experience with HEIR, ask questions, or help others learn from your insights.
Pricing
Open Source
HEIR compiler toolchain for homomorphic encryption, released under the Apache License 2.0 and free to use, modify and distribute.
- Apache License 2.0
- Self-hosted: build from source, use via bazel/rules_heir, or install the heir_py Python package
- Backends: OpenFHE, Lattigo, tfhe-rs, Jaxite
- Maintained by Google; not an officially supported Google product
Capabilities
Key Features
- MLIR-based compiler toolchain for fully homomorphic encryption
- Compiles high-level programs to encrypted equivalents
- Python front end with secret type annotations
- Code generation for OpenFHE, Lattigo, tfhe-rs and Jaxite backends
- Support for BGV, BFV, CKKS and CGGI schemes
- Lower-level dialects for polynomial and RNS arithmetic
- Noise analysis and ciphertext management
- Platform for FHE research and benchmarking
- Hardware accelerator code generation goals (GPU, TPU, FPGA, ASIC)
Integrations
Demo Video

