• Stars
    star
    219
  • Rank 181,133 (Top 4 %)
  • Language
    Python
  • License
    Other
  • Created about 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Concrete-Numpy: A library to turn programs into their homomorphic equivalent.

⚠️ Concrete Numpy is now integrated into Concrete (former package concrete-numpy is replaced by concrete-python). Read full announcement here

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:

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 [email protected].

More Repositories

1

concrete

Concrete: TFHE Compiler that converts python programs into FHE equivalent
C++
911
star
2

concrete-ml

Concrete ML: Privacy Preserving ML framework using Fully Homomorphic Encryption (FHE), built on top of Concrete, with bindings to traditional ML frameworks.
Python
881
star
3

tfhe-rs

TFHE-rs: A Pure Rust implementation of the TFHE Scheme for Boolean and Integer Arithmetics Over Encrypted Data.
Rust
860
star
4

fhevm

A Solidity library for interacting with an fhEVM blockchain.
TypeScript
387
star
5

bounty-program

Zama Bounty Program: Contribute to the FHE space and Zama's open source libraries and get rewarded 💰
233
star
6

awesome-zama

A curated list of amazing Fully Homomorphic Encryption (FHE) resources created by the team at Zama.
204
star
7

concrete-core

Concrete Core contains a set of low-level primitives which can be used to implement Fully Homomorphically Encrypted (FHE) programs.
Rust
73
star
8

fhevm-go

fhevm-go is an open-source library used to easily integrate the fhEVM into an EVM-compatible blockchain.
Go
21
star
9

concrete-fft

Rust
15
star
10

fhevmjs

A dapp SDK for the fhEVM ecosystem
TypeScript
13
star
11

concrete-ntt

Rust
13
star
12

verifiable-fhe-paper

Verifiable FHE prototype
Rust
13
star
13

hnp-examples

Repository to store hnp usage examples
11
star
14

go-ethereum

fhEVM reference implementation
Go
8
star
15

demo_z8z

Demo using Concrete library to implement exact homomorphic computation with 3-bit integers
Rust
8
star
16

fhevm-decryptions-db

The fhEVM Decryptions Database is a key-value database of decryption results.
Rust
8
star
17

fhe-tutorials

Jupyter Notebook
8
star
18

evmos

Go
7
star
19

fhe-biometrics

Jupyter Notebook
7
star
20

fhevm-hardhat-template

fhEVM hardhat template
TypeScript
6
star
21

fhe_game_of_life

Rust
6
star
22

fhevm-tfhe-cli

TFHE-rs CLI tool for the fhEVM
Rust
4
star
23

ethcc23-workshop

Python
4
star
24

concrete-fftw

C
4
star
25

fhevm-L1-demo

Shell
4
star
26

fhevmjs-react-template

TypeScript
3
star
27

concrete-compiler-internal-llvm-project

Internal fork of llvm-project for concrete-compiler-internal
2
star
28

concrete-example-client-server

Rust
2
star
29

ethermint

A component of the fhEVM stack. Fork of the original ethermint repository.
Go
1
star
30

.github

1
star
31

fhevmjs-vue-template

Vue
1
star