diff --git a/README.md b/README.md index 46c92b3d7..4ce5e7eb2 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ To install Concrete Numpy from PyPi, run the following: You can find more detailed installation instructions in [installing.md](docs/user/basics/installing.md) -## A simple example: numpy addition in FHE +## A simple example ```python import concrete.numpy as cnp @@ -62,6 +62,26 @@ for example in examples: print(f"Evaluation of {' + '.join(map(str, example))} homomorphically = {result}") ``` +if you have a function object that you cannot decorate, you can use the explicit compiler API instead + +```python +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) + +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