Skip to main content

A state-of-the-art homomorphic encryption framework

Project description


📒 Read documentation | 💛 Community support


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 Coming soon
Windows Subsystem for Linux Yes Yes
macOS 11+ (Intel) Yes Yes
macOS 11+ (Apple Silicon: M1, M2, etc.) Yes Yes

The preferred way to install Concrete is through PyPI:

pip install -U pip wheel setuptools
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.0rc3-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.0rc3-cp311-cp311-macosx_11_0_x86_64.whl (49.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

concrete_python-2.5.0rc3-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.0rc3-cp310-cp310-macosx_11_0_x86_64.whl (49.7 MB view details)

Uploaded CPython 3.10macOS 11.0+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

concrete_python-2.5.0rc3-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.0rc3-cp39-cp39-macosx_11_0_x86_64.whl (49.7 MB view details)

Uploaded CPython 3.9macOS 11.0+ x86-64

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

Uploaded CPython 3.9macOS 11.0+ ARM64

concrete_python-2.5.0rc3-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.0rc3-cp38-cp38-macosx_11_0_x86_64.whl (49.7 MB view details)

Uploaded CPython 3.8macOS 11.0+ x86-64

concrete_python-2.5.0rc3-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.0rc3-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.5.0rc3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1cc7f4b03bc9928bea61fb823ae385798535909220e9d852bb33f9ce8012cf25
MD5 4e6dafaef4767752d5eb992db64825b5
BLAKE2b-256 01481fba558aea34d88ae64e834827615e02e7ca34661efd6327e0712a0dc683

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc3-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 4a5561bcadbce2bba769265e751ab269d488833f3c4b79c8a028f364f9bf629e
MD5 fe45fe7dfe69f5b7c7ed4df9683c57c2
BLAKE2b-256 50499121e077352acca667e368b02e981c6d6aeda28d3b8bda7e9d4cc921e782

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7d5459163c36a7cca42826d18b604409345daa4a698c17fcd475661db974fe52
MD5 2bac18bb4a60e00f65d3885bd39133e4
BLAKE2b-256 4a3c772b888b6049d785e492ab100da06a2a5ac04f3de6feafc949cfe4bfc993

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc3-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 faabc952958bcbcba1aa7447d79f4aef7f66e6f1a3fb4befb4edbf1203982ec9
MD5 31247538fe5ac451fdab4274559517b6
BLAKE2b-256 20f68eb2f4271740099da79921b4cebeab2df3edad2a9bc7a3006421d69105a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc3-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 2f122b21829a5ebba874aa825ba574f235c1358ad557cb1898c511c68638e824
MD5 4721dfe72aacb3b65c347c74da648368
BLAKE2b-256 f0dcbdf73d36fe91e1402ffbdae27f4a57bdf685a2dc4b62aee48189aef716a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 19dd8caae5cc386d96c060d41f91459e8893850690c3d9cbbb85533a907e3637
MD5 6c7afb6cea7596e785c5a95ea58e6e6a
BLAKE2b-256 583b162c5d72de95550c1a06f27a2d5abfce5bf4e21a764d633d4a2ed5ed34ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc3-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2d560c08f50f7c0480b0f89a09a0e5dc9cf220c8a0273daf9c51787d969a9ad5
MD5 d7bd4ccd9a03edd0f34be280e4c8a213
BLAKE2b-256 514d6908ab710bc0ab458e8ccc75eac39ef7214e5859051f8d346f44a2671223

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc3-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 84b358a101a830784fb52d336d6fdb1e64658ce52053a735d9d5037d1c1eade2
MD5 d266e2cec811e87dc313d221feca41ed
BLAKE2b-256 f6e7f34604c966f5af5d86d612aca2c9f05d27c7c822e2b7cc32b03eda173a4f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a4ea1001c8fc28cfdfb9b8b3133cba94bcee2a74cf3d10ffcc1e8f5b5e4d8369
MD5 ecae81c83b978c9b236d577b99fe4692
BLAKE2b-256 47f15963e9de5f4af4bdb9adc96102cd76b44c420699047eddbb9909cfc9cf80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc3-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0b435f789643ae2d398f865744dafa8e3dbd27715372ad454817ffdba36c3221
MD5 70c350e59bef5c2be5ee0bb457dc8550
BLAKE2b-256 9998bc380785944c7704ab618246f2e88dcbb0d34b20bedd8f569d96cbb45e0c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc3-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 620b995f0cd34a63c2fd9c0fbc59cd5cbbfa3a57e9aed44c5a24bf546ed995c5
MD5 0c28644f55a7ef2fc17be378ca368ab3
BLAKE2b-256 28670c8bbe58fc6cbe94d2a9b805c793b7388db38026df18d5d4d9b48fecc71b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5.0rc3-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 faf224c52bd7b43f3f360e6254018dcf9731060f51001cef3468a7b33e193c67
MD5 ab44b3e2fea5da426945040ab9b9a660
BLAKE2b-256 27a5f179750f11d3790b21a01ba922c5540a9f2d26ea4e2cf690e43339984040

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