Skip to main content

HECO is an optimizing compiler for Fully Homomorphic Encryption (FHE).

Project description

    __  __________________          __  ________   ______                      _ __         
   / / / / ____/ ____/ __ \   _    / / / / ____/  / ____/___  ____ ___  ____  (_) /__  _____
  / /_/ / __/ / /   / / / /  (_)  / /_/ / __/    / /   / __ \/ __ `__ \/ __ \/ / / _ \/ ___/
 / __  / /___/ /___/ /_/ /  _    / __  / /___   / /___/ /_/ / / / / / / /_/ / / /  __/ /    
/_/ /_/_____/\____/\____/  (_)  /_/ /_/_____/   \____/\____/_/ /_/ /_/ .___/_/_/\___/_/     
                                                                    /_/                     

Language CPP_Standard CI/CD Documentation License: MIT

HECO is an optimizing compiler for Fully Homomorphic Encryption (FHE). FHE allows computation over encrypted data, but imposes a variety of cryptographic and engineering challenges. This compiler translates high-level program descriptions (expressed in Python) into the circuit-based programming paradigm of FHE. It does so while automating as many aspects of the development as possible, including automatically identifying and exploiting opportunities to use the powerful SIMD parallelism ("batching") present in many schemes.

HECO Python Frontend

Note HECO's Python Frontend is still undergoing a major revision. The current version only prints a (almost MLIR) version of the code. We are working on extending the frontend with more functionality and completing the toolchain, such that frontend programs can be executed again.

Finalize Installation

The HECO frontend relies on a development version of xdsl. If you install HECO from PyPi, you need to install the xdsl dependency afterwards with:

python3 -m pip install git+https://github.com/xdslproject/xdsl.git@frontend

Examples

Examples of HECO can be found in the examples folder.

One of them, for computing the hamming distance of two encrypted vectors, is shown here:

from xdsl.frontend import *
from xdsl.frontend.dialects.builtin import *
from heco.frontend.dialects.fhe import *

p = FrontendProgram()

secret_f64 = SecretType[f64]
arg_type = BatchedSecretType[f64]

with CodeContext(p):
    def encryptedHammingDistance(x: arg_type,
                                 y: arg_type) -> secret_f64:
        sum: SecretType[f64] = SecretAttr(FloatAttr(0.0))

        for idx in range(0, 4):
            sum = sum + (x[idx] - y[idx]) * (x[idx] - y[idx])

        return sum

# XXX: the part below was not yet ported to the new frontend

# Compiling FHE code
context = SEAL.BGV.new(poly_mod_degree = 1024)
f = p.compile(context = context)

# Running FHF code
x = [random.randrange(100) for _ in range(4)]
y = [random.randrange(100) for _ in range(4)]
x_enc = context.encrypt(x)
y_enc = context.encrypt(y)
s_enc = f(x_enc, y_enc)

# Verifying Result
s = context.decrypt(s_enc)
assert s == sum([(x[i] - y[i])**2 for i in range(4)])

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

heco-0.0.2.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

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

heco-0.0.2-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: heco-0.0.2.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for heco-0.0.2.tar.gz
Algorithm Hash digest
SHA256 3278dd207d048e7bd88dabe6bf9c6ae86328d6ddf468bc6d3da30f4b1fbcf4d8
MD5 e8ac55933cde3d308390ef056d5c62b8
BLAKE2b-256 80d1efeba2e595b6b1d39d2422cfd9433a2790ac1b13a5680fdb061287d393ad

See more details on using hashes here.

File details

Details for the file heco-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: heco-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for heco-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ec685950f3689aa892b1dad8ce834316f1f2d395e68dda20a452c73e269a1bc2
MD5 1d189ca118ac3224765e51412b0eec8f
BLAKE2b-256 563833429023cce17ad8ef137ec3be15022decdc59a41868cf79fcf378549da5

See more details on using hashes here.

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