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

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

concrete_python-2.2.0-cp311-cp311-macosx_11_0_x86_64.whl (48.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ x86-64

concrete_python-2.2.0-cp311-cp311-macosx_11_0_arm64.whl (42.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

concrete_python-2.2.0-cp310-cp310-manylinux_2_28_x86_64.whl (64.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

concrete_python-2.2.0-cp310-cp310-macosx_11_0_x86_64.whl (48.8 MB view details)

Uploaded CPython 3.10macOS 11.0+ x86-64

concrete_python-2.2.0-cp310-cp310-macosx_11_0_arm64.whl (42.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

concrete_python-2.2.0-cp39-cp39-manylinux_2_28_x86_64.whl (64.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

concrete_python-2.2.0-cp39-cp39-macosx_11_0_x86_64.whl (48.8 MB view details)

Uploaded CPython 3.9macOS 11.0+ x86-64

concrete_python-2.2.0-cp39-cp39-macosx_11_0_arm64.whl (42.4 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

concrete_python-2.2.0-cp38-cp38-manylinux_2_28_x86_64.whl (64.8 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

concrete_python-2.2.0-cp38-cp38-macosx_11_0_x86_64.whl (48.8 MB view details)

Uploaded CPython 3.8macOS 11.0+ x86-64

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

File metadata

File hashes

Hashes for concrete_python-2.2.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b11b5a5b0d02cc9cd1b9fe0d8e6f91201d7bf10dc3681c6b6c9e8ac3b874fcd9
MD5 e7267ad9bf296efee4a49128ac717092
BLAKE2b-256 f1db5c406c865e5624e51e0dcf0607966a59c3f9244b12917f962b129dd4124b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.2.0-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 c0b226e5e7ebf82c6df1e90f37f6281dd60c4d95d6d5029c663bc73d916121c1
MD5 c7c892f3f08a99715ca5f0eabdadd511
BLAKE2b-256 328b46bf54de68150bfaffa8afa3c10ec112af17e07551b4f940c6537cf698bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 126bbd5ad2066a5c052f65def6ca6261e8c42d5892908071164f871fdff4245c
MD5 d9b28c036733085ceeafbbcdb752dee2
BLAKE2b-256 1aad97d478c348095de3a66487aea42e31448babd55d468b0186d6a39fe077dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.2.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5b97d661a99282abd65e84f709fd0728de9940c5250b9077fec208ef2ad98793
MD5 00953a34686a2dfcafce7db27ab18d1b
BLAKE2b-256 79b1e759ce42494ad9a3b27a6b59e4bb42c8dfbe8a48137afaa0015359e7fad9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.2.0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 5615ff90aa828a073cc2e283cc23e6bd0124b509b29318b070687931e801f714
MD5 a4016663275f2cf0d2fbff123fe14d4f
BLAKE2b-256 cbdf2344837a86ca1da41c6dc7e000e7e70cc8398926a3832a96abc2eadf8aa5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 db9128634dcbbc9c74f6eefd688fabfea2b4144b8e7b30db8d57d232c8d75747
MD5 090ff6c7c45ead43b320c4f3664d4678
BLAKE2b-256 88b1cd23e3606d39d04e56399f4c1c2062d054aa882d1831b4a400177e1951dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.2.0-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 41d552f41977d83f3a39d78ff77644ebad2305f313509a9d4d8faf32c519eae2
MD5 487f4744ca0f393fc79a637581f35114
BLAKE2b-256 94f67435c6ab22f28135c9feb66462bdf7f720b3db18ebe879d47e6badb1768e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.2.0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 fcf5c32ad552f8b25b73ecc31f0c23e5ea39187233d50de1971c7e3473523f0c
MD5 f69294efc42ae1a26ee757f729be1af9
BLAKE2b-256 21066897212cb252c2c413dbce794f163d3284cbbab4dae8937ee4c9e5373365

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.2.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9ce9cafde72e4e1e018f8cfaee744943b7c736ca7bba329f49a2ed94ec3c532b
MD5 26db1a6d439dd01e9666acc2a471764d
BLAKE2b-256 c56f262da76a8bf108829e7bc5f05fd0de216c63b0960376e91b8cf916ed2d57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.2.0-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9d24194ff858eea7bd503b0fc2c5fa23a20b8b3026e04677882a3add663b1e84
MD5 ac97f6351a69e0c4fa5c15f167bbd051
BLAKE2b-256 9ab0ece88c137d1a65355ee894cd6d7ee864fed54b41d68782c65e81ac1c5dd2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.2.0-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 ab982563fcdca457a9c36ccef9af83eff5409bb951a250c07948b44b626063a4
MD5 9ae4d6abfbe21a20ebf2aefc0d42637a
BLAKE2b-256 353352fff444666e7ed0650a2c0da35126cd1e597a03dce2bf2c9617fabf58fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.2.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 80ca3281530fd11e54c778c47166fb711f45cc8499be78fab7ffb2ac51aa65c8
MD5 81b6a35c07612f961efdb3aa8516607b
BLAKE2b-256 b3e215d01665b77c3bc94cd940ff8110456a4fdc3426edfe780324ed12dc5577

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