A state-of-the-art homomorphic encryption framework
Project description
📒 Documentation | 💛 Community support | 📚 FHE resources by Zama
About
What is Concrete
Concrete is an open-source FHE Compiler that simplifies the use of fully homomorphic encryption (FHE). Concrete framework contains a TFHE Compiler based on LLVM, making writing FHE programs an easy task for developers.
Fully Homomorphic Encryption (FHE) enables performing computations on encrypted data directly without the need to decrypt it first. FHE allows developers to build services that ensure privacy for all users. FHE is also an excellent solution against data breaches as everything is performed on encrypted data. Even if the server is compromised, no sensitive data will be leaked.
Concrete is a versatile library that can be used for a variety of purposes. For instance, Concrete ML is built on top of Concrete to simplify Machine-Learning oriented use cases.
Table of Contents
Getting Started
Installation
Depending on your OS, Concrete may be installed with Docker or with pip:
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.) | Coming soon | Yes |
Pip
The preferred way to install Concrete is through PyPI:
pip install -U pip wheel setuptools
pip install concrete-python
Docker
You can get the concrete-python docker image by pulling the latest docker image:
docker pull zamafhe/concrete-python:v2.0.0
Find more detailed installation instructions in this part of the documentation
A simple example
To compute on encrypted data, you first need to define the function you want to compute, then compile it into a Concrete Circuit, which you can use to perform homomorphic evaluation. Here is the full example:
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}")
This example is explained in more detail in this part of the documentation.
Resources
Concrete deep dive
- Part I: Concrete, Zama's Fully Homomorphic Compiler
- Part II: The Architecture of Concrete, Zama's Fully Homomorphic Encryption Compiler Leveraging MLIR
Tutorials
- [Video tutorial] Dive into Concrete - Zama's Fully Homomorphic Encryption Compiler
- [Video tutorial] How To Get Started With Concrete - Zama's Fully Homomorphic Encryption Compiler
- The Encrypted Game of Life in Python Using Concrete
- Encrypted Key-value Database Using Homomorphic Encryption
- SHA-256 Implementation Using Concrete
Explore more useful resources in Concrete tutorials and Awesome Zama repo. If you have built awesome projects using Concrete, please let us know and we will be happy to showcase them here!
Documentation
Full, comprehensive documentation is available at https://docs.zama.ai/concrete.
Working with Concrete
Citations
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}},
}
Contributing
There are two ways to contribute to Concrete. You can:
- Open issues to report bugs and typos, or to suggest new ideas
- Request to become an official contributor by emailing hello@zama.ai.
Becoming an approved contributor involves signing our Contributor License Agreement (CLA)). Only approved contributors can send pull requests (PRs), so get in touch before you do!
Additionally, you can contribute to advancing the FHE space with Zama by participating in our Bounty Program and Grant Programs!
License
This software is distributed under the BSD-3-Clause-Clear. Check for more details
If you have any questions, please contact us at hello@zama.ai.
Support
🌟 If you find this project helpful or interesting, please consider giving it a star on GitHub! Your support helps to grow the community and motivates further development.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for concrete_python-2.6.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da3eb967c811c7e547210ba3ec968b722ec1d9208593d2976c88f9568adfdaba |
|
MD5 | 2a6de21d661bad897434df495171119e |
|
BLAKE2b-256 | e310c3e34663767ae6568438ff93df093f426057b3c2e1a77e4ffc1e4669211f |
Hashes for concrete_python-2.6.0-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ca5048ae39dc89204020a799c408c1f919d3e65bdf6c0b542e250e58cb70098 |
|
MD5 | a0cf3c398298c5fcd77b543a36eb4ef1 |
|
BLAKE2b-256 | a403462e5c5e9c0ec927a9f74f8a6411d15fcf1105eba1f172f8d6fb19a5c38a |
Hashes for concrete_python-2.6.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51086737dc044ddd56b16461aff5d0dc23fbc18a399a04ca528d27cae1395428 |
|
MD5 | 6baf747dff723cf3587a86b132e90bad |
|
BLAKE2b-256 | e0772381eb2659274cd8bb06b15ea9877d04f1c658c39e6ff23795f952f2fa37 |
Hashes for concrete_python-2.6.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1a71c3fd4db8f8959167dcb0dbdb0502dc62657b52827fc51300893f7a85c6f |
|
MD5 | 1f739a3aebeb6bc50333d71053534464 |
|
BLAKE2b-256 | e955eb96a35f5414f354b3393d23eb2c729b9ac7ddf4fadf41bec8f5a07a1ad3 |
Hashes for concrete_python-2.6.0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a13c156c6442fea198f08feeaac4043742ee457e9f2c2e44ad2fb0c06c539990 |
|
MD5 | a1680651b64611e546b71b2810103acb |
|
BLAKE2b-256 | d533f678dcbd77b1dc1f9449f940621a867a3c8ffebef88c8ec7d383db7b0997 |
Hashes for concrete_python-2.6.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c86978a461b3f192271cc9944bc9c0da193471662ee9248833f0e828060286ce |
|
MD5 | e1fa55013e8fe27ab257b44e73b5a2de |
|
BLAKE2b-256 | b6a8b15b9d803f265c41f433700a04b50a8b1990e5ad3e212f9d0d9d9b296d40 |
Hashes for concrete_python-2.6.0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47593e52a6d283b2370b35e834bf6383f056931595f6f5673e3abcd64f4fff6e |
|
MD5 | 2144eccf89b6efc623ea824d81bfe1d4 |
|
BLAKE2b-256 | a8156402b50356d1eb61599df084fb096ea02b5f46ebdc91a4c16f4fe2e02da0 |
Hashes for concrete_python-2.6.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5442fd50d1860ef941ac899a7251fdb97aa65cce0e90d850b135c5554e40e3ac |
|
MD5 | 58e1652d119306293324a7042481a6aa |
|
BLAKE2b-256 | a4daa3302dbb472d170a9ad218f414f4e42d3c5359f69732d677efff5706e0ba |
Hashes for concrete_python-2.6.0-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83d4cab6e93c2b2df6a58c7695c3b6f005ada4d95d13a55ee667817ab0eb53f6 |
|
MD5 | c97145123bd298558bf42a54c7b97f1e |
|
BLAKE2b-256 | 6b64975c1a5f0cefd20b915cdf909210139dc21e5b830b588bba36e7560c29c2 |
Hashes for concrete_python-2.6.0-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9b2845ed8202641d313cc13c25d2aeeb63b28d1136e1b5e7087da4fe1f7c3d9 |
|
MD5 | 8346e9b6f76e93105292eb16c08ef000 |
|
BLAKE2b-256 | f6f9fd9f43f5f9a099031ec5b0b2669e88cfc2ef8d10d583e5ce53c80245d56a |
Hashes for concrete_python-2.6.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02874867cafd53f73edf65dd482fe1aa990924a31f6f2f8ad5ae42ed9da4767f |
|
MD5 | 4da3aa5ae2f91d329e7bfd5581ee310d |
|
BLAKE2b-256 | b0bdc70b1cf624d772fa3ef488f4354b5e86f658ee1c570cd0cfe3ede32cefcf |