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.0.0-cp311-cp311-manylinux_2_28_x86_64.whl (64.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

concrete_python-2.0.0-cp311-cp311-macosx_11_0_x86_64.whl (48.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ x86-64

concrete_python-2.0.0-cp311-cp311-macosx_11_0_arm64.whl (42.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

concrete_python-2.0.0-cp310-cp310-manylinux_2_28_x86_64.whl (64.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

concrete_python-2.0.0-cp310-cp310-macosx_11_0_x86_64.whl (48.8 MB view details)

Uploaded CPython 3.10macOS 11.0+ x86-64

concrete_python-2.0.0-cp310-cp310-macosx_11_0_arm64.whl (42.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

concrete_python-2.0.0-cp39-cp39-manylinux_2_28_x86_64.whl (64.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

concrete_python-2.0.0-cp39-cp39-macosx_11_0_x86_64.whl (48.8 MB view details)

Uploaded CPython 3.9macOS 11.0+ x86-64

concrete_python-2.0.0-cp39-cp39-macosx_11_0_arm64.whl (42.4 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

concrete_python-2.0.0-cp38-cp38-manylinux_2_28_x86_64.whl (64.8 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

concrete_python-2.0.0-cp38-cp38-macosx_11_0_x86_64.whl (48.8 MB view details)

Uploaded CPython 3.8macOS 11.0+ x86-64

concrete_python-2.0.0-cp38-cp38-macosx_11_0_arm64.whl (42.4 MB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for concrete_python-2.0.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 48b422747389d0438ae4953512514be5766b95686d3ee8316beec09d42591399
MD5 965a1f1c84d7ee9a83985b4ffbd5cc0b
BLAKE2b-256 e3d6d835304aeb53c5a429b26d824796f7110826d2a41b7dc66d6c937919afe6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.0.0-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 1190eb801707d130c1c8dd3f15fecfa9ac621e21312c512e0ebe58323efdf8e3
MD5 30bd387b10a9648ded11c8f926b4d383
BLAKE2b-256 0e3f8f8402d3011c1a8de26c8af5c65ee17170be8dcdc94b7ca8d6932e6d90b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.0.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0394f904d1da40ac81aa0053ff60f6001305dda63cd3663a2f488ced01cc0470
MD5 1e41129a00e63de61fae2a575c3c3f85
BLAKE2b-256 966eb6bc23a008e26389bf9ca73e9cae584d9a65a18e949937f033fa443686d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.0.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dcb23ee89ec9f847b831de1944ed59d053a81f60e1782d5bcb8008f511ca6033
MD5 b69b6463829ea71adc1a9bef4e5bd0d0
BLAKE2b-256 829103dd62f80f4362252b12104eb9b080da33d69072a8aaae2dba7986af476b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.0.0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 8d4e4733afa011ab4d8dbbf7ee95002c57536fab1a790d603026aaa6c92ba9c1
MD5 f57b8d327253799364713ce30dbbb7cb
BLAKE2b-256 e5e56c6d4f0ae1202acd85130af54fbc5214bcc98bfd4c8f23467a8044309347

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.0.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3582daa032fb5e819209aead5510fae6aa19a8cbc0295c727e951ab36d80bbb3
MD5 43fb99abfaccad50963a88752726ba20
BLAKE2b-256 a6617c55deb6be15c2dab8a74a665933f0be4b275caefb11808e85b5488b8ed4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.0.0-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f7e859d90459bfe642b98d16cc50557531d8e0e774291a01cca27f40055516b3
MD5 6032844f6970f70d0ac90478815db72a
BLAKE2b-256 207dff4a76d1424f18bf8173d075d057bcdb00fc44432cfc1a8e6c47fd3e75b6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.0.0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 3514c3fece9d8fe8bd06ae6ca6b0cb7cbe1e89ecfb51f5dda46b7f26631e8eff
MD5 ea864e214e59787ad8f552399756d754
BLAKE2b-256 e50ba03944450ad461f0eb14e81c09417da1a4c0149b6b2bff334f8507943d78

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.0.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3f69a9231edd8a9903f09b81b9d0fbc7aa57602a5ae089f8f08d24c2b9da50a6
MD5 1948209cb8c4559f038967ca63e9f646
BLAKE2b-256 004c77f0c1f215e3f64b25fd5a54c2d93e8f044360d34d8822b2baf5bb9ce67f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.0.0-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cbb93e7e2f83a00640c7e089abaa8a3076580a9063a5046f301a6b29e4cd8682
MD5 73a416d57bd215f8b3b3767ae6bc529e
BLAKE2b-256 e64927aa97aba37b6e6cb5041cec6651803f794496fe86049ddbbf874e9b0eca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.0.0-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 968d438b77de17ad81c5fae27accf0fd43ebb7611a52559979d433d6455004e6
MD5 f1b180e55bee0cdf89f45ba070bfeae1
BLAKE2b-256 f96dbac7fafbda15299512f4f4314beccb08df452c84807ab2ae12bc835e2df2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.0.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 48893d59f01d4062b61974971e47d76434b787020c5d3ee9459eb3b552fa7899
MD5 616338fb2afde6c08477ca57f84c2bb1
BLAKE2b-256 1e91dc9642221553737e2e28da718def0cdf00fd074c8420f5052c9d9b2d2858

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