Skip to main content

The HEIR compiler

Project description

HEIR: Homomorphic Encryption Intermediate Representation

GitHub Workflow Status (with event) GitHub Contributors GitHub Discussions GitHub License OpenSSF Scorecard

An MLIR-based toolchain for homomorphic encryption compilers. Read the docs at the HEIR website.

For more information on MLIR, see the MLIR homepage.

Quickstart (Python)

Pip install the heir_py package

pip install heir_py

Then run an example:

from heir import compile
from heir.mlir import I64, Secret

@compile()  # defaults to scheme="bgv", OpenFHE backend, and debug=False
def func(x: Secret[I64], y: Secret[I64]):
    sum = x + y
    diff = x - y
    mul = x * y
    expression = sum * diff + mul
    deadcode = expression * mul
    return expression

func.setup()
enc_x = func.encrypt_x(7)
enc_y = func.encrypt_y(8)
result_enc = func.eval(enc_x, enc_y)
result = func.decrypt_result(result_enc)

print(
  f"Expected result for `func`: {func.original(7,8)}, FHE result:"
  f" {result}"
)

This will compile the function above using the BGV scheme to machine code via the OpenFHE backend. Then calling the function will encrypt the inputs, run the function, and return the decrypted result. The function call foo(7, 8) runs the entire encrypt-run-decrypt flow for ease of testing.

Quickstart (heir-opt, heir-translate)

The python package heir_py ships with the heir-opt and heir-translate. If you install via virtualenv, the binaries will be in your venv/bin.

venv/bin/heir-opt --help

Supported backends and schemes

Backend Library BGV BFV CKKS CGGI
OpenFHE
Lattigo
tfhe-rs
Jaxite

Note some backends do not support all schemes.

Contributing

There are many ways to contribute to HEIR:

Citations

The HEIR project can be cited in in academic work through following entry:

@misc{ali2025heir,
      title={HEIR: A Universal Compiler for Homomorphic Encryption},
      author={Asra Ali and Jaeho Choi and Bryant Gipson and Shruthi Gorantala
              and Jeremy Kun and Wouter Legiest and Lawrence Lim and Alexander
              Viand and Meron Zerihun Demissie and Hongren Zheng},
      year={2025},
      eprint={2508.11095},
      archivePrefix={arXiv},
      primaryClass={cs.CR},
      url={https://arxiv.org/abs/2508.11095},
}

Support disclaimer

This is not an officially supported Google product.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

heir_py-2026.3.30.dev0.tar.gz (13.7 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

heir_py-2026.3.30.dev0-cp311-abi3-manylinux_2_28_x86_64.whl (36.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ x86-64

heir_py-2026.3.30.dev0-cp311-abi3-manylinux_2_28_aarch64.whl (35.1 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

heir_py-2026.3.30.dev0-cp311-abi3-macosx_11_0_arm64.whl (39.3 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

Details for the file heir_py-2026.3.30.dev0.tar.gz.

File metadata

  • Download URL: heir_py-2026.3.30.dev0.tar.gz
  • Upload date:
  • Size: 13.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for heir_py-2026.3.30.dev0.tar.gz
Algorithm Hash digest
SHA256 37b96f011b5f3adc9309e4c5558c793422e00104dadcc418f9a06ec47222b225
MD5 aba67894fee5bc78b8280f111786fac5
BLAKE2b-256 5d89e02f103b1117e222442899d5ab77c3e72dee91b60bf605b6301d7cb602da

See more details on using hashes here.

Provenance

The following attestation bundles were made for heir_py-2026.3.30.dev0.tar.gz:

Publisher: wheels.yml on google/heir

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file heir_py-2026.3.30.dev0-cp311-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for heir_py-2026.3.30.dev0-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bfb7b0fa7104d19859a0abeb1da8ba9615352a75c5a5e653107585f5c3c02d59
MD5 9c48886dacde0da623c86df3b82dd4e5
BLAKE2b-256 e1b4fa5ba5e321ebc85ff3cc638dafb55c796f736f5e7c17863cb92fd62f4f4c

See more details on using hashes here.

Provenance

The following attestation bundles were made for heir_py-2026.3.30.dev0-cp311-abi3-manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on google/heir

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file heir_py-2026.3.30.dev0-cp311-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for heir_py-2026.3.30.dev0-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 77b3686c0606a48a373d42ba7ebf2f287f2cddb899935de7907bd8214f899fe8
MD5 e9db5784a3d6952c6067d1191a28fda8
BLAKE2b-256 cdcb5e68ffebfbc27d06b4efecb256799f891985da0e087b41564408f362812b

See more details on using hashes here.

Provenance

The following attestation bundles were made for heir_py-2026.3.30.dev0-cp311-abi3-manylinux_2_28_aarch64.whl:

Publisher: wheels.yml on google/heir

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file heir_py-2026.3.30.dev0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for heir_py-2026.3.30.dev0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e521a141a76e629bf3988a7b1f12a3fe3bc0092f9f50f4ad351157a3745a18ad
MD5 7acc383289c244550ef18a6d982047fc
BLAKE2b-256 109975a5e75d0fd1c292f24815cf20e454e2db09f22f414a5c302b8e699e9932

See more details on using hashes here.

Provenance

The following attestation bundles were made for heir_py-2026.3.30.dev0-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: wheels.yml on google/heir

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page