mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-08 19:44:57 -05:00
docs: add an example with explicit compiler api to readme
This commit is contained in:
22
README.md
22
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
|
||||
|
||||
Reference in New Issue
Block a user