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

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

concrete_python-2.5-cp311-cp311-macosx_11_0_x86_64.whl (49.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

concrete_python-2.5-cp310-cp310-manylinux_2_28_x86_64.whl (65.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

concrete_python-2.5-cp310-cp310-macosx_11_0_x86_64.whl (49.8 MB view details)

Uploaded CPython 3.10macOS 11.0+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

concrete_python-2.5-cp39-cp39-manylinux_2_28_x86_64.whl (65.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

concrete_python-2.5-cp39-cp39-macosx_11_0_x86_64.whl (49.8 MB view details)

Uploaded CPython 3.9macOS 11.0+ x86-64

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

Uploaded CPython 3.9macOS 11.0+ ARM64

concrete_python-2.5-cp38-cp38-manylinux_2_28_x86_64.whl (65.5 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

concrete_python-2.5-cp38-cp38-macosx_11_0_x86_64.whl (49.8 MB view details)

Uploaded CPython 3.8macOS 11.0+ x86-64

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

File metadata

File hashes

Hashes for concrete_python-2.5-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 21073c95ef3eaff7e95fe646f27b75b133ff81ed2e57d7bb33b08c19dee5211e
MD5 f946c0555c3f3045d117f9b7aaf4bab7
BLAKE2b-256 8f915f7398ae7258d50a78f968fbea50b80b7ee2a67045fc11f883963a2cdd66

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 a7979f317394f0cdbdf93be613ac433e5de3fddca3c7b17d0f3989c153fac2c7
MD5 cd8f3496521c2844af18275b1a789a73
BLAKE2b-256 00b5b306a70a4b29219972dd7f78a6d2ef3d3b6a3a610ef0d6d058ce1c93995c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 78ae8c3b4362a05515857b3c81395abcd0e199997a9993d06098875771ac7c57
MD5 a0a9921be0f039292963ee3f956f1f91
BLAKE2b-256 0c23aafa86a1c9df605ce96846cbfd9ab5119050f36252bbdda0db3ddc4beccf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fa26ec5f11c03d7fad6f7b82b0509a4db488dc921c9eb649fc1be403e27e358f
MD5 45c4e1ec18552b05c8b257896e4c9dca
BLAKE2b-256 0da853f61d5ea3afa5043eafbe6f861f87ad1646fe5afce71969089dd9193ad7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 f38b6873eea1f8e72ec5d5ccdcbf4f611f576213ea6ba474ecda2c7ce818ae40
MD5 67c805515b0b8c95b6b5844d10f39df3
BLAKE2b-256 c0f8c410291289781b6b7baf8b74d6b5299f7b8bf651cc38a2e1004d3a339ae2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b9cb6f281ae0d7c5e3fe8f43584a61fbd3f8ddb640656a4ea091af012814a02e
MD5 3ea8027a44eb37f55b16c672e7a18a05
BLAKE2b-256 32035b6da860bdec2d43619af59234150f011b6125997b67d2689f8dad045315

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9c168f18b3c6a1938bdb6306b7be2ffd6d2076e45cfd4935b7a842f0b72d1091
MD5 3237e86fe7b6a36be04bf946e3ef26df
BLAKE2b-256 d2a7a59edf3c4f6c0d98c214ad927974927b63a71e35ab3fa5013df0bc86e13e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 4e2323982fed6168d09b9648e6feebdadbc236051afc398b2b59f9cb177b757e
MD5 cf79e74bffe4254369a9ad13018cae20
BLAKE2b-256 97ab9999451d7a91c093b2afd845181b9120218beed3be13cbb5241a381664bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8ccad39025a35ebc234f2c086bd18033eca478d97e8e429b6855b65495aa0e11
MD5 47565edb1be46ab01f1a0a476783e108
BLAKE2b-256 26c03dfd98e7fc1016c4166614648d61046ea3a6507172417ec3c59cc2db21d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f9c99ca634dd86efbef8f8baec66c3a63a3e80f759b1befebb19ba7be93bd68b
MD5 ff68d6cbc80200a732ef3fc829581fee
BLAKE2b-256 d40c6e7c3ef1bade3a0309fa36621500a11602cc266fed3ebf0949a6d48511ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 2d631616c3102decd5ca071e4f2cf2d26308948fc461d14803ba73e4d01998ab
MD5 1fb37659e6303bd8454d828c0470ee86
BLAKE2b-256 e868ec5cd68f27873b34369ccfea7cfc2385a277d09f2d132f44ef9910f857d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.5-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 43145e7397a4f1ec34fae4535a76b2022609728dcf50bed340757ad6c9e9d7d9
MD5 9b68f134a5ad8805045d0ad55f70909b
BLAKE2b-256 39b57a405dd36bd32b044d9f8f544dbeff53958dea3a1324bf96476997e8a44e

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