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.4.0rc1-cp311-cp311-manylinux_2_28_x86_64.whl (65.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

concrete_python-2.4.0rc1-cp311-cp311-macosx_11_0_x86_64.whl (48.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

concrete_python-2.4.0rc1-cp310-cp310-manylinux_2_28_x86_64.whl (65.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

concrete_python-2.4.0rc1-cp310-cp310-macosx_11_0_x86_64.whl (48.9 MB view details)

Uploaded CPython 3.10macOS 11.0+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

concrete_python-2.4.0rc1-cp39-cp39-manylinux_2_28_x86_64.whl (65.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

concrete_python-2.4.0rc1-cp39-cp39-macosx_11_0_x86_64.whl (48.9 MB view details)

Uploaded CPython 3.9macOS 11.0+ x86-64

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

Uploaded CPython 3.9macOS 11.0+ ARM64

concrete_python-2.4.0rc1-cp38-cp38-manylinux_2_28_x86_64.whl (65.0 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

concrete_python-2.4.0rc1-cp38-cp38-macosx_11_0_x86_64.whl (48.9 MB view details)

Uploaded CPython 3.8macOS 11.0+ x86-64

concrete_python-2.4.0rc1-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.4.0rc1-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.4.0rc1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 338efffe52e65f005d78029059027e97f972dd9ff17ab2618a7395a139adddcd
MD5 7192456d4987248e5f4df01a7a03cd4d
BLAKE2b-256 2b9f64b7343aa993988619873a3ceb96695accd6eae21c0f4b9ef1598f7b3f68

See more details on using hashes here.

File details

Details for the file concrete_python-2.4.0rc1-cp311-cp311-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.4.0rc1-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 58ecc98def31331dbb8ceba19690a2fb22816ec291591f76cf35673cc566100a
MD5 2b771fbf204e02d07f1f0543bb94e93d
BLAKE2b-256 c893d99b5e0c0e71084ee8e68279b026ee3dd922a2186a058ef40524a4efc883

See more details on using hashes here.

File details

Details for the file concrete_python-2.4.0rc1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for concrete_python-2.4.0rc1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f99ec1b354bbd059170377484b6d012b56e4bab1ac6f76644ee2782f61e43198
MD5 0aedc47c4793adf4aeb5045b3ce607b4
BLAKE2b-256 2cfaac892a641f018afebed6f8b3ee1fa7c2fe04435d2255180f9fe6f21e4a00

See more details on using hashes here.

File details

Details for the file concrete_python-2.4.0rc1-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.4.0rc1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1e2c53e918841f6e658985a70ea17c3bda9652c11b2f3d0e7d051ee671ba87d9
MD5 6a8a8380fe66b5fa928a26b427855c7b
BLAKE2b-256 4a3e57724ea8c708dffd756764d6cbbda48ba6703a403d16a53e11c339236d7f

See more details on using hashes here.

File details

Details for the file concrete_python-2.4.0rc1-cp310-cp310-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.4.0rc1-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 222f0118aaa13cba365e0036851e5228ef9f13501c227dc2e306926956cda9fd
MD5 630016475173d6e56ab56f0f83bf9cba
BLAKE2b-256 8c01a255f821e78088e1ef7c5cba2413049be18c25b23f01a61f5a3fe1b43e24

See more details on using hashes here.

File details

Details for the file concrete_python-2.4.0rc1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for concrete_python-2.4.0rc1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 94d209900fa7562ac97d262603099e2577dc086263230e538d7d0251c4124fa6
MD5 e22fed41da293c40e5a21065661be423
BLAKE2b-256 484ca5efae51dedb4c685d45d2185da870b9520e0a2158db94bfe3b7c755d82f

See more details on using hashes here.

File details

Details for the file concrete_python-2.4.0rc1-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.4.0rc1-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4688a01fc01df53fc42ffbaf980f600ea76c6d3d524169ed388208ec6bd3c509
MD5 33186495db172648cb77d544d9a0a7b6
BLAKE2b-256 86c3cee93199b9619c414d5f114c0fb737e3a3fe2327cfa706ea3b30b3c4badd

See more details on using hashes here.

File details

Details for the file concrete_python-2.4.0rc1-cp39-cp39-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.4.0rc1-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 25e9d6bad4d08bee317317d79cc4ab4c2fa383ecdde54fa9c81287fabc9b5565
MD5 3822fa345239a15838057e6e080dbd52
BLAKE2b-256 966f3439f76204f41e5d925e0b7d1e571e1de3d9001af508bb4b1abf333d093c

See more details on using hashes here.

File details

Details for the file concrete_python-2.4.0rc1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for concrete_python-2.4.0rc1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9b37437aed3187f0638eb6cb96fe938095f22e7ff3616a304931b74cbe520ad9
MD5 ddf98262842b22816f73367e3bf60336
BLAKE2b-256 aa6d9551bf1ad958431321d29aaf7927cdcdcf2f461c474842219433f0f1797f

See more details on using hashes here.

File details

Details for the file concrete_python-2.4.0rc1-cp38-cp38-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.4.0rc1-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ff99675f444b76f25c21a5cf4adc589cf4d393cb819aef5cf6b02f813555636f
MD5 9f7831b698400f56d896c374864661bf
BLAKE2b-256 fb10caa4a821bebd51dd677be5b8f7ffb83c7630804151f428d437114f95cbc9

See more details on using hashes here.

File details

Details for the file concrete_python-2.4.0rc1-cp38-cp38-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.4.0rc1-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 bf676a58382fb52ff46918c6b1f774998947e05e1c28fb99fedc827187b53ef2
MD5 c4c6e7435a5ba59bcf02e74ff5adaa71
BLAKE2b-256 0c2d2481759736606a3ef8b4c8261ee566575b6148db6a04676ef4df633a0707

See more details on using hashes here.

File details

Details for the file concrete_python-2.4.0rc1-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for concrete_python-2.4.0rc1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 45a8e4c3c5ac6aacf47b945d07e1d70efe04c788eca1416df1b7b9037b644e86
MD5 49d2148451a27b389cb268480c6cb100
BLAKE2b-256 a686f1ac4e6d039163a9785293eebbfdbbef68018f6a784af08cfb4bf8db1123

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