Skip to main content

A state-of-the-art homomorphic encryption framework

Project description


📒 Read documentation | 💛 Community support


:warning: Starting from v1, Concrete Rust Libraries are now deprecated and replaced by TFHE-rs, Concrete is now, exclusively, Zama TFHE Compiler. Read full announcement here

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 No
Windows Subsystem for Linux Yes Yes
macOS (Intel) Yes Yes
macOS (Apple Silicon) Yes Yes

The preferred way to install Concrete is through PyPI:

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.0rc2-cp311-cp311-manylinux_2_28_x86_64.whl (65.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

concrete_python-2.5.0rc2-cp311-cp311-macosx_11_0_x86_64.whl (49.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ x86-64

concrete_python-2.5.0rc2-cp311-cp311-macosx_11_0_arm64.whl (43.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

concrete_python-2.5.0rc2-cp310-cp310-manylinux_2_28_x86_64.whl (65.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

concrete_python-2.5.0rc2-cp310-cp310-macosx_11_0_x86_64.whl (49.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ x86-64

concrete_python-2.5.0rc2-cp310-cp310-macosx_11_0_arm64.whl (43.0 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

concrete_python-2.5.0rc2-cp39-cp39-manylinux_2_28_x86_64.whl (65.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

concrete_python-2.5.0rc2-cp39-cp39-macosx_11_0_x86_64.whl (49.4 MB view details)

Uploaded CPython 3.9macOS 11.0+ x86-64

concrete_python-2.5.0rc2-cp39-cp39-macosx_11_0_arm64.whl (43.0 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

concrete_python-2.5.0rc2-cp38-cp38-manylinux_2_28_x86_64.whl (65.3 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

concrete_python-2.5.0rc2-cp38-cp38-macosx_11_0_x86_64.whl (49.4 MB view details)

Uploaded CPython 3.8macOS 11.0+ x86-64

concrete_python-2.5.0rc2-cp38-cp38-macosx_11_0_arm64.whl (43.0 MB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

Details for the file concrete_python-2.5.0rc2-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.0rc2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 44eaaa7c14cfd8208daaa775e2a587caf774f4cf771c702b6a1e7778fa5b5da7
MD5 79bd2df1f43dfe569f9eb9fb8f86e24c
BLAKE2b-256 6d1b9f52ac691efb8e28bae618f95a8e1d93159c81b0ba6fe8ddaa1b2e79ea68

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.0rc2-cp311-cp311-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.0rc2-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 d3f56ec30db9391c49d4b7288d6b1eb6f3b75bca345a485cfba95ad00dd8ecca
MD5 37224eae5d30dbdbb8e0c1f97384b5ef
BLAKE2b-256 6158513a722db1e1d21d845118f946c92a3e0c7e8af559fe3510a988c773e5c7

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.0rc2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.0rc2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c15c692bd58c9af1c9ed636683024adba3a6aad8224c95104fc55b24dc802ef0
MD5 f02203871e70ca16f848b1311ef55f9a
BLAKE2b-256 3de3cfc612a36ae6df2f71d4591c78be88244f0cef75e6f6a388adf476c153a7

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.0rc2-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.0rc2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1cd681db71afecc3f3592fb20ec87d84c3ad4b95e12f7db8a28856960eede185
MD5 f13369a0ee35161027249f029aca8912
BLAKE2b-256 22762de886721195e9bd5ccff2afe60a585047c750816b25ebc75cf66c2a3d88

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.0rc2-cp310-cp310-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.0rc2-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 6a1c8a9bfc71dc9b72709003255ec8d437fa9912d36414a552dfd4f5008095d3
MD5 aa4b90290e2b793762e5747eeb4864a5
BLAKE2b-256 0af791c6ceab8b7e53ab7f486a72ba73f6ef334c570d711ae4e24e115194a5f0

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.0rc2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.0rc2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8c8605633ecd43ad8b749ff85074227f2345f9d46c752fcb8972cd32ab84702e
MD5 b8eafb3d3481ebc07438a8c37b432855
BLAKE2b-256 b45d2539e6a878a3cbe60ecd979befdd0be2ce18d967bac33fe431ee496041b9

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.0rc2-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.0rc2-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cae76016f85a5dc07bc6da44650107e9874326b195e1f033cc296c278bb80306
MD5 9b4a4a85a6742f54bee724a0892d4556
BLAKE2b-256 47a24e3ecf8b393b7a2ded7d9f51bf5db5e2334d8c596b74d53b03994b2e6942

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.0rc2-cp39-cp39-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.0rc2-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 25360c5b07939c9b700185fafa042d2134e7bcec1cb4baff53c7885defa51f36
MD5 ad4fbfd2893fd8e015de57020718eac0
BLAKE2b-256 ba9a3f24ace22b79a0abec075b8dc1f05f58e3f4071b6065dd712d546484e5ae

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.0rc2-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.0rc2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 41aab449f981e6eec904156633dd1cf6628fc1b62c23d6e2d59cab964320db01
MD5 362221360ae2b5ac846cddcb7b188afc
BLAKE2b-256 be16b632cfd289feab57e64451bc9b824dd1181ee067d1dd7565d6a61d23521d

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.0rc2-cp38-cp38-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.0rc2-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6d73446e665a4d659efc95cbf06e504582e400a024ae8451c8a47df31ed91a7b
MD5 5b3b9e1484853944020f81ce37af6d99
BLAKE2b-256 3b2b847df828ec0f7b44003c2675be429b9793d4c595cc93d9807f781d299b83

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.0rc2-cp38-cp38-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.0rc2-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 372fad620f0063e1bf46fb2c5c8e6dd4f1a792b38a7eab839090d911ca7bc145
MD5 302230d699cd2c27ce089101dae07754
BLAKE2b-256 0ab41379dc9ded83f7a14a5ea8720327545a138f1199e83ad730583f349c2171

See more details on using hashes here.

File details

Details for the file concrete_python-2.5.0rc2-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.0rc2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d4546af6f58e0b565290f96e6efdfbbc2ae2f25649063aafe19c72ac337681c9
MD5 46baf95301b03191665f03dae1a4ebeb
BLAKE2b-256 467b301c4aa987ee8d609df956daacab982a581024c80e26ef276117478787ae

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