Deploy
Last updated
Last updated
This document explains how to deploy a circuit after the development. After developing your circuit, you may want to deploy it without sharing the circuit's details with every client or hosting computations on dedicated servers. In this scenario, you can use the Client
and Server
features of Concrete.
In a typical Concrete deployment:
The server hosts the compilation artifact, including client specifications and the FHE executable.
The client requests circuit requirements, generates keys, sends an encrypted payload, and receives an encrypted result.
Follow these steps to deploy your circuit:
Develop the circuit: You can develop your own circuit using the techniques discussed in previous chapters. Here is an example.
Save the server files: Once you have your circuit, save the necessary server files.
Send the server files: Send server.zip
to your computation server.
Load the server files: To set up the server, load the server.zip
file received from the development machine.
Prepare for client requests: The server needs to wait for the requests from clients.
Serialize ClientSpecs
: The requests typically starts with ClientSpecs
as clients need ClientSpecs
to generate keys and request computation.
Send serialized ClientSpecs
to clients.
Create the client object: After receiving the serialized ClientSpecs
from a server, create the Client
object.
Generate keys: Once you have the Client
object, perform key generation. This method generates encryption/decryption keys and evaluation keys.
Serialize the evaluation keys: The server needs access to the evaluation keys. You can serialize your evaluation keys as below.
Send the evaluation keys to the server.
Serialized evaluation keys are very large, even if they are compressed and can be reused several times: consider caching them on the server
Encrypt inputs: Encrypt your inputs and request the server to perform some computation. This can be done in the following way.
Send the serialized arguments to the server.
Deserialize received data: On the server, deserialize the received evaluation keys and arguments received from the client.
Run the computation: Perform the computation and serialize the result.
Send the serialized result to the client:
Clear arguments can directly be passed to server.run
(For example, server.run(x, 10, z, evaluation_keys=...)
).
Deserialize the result: Once you receive the serialized result from the server, deserialize it.
Decrypt the deserialized result:
Deploying a module follows the same logic as the deployment of circuits.
For example, consider a module compiled in the following way:
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.
For example, to encrypt an argument for the inc
function of the module:
To execute the inc
function:
To decrypt a result from the execution of dec
: