# HEIR

> An MLIR-based compiler toolchain that compiles high-level programs into fully homomorphic encryption (FHE) equivalents.

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.

## 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
OpenFHE, Lattigo, tfhe-rs, Jaxite, Bazel, MLIR, LLVM, heir-py

## Platforms
API, DEVELOPER_SDK, CLI

## Pricing
Open Source

## Version
v2026.10.01

## Links
- Website: https://heir.dev/
- Documentation: https://heir.dev/docs/
- Repository: https://github.com/google/heir
- EveryDev.ai: https://www.everydev.ai/tools/heir
