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.0-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.0-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.0-cp311-cp311-macosx_11_0_arm64.whl (42.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

concrete_python-2.4.0-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.0-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.0-cp310-cp310-macosx_11_0_arm64.whl (42.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

concrete_python-2.4.0-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.0-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.0-cp39-cp39-macosx_11_0_arm64.whl (42.4 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

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

File metadata

File hashes

Hashes for concrete_python-2.4.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f5a9bac76e6b4d28f36a2eb41dad6bbdeabb9629408a6b902aa42b58e9ee5a1f
MD5 0f3b0b1fbc61e35a21e8d1d24ad2c4b6
BLAKE2b-256 a036bdf6238f122d68318e35b5ac3204c720f2882ece19f163aa33190524d6f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.4.0-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 185ac9fe385dfc783fc0864777118f7e7ac389f823302df84f62d7de6527a1a4
MD5 14eef5d4f290770dbe35a546869d2d97
BLAKE2b-256 0ca2d476fdc19d649062261cba93958fc812f5b77fb65cd9581e85c148f8ee52

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.4.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ad3164ae77962a8f5e6b03e88e1d436015148b35ba2a594f9dc7ca63e7c5a5bf
MD5 cf6d61e5080847d9672f51fa2d835812
BLAKE2b-256 aeab5a08fbfe8176f388700e7e15f1d8afd063a93aafd3c08c0ae602d32e3491

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.4.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1e3dd30ce85b48cb76e3ed0f7ce6fbff402d21117d2a077b8e5f1eb9595b0cdb
MD5 c650a56d75d7283a6b7efc8cd1c4627b
BLAKE2b-256 33f4c29f9639b21bf124d79bd0a7b42d8aaedb4e6ee780312279e07ea7b6c23c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.4.0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 6f86b4ed1f25c0d0fe26e38bb910704704ee32f1e0d59491141e19c693adf3b3
MD5 0696cdca7a6e148e68829b54f4e66696
BLAKE2b-256 bd0cc992a6497902b3294371ab3165b24b7b2e7deea36b5838114dc2e8e44e38

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.4.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 417f7e3cd7027e09a9da0d19d41067200b8073d6f3d80ca4792113184ff4a7cd
MD5 30ccb210d70d6d4f5ef927dec128131b
BLAKE2b-256 0ddea71400ab2220cacbfd39e7611936db5bca158f73815177e6ce53da49abe6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.4.0-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f7ba1684ec0bff6a964340dd9a0a7781bf0b288baabd2ec1c2f7eb6b8e4b0439
MD5 13ca189ac8a97297eaee38857325218d
BLAKE2b-256 83286c7aa006026ec9995fde2c8139fba25d7496f5ab6ee9309b5207dea5bd29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.4.0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 401351d95ef1123656f5b6c0bc1a666c8d82e49d35da36876ec4d5476b7f323b
MD5 e5c2d307bdc4f576ff056398bf95bff8
BLAKE2b-256 fe76d792473b83445600aff43d4725cdffcb21b03b85eefd077b3f5ae2309b6c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.4.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 14d36ef65016cd6cb3e3b48fe071a010e3c06760cd24ffb9ecccfb81b6bb57da
MD5 ecf69ba7b98cfea26ae0fe55ac3cf2d9
BLAKE2b-256 c67c897d814302d453a0c730070ec23abcbb216ba69805aa3a3ad1acb6d1cbf8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.4.0-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7bf22485cc7e32e1b75c11bef1e353a1f56183af722cfc7ef5de7f49689e49df
MD5 5d1bfdfe40980edfacd99e060c4116d4
BLAKE2b-256 cfa6af0e2e361561edc0dd0feea62610c5cb69ad404a0ef3abbb5faaa8266181

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.4.0-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 fd96a527d09ab53a86605f28f387b846656a83ad7635c2b32be1c85a7cfb1383
MD5 e545933c603f609fcb706329dc6db5f0
BLAKE2b-256 bde873a5a95e05106a2aa67b393c20e9a149a2ee3fcba84d133f872d6fe14d51

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.4.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 712b3b66afc8b05c724f3dd6c1ae075cf915de7ef78306b75cd30c7c6d5f730e
MD5 1b4b7ef72fb5839471b59c94923c596a
BLAKE2b-256 ee3711ead7fe07d845bf88c1a3d168fc1a6159e6f722f1d96c01883849572efb

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