+
Skip to content

j2kun/heir

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Standard MLIR dialects for homomorphic encryption

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 51.2%
  • MLIR 31.6%
  • Starlark 6.7%
  • Python 4.4%
  • Jupyter Notebook 2.1%
  • Verilog 1.9%
  • Other 2.1%
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载