Skip to main content

A state-of-the-art homomorphic encryption framework

Project description


📒 Read documentation | 💛 Community support | 📚 FHE resources


Concrete is an open-source FHE Compiler which simplifies the use of fully homomorphic encryption (FHE).

FHE is a powerful cryptographic tool, which allows computation to be performed directly on encrypted data without needing to decrypt it first. With FHE, you can build services that preserve privacy for all users. FHE is also great against data breaches as everything is done on encrypted data. Even if the server is compromised, in the end no sensitive data is leaked.

Since writing FHE programs can be difficult, Concrete, based on LLVM, make this process easier for developers.

Main features

  • Ability to compile Python functions (that may include NumPy) to their FHE equivalents, to operate on encrypted data
  • Support for large collection of operators
  • Partial support for floating points
  • Support for table lookups on integers
  • Support for integration with Client / Server architectures

Installation

OS / HW Available on Docker Available on PyPI
Linux Yes Yes
Windows Yes Coming soon
Windows Subsystem for Linux Yes Yes
macOS 11+ (Intel) Yes Yes
macOS 11+ (Apple Silicon: M1, M2, etc.) Yes Yes

The preferred way to install Concrete is through PyPI:

pip install -U pip wheel setuptools
pip install concrete-python

You can get the concrete-python docker image by pulling the latest docker image:

docker pull zamafhe/concrete-python:v2.0.0

You can find more detailed installation instructions in installing.md

Getting started

from concrete import fhe

def add(x, y):
    return x + y

compiler = fhe.Compiler(add, {"x": "encrypted", "y": "encrypted"})
inputset = [(2, 3), (0, 0), (1, 6), (7, 7), (7, 1), (3, 2), (6, 1), (1, 7), (4, 5), (5, 4)]

print(f"Compiling...")
circuit = compiler.compile(inputset)

print(f"Generating keys...")
circuit.keygen()

examples = [(3, 4), (1, 2), (7, 7), (0, 0)]
for example in examples:
    encrypted_example = circuit.encrypt(*example)
    encrypted_result = circuit.run(encrypted_example)
    result = circuit.decrypt(encrypted_result)
    print(f"Evaluation of {' + '.join(map(str, example))} homomorphically = {result}")

or if you have a simple function that you can decorate, and you don't care about explicit steps of key generation, encryption, evaluation and decryption:

from concrete import fhe

@fhe.compiler({"x": "encrypted", "y": "encrypted"})
def add(x, y):
    return x + y

inputset = [(2, 3), (0, 0), (1, 6), (7, 7), (7, 1), (3, 2), (6, 1), (1, 7), (4, 5), (5, 4)]

print(f"Compiling...")
circuit = add.compile(inputset)

examples = [(3, 4), (1, 2), (7, 7), (0, 0)]
for example in examples:
    result = circuit.encrypt_run_decrypt(*example)
    print(f"Evaluation of {' + '.join(map(str, example))} homomorphically = {result}")

Documentation

Full, comprehensive documentation is available at https://docs.zama.ai/concrete.

Target users

Concrete is a generic library that supports a variety of use cases. Because of this flexibility, it doesn't provide primitives for specific use cases.

If you have a specific use case, or a specific field of computation, you may want to build abstractions on top of Concrete.

One such example is Concrete ML, which is built on top of Concrete to simplify Machine Learning oriented use cases.

Tutorials

Various tutorials are proposed in the documentation to help you start writing homomorphic programs:

If you have built awesome projects using Concrete, feel free to let us know and we'll link to it.

Project layout

concrete project is a set of several modules which are high-level frontends, compilers, backends and side tools.

  • frontends directory contains a python frontend.
  • compilers directory contains the concrete-compiler and concrete-optimizer modules. concrete-compiler is a compiler that:
    • synthetize a FHE computation dag expressed as a MLIR dialect
    • compile to a set of artifacts
    • and provide tools to manipulate those artifacts at runtime. concrete-optimizer is a specific module used by the compiler to find the best, secure and accurate set of cryptographic parameters for a given dag.
  • The backends directory contains implementations of cryptographic primitives on different computation unit, used by concrete-compiler runtime. concrete-cpu module provides CPU implementation, while concrete-cuda module provides GPU implementation using the CUDA platform.
  • The tools directory contains side tools used by the rest of the project.

Need support?

Citing Concrete

To cite Concrete in academic papers, please use the following entry:

@Misc{Concrete,
  title={{Concrete: TFHE Compiler that converts python programs into FHE equivalent}},
  author={Zama},
  year={2022},
  note={\url{https://github.com/zama-ai/concrete}},
}

License

This software is distributed under the BSD-3-Clause-Clear license. If you have any questions, please contact us at hello@zama.ai.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

concrete_python-2.5.1-cp311-cp311-manylinux_2_28_x86_64.whl (65.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

concrete_python-2.5.1-cp311-cp311-macosx_11_0_x86_64.whl (49.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ x86-64

concrete_python-2.5.1-cp311-cp311-macosx_11_0_arm64.whl (43.1 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

concrete_python-2.5.1-cp310-cp310-manylinux_2_28_x86_64.whl (65.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

concrete_python-2.5.1-cp310-cp310-macosx_11_0_x86_64.whl (49.8 MB view details)

Uploaded CPython 3.10macOS 11.0+ x86-64

concrete_python-2.5.1-cp310-cp310-macosx_11_0_arm64.whl (43.1 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

concrete_python-2.5.1-cp39-cp39-manylinux_2_28_x86_64.whl (65.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

concrete_python-2.5.1-cp39-cp39-macosx_11_0_x86_64.whl (49.8 MB view details)

Uploaded CPython 3.9macOS 11.0+ x86-64

concrete_python-2.5.1-cp39-cp39-macosx_11_0_arm64.whl (43.1 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

concrete_python-2.5.1-cp38-cp38-manylinux_2_28_x86_64.whl (65.5 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

concrete_python-2.5.1-cp38-cp38-macosx_11_0_x86_64.whl (49.8 MB view details)

Uploaded CPython 3.8macOS 11.0+ x86-64

concrete_python-2.5.1-cp38-cp38-macosx_11_0_arm64.whl (43.1 MB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

Details for the file concrete_python-2.5.1-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 34f8774fd68bfc9e281c51f4766ea4739ff869ceab589fac7976a1b6825a2959
MD5 578812f3fbb93bcb1cb7daa98e93741c
BLAKE2b-256 3454f0085e3014ef01715097f52225a99e444d292b10a8fe015b3ce286d89edc

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.1-cp311-cp311-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.1-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 a9953917ac3eecbb2424f2efd8dfb9cbff02b98a7e8c140684f87112ad1a125d
MD5 8e19a94bc117f0429b2425820fc26b31
BLAKE2b-256 34860dc6ebb3c49b8b89e2170dcf1a35b46bdb4d961e29e30f9b1effdfd5d373

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bf13c62a46c5a5a249d749a34f5671d080a767a7996bf4c0878aeaaddbd672ab
MD5 e87ac0292ad7af1607a0d66afd8747c7
BLAKE2b-256 430998a0a3a3bbd673c497e10a04acbaa77b2cc31e74a514dd04861fb15bd991

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.1-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6cef83fceea20aa6806d24e96784394f759c7cbd734f194ef8efb2fff5619198
MD5 a702fd3d44227419015ca66cb9f686ed
BLAKE2b-256 77337c240173e507260ba6fcb67a51794092689519fed17a3eecb018cf0e6973

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.1-cp310-cp310-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.1-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 235bf2b65fa9a5510e46b47155fda75a52e2dce018b9b553b1ee0b4496d12335
MD5 e66c20fb1876c7c75c3b2b24a6afd268
BLAKE2b-256 408cf5ff758bbf01863f9e9ecfac0eb9acdfa90c796a8a7131826af492bf76ae

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7251d8ee55c9773dc9bcb771b286200068cbc70a352969489ba5a8d40ccb99c0
MD5 c89937a341dba71847856b4af00da1d0
BLAKE2b-256 a8c61cb0a20da067a029d5f479e38b1d296a20ab927099ce5d85375a1ecd9617

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.1-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.1-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0ec8dbcdf7ce225aa3e2b72c82aa79e340dc6595b1c0e392b93fe9eb9dd72f4c
MD5 9a644b2f052e9712a60283984131a478
BLAKE2b-256 6a5d2cf8bf45d81d922ee531dfd4acbcae7357eadb4d2c805f454c72cea330dc

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.1-cp39-cp39-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.1-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 5b465e7181eab814b0a9bd1d1215e2bdde89e1ba7c7bf068081664003c64fcca
MD5 cbee490b224f449fae7d3efc9bf8380e
BLAKE2b-256 c2c5f789c0452f0172757bbf5a1e2a4612de74efb9247a496cd784c807d55b77

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2482e4eb518038a7f4f5c4fa647fe0ffce0acb49c3b3b657a3e49206b2856c86
MD5 bde09249749177dc3257584c9964b7f5
BLAKE2b-256 6ec0ce816287fc996c5ab60fb04ad10698d0093659a7614e89f972b3bcdec33c

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.1-cp38-cp38-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.1-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 67a89c6030374d356e0164fba5f8779ac1acf2e7994d2fd0129c7218b3f6890f
MD5 12617d37468ed956d67a576f0093ead3
BLAKE2b-256 98a59ece505aaf50255588d8f5327c296db2df0b6eae275a96cdbb422689d5fb

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.1-cp38-cp38-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.1-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 0ebdf576daedc5b3d487ea9217c31ffca4f6bb0dd633d00c50f095373ce004c4
MD5 e4d81448626114d5f12079ba613e8523
BLAKE2b-256 8ba01d6c8ce28228533eda41980187c22b20281ae137de40ce1b33769b3e354a

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.1-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ad0126a84b15500d0aeea480057df45ab3aa8628228ef726a3a2f254f7a6ecd6
MD5 9759182e9031dca8ff18c61c24261517
BLAKE2b-256 440cd8aabfa52a03297fa5c2e7bc4c13bf74c744ac0090a63c6505b981d88d3b

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