concrete-numpy icon indicating copy to clipboard operation
concrete-numpy copied to clipboard

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

Concrete Numpy is an open-source set of tools which aims to simplify the use of fully homomorphic encryption (FHE) for data scientists.

With Concrete Numpy, data scientists can implement machine learning models using a subset of numpy that compiles to FHE. They will be able to train models with popular machine learning libraries and then convert the prediction functions of these models to FHE with concrete-numpy.

  • concrete-numpy
    • Links
    • For end users
      • Installation
      • A simple example
    • For developers
      • Project setup
      • Documenting
      • Developing
      • Contributing
    • License

Links

For end users

Installation

The preferred way to use concrete-numpy is through docker. You can get the concrete-numpy docker image by pulling the latest docker image:

docker pull zamafhe/concrete-numpy:latest

To install Concrete Numpy from PyPi, run the following:

pip install concrete-numpy

You can find more detailed installation instructions in installing.md

A simple example: numpy addition in FHE

import concrete.numpy as hnp

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)]
compiler = hnp.NPFHECompiler(add, {"x": "encrypted", "y": "encrypted"})

print(f"Compiling...")
circuit = compiler.compile_on_inputset(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}")

For developers

Project setup

Installation steps are described in project_setup.md. Information about how to use Docker for development are available in docker.md.

Documenting

Some information about how to build the documentation of concrete-numpy are available in documenting.md. Notably, our documentation is pushed to https://docs.zama.ai/concrete-numpy/.

Developing

Some information about our terminology and the infrastructure of concrete-numpy are available in terminology_and_structure.md. An in-depth look at what is done in concrete-numpy is available in compilation.md.

Contributing

Information about how to contribute are available in contributing.md.

License

This software is distributed under the BSD-3-Clause-Clear license. If you have any questions, please contact us at [email protected].