Concrete Numpy is an open-source library which simplifies the use of fully homomorphic encryption (FHE).
Project description
Concrete Numpy is an open-source library which simplifies the use of fully homomorphic encryption (FHE) in Python.
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 the privacy of the 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.
Main features
- Ability to compile Python functions (that may use NumPy within) 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 (Intel) | Yes | Yes |
macOS (Apple Silicon, ie M1, M2 etc) | Yes (Rosetta) | Coming soon |
The preferred way to install Concrete Numpy is through PyPI:
pip install concrete-numpy
You can get the concrete-numpy docker image by pulling the latest docker image:
docker pull zamafhe/concrete-numpy:v0.10.0
You can find more detailed installation instructions in installing.md
Getting started
import concrete.numpy as cnp
def add(x, y):
return x + y
compiler = cnp.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:
import concrete.numpy as cnp
@cnp.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-numpy.
Target users
Concrete Numpy 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 Numpy.
One such example is Concrete ML, which is built on top of Concrete Numpy to simplify Machine Learning oriented use cases.
Tutorials
Various tutorials are proposed in the documentation to help you start writing homomorphic programs:
- How to use Concrete Numpy with Decorators
- Partial support of Floating Points
- How to perform Table Lookup
More generally, if you have built awesome projects using Concrete Numpy, feel free to let us know and we'll link to it!
Need support?
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file concrete_numpy-0.11.1-py3-none-any.whl
.
File metadata
- Download URL: concrete_numpy-0.11.1-py3-none-any.whl
- Upload date:
- Size: 88.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/37.3 requests/2.28.2 requests-toolbelt/0.10.1 urllib3/1.26.14 tqdm/4.64.1 importlib-metadata/4.2.0 keyring/23.9.3 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e348650c10de46335d2fd92adb2ca98f2d7cce1088bd108c2f57020fb5e788a2 |
|
MD5 | f329cefd64ae0416b7297395082e5771 |
|
BLAKE2b-256 | 3a0d78fe1610ec9c57d465cc5ea851e5d20e29cb8636a90f39fafae1927b822c |