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.3.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.3.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.3.0-cp311-cp311-macosx_11_0_arm64.whl (42.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

concrete_python-2.3.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.3.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.3.0-cp310-cp310-macosx_11_0_arm64.whl (42.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

concrete_python-2.3.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.3.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.3.0-cp39-cp39-macosx_11_0_arm64.whl (42.4 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

concrete_python-2.3.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.3.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.3.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.3.0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for concrete_python-2.3.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6a75a016ec62e3ca746802530d469d65844fb378a26f364844afb0ce5740b17e
MD5 e92e6956bf5d9b2b299293575e448a37
BLAKE2b-256 d26d26c9a21fff8f31ebb15ec049d21b55d1743bb272a2b2f4b1e7945a39694c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.3.0-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 001d3c8369f9881f8026615b38bf53f516ce089b90bd40d231ab1488d863eae2
MD5 12c46ba9d4404f77fdcab200dac35f78
BLAKE2b-256 e460bffaf89e015401b57b293ebd77d4497e9d7eda4bb0d2d83035710fcbeb80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.3.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dbbafc7daab00852d8dbc02a0347c49e586937898a4a9fb790503e8f62c7d891
MD5 d7eb5b8c966ba26551fec18ff88b0515
BLAKE2b-256 d74d567196c88510321e342b7f77e0f1213dd6384115ac56d13ffd5f7269083d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.3.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 aeb71f408dd934bd21e254fc03fa660e07ce56d102cb4f976906939bd3d8f198
MD5 76dbf01c8965d8b9cc30e07ea398ef24
BLAKE2b-256 a612f2601c058d37621c97687e323bb95d5fc72e1e82c0588ee836e9bb0f9ea8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.3.0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 72addb0702654e8fab2af15e99b451f93886b49ab86c2b47d2e0be3a97cf01e8
MD5 16120c020720f8dc7a1a7783ea0c8f2e
BLAKE2b-256 e540ba61baa3b7df436fdffc7be9783dc1239c3687ea70e322f81c68e5c70e31

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.3.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 db8e9f55848a75ec5451f53af1a20b571fce206ebf59dd0840f79651ada1b3d6
MD5 3d402657b902a2e139ebe8d8fa929761
BLAKE2b-256 2950a450b0124660d70a7d420efa459d2c341e2c57808137443e39ce0fcc3dbc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.3.0-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ee7b13cad3783c28ea3857b78ab8e38be8f980b4c6b1c278d3f3d8b854130ad1
MD5 785f82423487607f11a769891fde749b
BLAKE2b-256 e10adc2fe377b2f12a882462e4925854f6d30297a34c3c179002b47163f0719c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.3.0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 6ed38ed37f1cf8fef3f81b07721a83778a50f53176d078f203dbcfa6588cf27c
MD5 edc468e7e669c7c1f55d6f34a88e4a6c
BLAKE2b-256 71390a474c410f5bc1267b9e07e5f4df990ec59753af2a62aea4e4863f64d21c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.3.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 de068750a364fcaad8ddc4c8e856b6f04c72378533c036e533a1105047f974df
MD5 68d9e09bbf5d666d3079f23dabe0bb2a
BLAKE2b-256 a16d650b893e23303b5fff15312ee5633007a275e2681616cde907cbee9b0517

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.3.0-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a4d42ea56f4d351799bdcde4ad38ad40c7b5f88f9d1e68b5a26d6676838d1f09
MD5 b36fff5e8a369e28ddacfa4b9a44e156
BLAKE2b-256 01a550c077ad740ec2a3bfae798288d43b74092bac1d3a85b8970c4fc750db4d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.3.0-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 a7f23cb559a8c2b6325a7a3a4f771e2e8a34d593be4c4e131ca53b25d146bf16
MD5 b6651c9e6c04c80e25ff3972e2f023c4
BLAKE2b-256 4df7391b1d12c2913ab2cc14fd78f8e0bd53564219c3c9347a3c1866adfc7c62

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for concrete_python-2.3.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e544eed70988c03aacdc25ac7840f7e27ee78979ed67723f6b3d3429b13ed5a5
MD5 6732999799df2b2794e77509fc493731
BLAKE2b-256 a01ff6c1159316f2d44f2f1f5a81d4943c99c98ccccea86b0dac9e93307056e5

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