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 F32, I16, I64, Secret

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

foo.setup()
enc_a = foo.encrypt_a(7)
enc_b = foo.encrypt_b(8)
result_enc = foo.eval(enc_a, enc_b)
result = foo.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{HEIR,
  title={{HEIR: Homomorphic Encryption Intermediate Representation}},
  author={HEIR Contributors},
  year={2023},
  note={\url{https://github.com/google/heir}},
}

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-0.0.2.tar.gz (47.7 kB view details)

Uploaded Source

Built Distributions

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

heir_py-0.0.2-cp311-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (69.8 MB view details)

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

heir_py-0.0.2-cp311-abi3-macosx_11_0_arm64.whl (62.5 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

Details for the file heir_py-0.0.2.tar.gz.

File metadata

  • Download URL: heir_py-0.0.2.tar.gz
  • Upload date:
  • Size: 47.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for heir_py-0.0.2.tar.gz
Algorithm Hash digest
SHA256 83157635c13cb19d5522e60d85827e8f9db2b8660a94cae6157a2dd3332acaf3
MD5 1f2bcbe4bd732db62cf3872ddbc48536
BLAKE2b-256 f904d356717149a223692cdb5c9cfc7b940a3ccc861090f4a52c42b667daa8b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for heir_py-0.0.2.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-0.0.2-cp311-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for heir_py-0.0.2-cp311-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f5d9f95edc958757387b60cb00859443decd2255bf4e54c985c30db8b7597a6e
MD5 40e67fa0d252e097b2cfd05d5cf0c45e
BLAKE2b-256 fa5f0b8adee41af84b50e347d7143defe74e94906bff51fd9485556558dac3ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for heir_py-0.0.2-cp311-abi3-manylinux_2_27_x86_64.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-0.0.2-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for heir_py-0.0.2-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8787777211bc9bc6af17dd38af97e1628b9644a1ba484985f0d6ea22dd791992
MD5 5b5f0518970f2d5f91aee4f5ec1b2146
BLAKE2b-256 0176cfa50380a5cca861dc8ef7b6779ef550d4aa409e61d4b6469b8f3ed6fc24

See more details on using hashes here.

Provenance

The following attestation bundles were made for heir_py-0.0.2-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