refactor: concrete-numpy to concrete-python

This commit is contained in:
Umut
2023-03-16 10:26:03 +01:00
parent 1ed1f4321c
commit 4e7cbac264
153 changed files with 1124 additions and 7448 deletions

View File

@@ -1,40 +1,40 @@
# Installation
**Concrete-Numpy** is natively supported on Linux and macOS for Python 3.8 and 3.9, but if you have Docker support in your platform, you can use the docker image to use **Concrete-Numpy**.
**Concrete Python** is natively supported on Linux and macOS for Python 3.8 onwards.
## Using PyPI
You can install **Concrete-Numpy** from PyPI:
You can install **Concrete Python** from PyPI:
```shell
pip install -U pip wheel setuptools
pip install concrete-numpy
pip install concrete-python
```
{% hint style="warning" %}
Apple silicon users must use docker installation (explained below) as there is no ARM version of some of our dependencies for the time being.
Apple Silicon is not supported for the time being. We're working on bringing support for it, which should arrive soon.
{% endhint %}
## Using Docker
You can also get the **Concrete-Numpy** docker image:
You can also get the **Concrete Python** docker image:
```shell
docker pull zamafhe/concrete-numpy:v1.0.0
docker pull zamafhe/concrete-python:v1.0.0
```
### Starting a Jupyter server.
By default, the entry point of the **Concrete-Numpy** docker image is a jupyter server that you can access from your browser:
By default, the entry point of the **Concrete Python** docker image is a jupyter server that you can access from your browser:
```shell
docker run --rm -it -p 8888:8888 zamafhe/concrete-numpy:v1.0.0
docker run --rm -it -p 8888:8888 zamafhe/concrete-python:v1.0.0
```
To save notebooks on host, you can use a local volume:
```shell
docker run --rm -it -p 8888:8888 -v /path/to/notebooks:/data zamafhe/concrete-numpy:v1.0.0
docker run --rm -it -p 8888:8888 -v /path/to/notebooks:/data zamafhe/concrete-python:v1.0.0
```
### Starting a Bash session.
@@ -42,5 +42,5 @@ docker run --rm -it -p 8888:8888 -v /path/to/notebooks:/data zamafhe/concrete-nu
Alternatively, you can launch a Bash session:
```shell
docker run --rm -it zamafhe/concrete-numpy:latest /bin/bash
docker run --rm -it zamafhe/concrete-python:v1.0.0 /bin/bash
```

View File

@@ -55,7 +55,7 @@ After getting the serialized `ClientSpecs` from a server, you can create the cli
<!--pytest-codeblocks:skip-->
```python
client_specs = cnp.ClientSpecs.unserialize(serialized_client_specs)
client_specs = cnp.ClientSpecs.deserialize(serialized_client_specs)
client = cnp.Client(client_specs)
```
@@ -96,19 +96,19 @@ The only thing left to do is to send serialized args to the server.
## Performing computation (on the server)
Upon having the serialized evaluation keys and serialized arguments, you can unserialize them like so:
Upon having the serialized evaluation keys and serialized arguments, you can deserialize them like so:
<!--pytest-codeblocks:skip-->
```python
unserialized_evaluation_keys = cnp.EvaluationKeys.unserialize(serialized_evaluation_keys)
unserialized_args = server.client_specs.unserialize_public_args(serialized_args)
deserialized_evaluation_keys = cnp.EvaluationKeys.deserialize(serialized_evaluation_keys)
deserialized_args = server.client_specs.deserialize_public_args(serialized_args)
```
And you can perform the computation as well:
<!--pytest-codeblocks:skip-->
```python
public_result = server.run(unserialized_args, unserialized_evaluation_keys)
public_result = server.run(deserialized_args, deserialized_evaluation_keys)
serialized_public_result: bytes = public_result.serialize()
```
@@ -116,17 +116,17 @@ Finally, you can send the serialized public result back to the client, so they c
## Decrypting the result (on the client)
Once you have received the public result of the computation from the server, you can unserialize it:
Once you have received the public result of the computation from the server, you can deserialize it:
<!--pytest-codeblocks:skip-->
```python
unserialized_public_result = client.specs.unserialize_public_result(serialized_public_result)
deserialized_public_result = client.specs.deserialize_public_result(serialized_public_result)
```
Finally, you can decrypt the result like so:
<!--pytest-codeblocks:skip-->
```python
result = client.decrypt(unserialized_public_result)
result = client.decrypt(deserialized_public_result)
assert result == 49
```