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

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

concrete_python-2.5.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.5.0rc1-cp311-cp311-macosx_11_0_arm64.whl (42.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

concrete_python-2.5.0rc1-cp310-cp310-manylinux_2_28_x86_64.whl (64.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

concrete_python-2.5.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.5.0rc1-cp310-cp310-macosx_11_0_arm64.whl (42.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

concrete_python-2.5.0rc1-cp39-cp39-manylinux_2_28_x86_64.whl (64.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

concrete_python-2.5.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.5.0rc1-cp39-cp39-macosx_11_0_arm64.whl (42.4 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

concrete_python-2.5.0rc1-cp38-cp38-manylinux_2_28_x86_64.whl (64.6 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

concrete_python-2.5.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.5.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.5.0rc1-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.0rc1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a0fd46216bda3bd653b20d049954556870c83c0f9364ce11c3c4566acf76340f
MD5 7440634a42546142cb4106e5ace3cd68
BLAKE2b-256 b14188dbe40bf595965293718e7b3aeb55792d0b46ff03ab4dc73300c9d28722

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc1-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 77afc0156230c74055d03adb2446a68de818ca57b63c751abb345fcffc98d43f
MD5 b08a8a6844a19ac93067b81d88b79253
BLAKE2b-256 b6c6dcaf8c3c7fb0f65ba9d2d9e3a3554a562eca1a4d8b5bf6496664d922030b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 415a805362c29958c2c276e7a22a6fab930772641e6992ec1166f330cba30840
MD5 372f3268389c7ae7b0a7248e71220f0c
BLAKE2b-256 f14c15301def49e3c3f44b17497735aa6aebf2a3412825895ff21892d77fc47b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 959eb01f5b141bfbeda97134b6f12eca8fe6658403c3245c6d8cd350c3ba4712
MD5 6d9b2d62f11565fc7b6bed867d63a0bf
BLAKE2b-256 9cf99a4dd7c2b465f1a79b6598aefed1c2bd6ee329d31ca0c0a37fc20e064251

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc1-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 c826475edb8fc707e5dde6e7b656bf370319665d1136a4150e6d9160b6957cc2
MD5 62c03f3b3f912e618195ca62fb999295
BLAKE2b-256 da9aa3f4feb6d1489433bf7e22c1f98ea31a4d7ba109b5e17a17b4aed47d2db9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4165e0ebd5904fb88ccd4ac2b987aa1e4f39ca50f7afa5834fc23d6645dda657
MD5 ca6d3ef6078df3d0002e96c1509042a9
BLAKE2b-256 ddd61a7f8f53b3c0b299bbfc4722fa9c3e433a76b882dd0a3a23c4b5f3ababdb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc1-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1a823df58a742ad65e09c7f098140e8f8c565705bdc2bf13c954f5ac32e285b7
MD5 7c88ebfcd5b15b1c2687c5fbb9ee6763
BLAKE2b-256 928f168ea4c08cd20960617a40590d038d96d7cb9138f25b4ffc7b4738a630ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc1-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 0556618c065e54abe3cbba6b1f5e17a2a77ade5936108bb27f401c084d686471
MD5 edd13cf8a5adbd17651040d245f45960
BLAKE2b-256 64ac2972a0efb7d5954edd922f2ea86df533b11ee6330ff3382114f504644c4b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 92c8acd325bbebf04ea9acf30f012ffb54a645083c64c0020c5233790af5eae1
MD5 1489397f351f4f0d2294307ce02c3565
BLAKE2b-256 71195fb2fc4acdeb1b1778e4316a40487bbb12f48406759c797f33db301f58c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc1-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0e6e48969f8f3e44cc6c40dd5c25e3c72b6db37658562b0652ea40f50bc403e7
MD5 c0bdfb4097d66fd5f0cffbbf77f9ebfc
BLAKE2b-256 48067b1de16bbe20bb421f56831735e27d818b59cd2c04fdbbbc0778e89dcf5f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc1-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 40e461a0f2338e1095b21e29b8a2f364b5e1c99985f84cdbebd59ff28eb11e33
MD5 18a9327e5dd3d15b0d9713f4b21be2da
BLAKE2b-256 e611e7207301b81258379c32cb23c6f1011e2ce1269f3af5e57f826b43f07295

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c2bd7e1acf40f335c5421a843017001dfbdfc8655b38c58e97055a3a1f949aaa
MD5 101ddfae22bd62a6bac4496f6a03b6f2
BLAKE2b-256 c78bb4bc87b8fa38177520648050ebfc1137a385fe50f77c57eee085764dcf43

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