Deploy
Last updated
Last updated
After developing your circuit, you may want to deploy it. However, sharing the details of your circuit with every client might not be desirable. As well as this, you might want to perform the computation on dedicated servers. In this case, you can use the Client
and Server
features of Concrete.
You can develop your circuit using the techniques discussed in previous chapters. Here is a simple example:
Once you have your circuit, you can save everything the server needs:
Then, send server.zip
to your computation server.
You can load the server.zip
you get from the development machine:
You will need to wait for requests from clients. The first likely request is for ClientSpecs
.
Clients need ClientSpecs
to generate keys and request computation. You can serialize ClientSpecs
:
Then, you can send it to the clients requesting it.
After getting the serialized ClientSpecs
from a server, you can create the client object:
Once you have the Client
object, you can perform key generation:
This method generates encryption/decryption keys and evaluation keys.
The server needs access to the evaluation keys that were just generated. You can serialize your evaluation keys as shown:
After serialization, send the evaluation keys to the server.
Serialized evaluation keys are very large, so you may want to cache them on the server instead of sending them with each request.
The next step is to encrypt your inputs and request the server to perform some computation. This can be done in the following way:
Then, send the serialized arguments to the server.
Once you have serialized evaluation keys and serialized arguments, you can deserialize them:
You can perform the computation, as well:
Then, send the serialized result back to the client. After this, the client can decrypt to receive the result of the computation.
Once you have received the serialized result of the computation from the server, you can deserialize it:
Then, decrypt the result:
You can extract the server from the module and save it in a file:
The only noticeable difference between the deployment of modules and the deployment of circuits is that the methods Client::encrypt
, Client::decrypt
and Server::run
must contain an extra function_name
argument specifying the name of the targeted function.
The encryption of an argument for the inc
function of the module would be:
The execution of the inc
function would be :
Finally, decrypting a result from the execution of dec
would be:
Deploying a follows the same logic as the deployment of circuits. Assuming a module compiled in the following way: