Hello. I have been playing around with the Concrete python libraries (Numpy and ML) and despite what is said in this question on this same forum I tested that it is possible to manually call the encrypt, run and decrypt steps separately (see the basic example from the Concrete-numpy documentation).
From the example:
# this will encrypt arguments that require encryption and pack all arguments
# as well as public materials (public keys)
public_args = circuit.encrypt(3, 4)
# this will run the encrypted computation using public materials and inputs provided
encrypted_result = circuit.run(public_args)
# the execution returns the encrypted result which can later be decrypted
decrypted_result = circuit.decrypt(encrypted_result)
Using the Concrete library in Rust I was able to save and later retrieve encrypted values in files or different data structures (via bincode serialization), but this is not possible using the Python libraries. Exploring the code I saw that it is not possible to pickle those values since the mlir package is compiled. This is the error I’m facing:
I am going to try to answer for CN team since they are in vacation.
First: yes, as explained in the question you link, it is not possible to call the encrypt / run / decrypt in Concrete-ML. It will be possible to have the separated APIs in Concrete-ML in the next release.
Now, you’re right, Concrete-Numpy is always a step in advance, since Concrete-ML is built on top of Concrete-Numpy. So yes, as you say, in CN, you have the encrypt, run and decrypt APIs.
In the next releases of Concrete-Numpy and Concrete-ML (this summer), you will have complete examples of a client & server protocol, possibly on different machines, which will allow you to do exactly what you want. Certainly you can build workarounds in the meantime, but it may be simpler & safer to just wait for the next release for this part, if it does not block you.
Thanks for your quick response. Probably there are workarounds, but I guess they would require memory management or similar complex methods. I agree that it is simpler and safer to wait, hopefully this summer the next release of both libraries is released .
Adding to what @benoit already said, you can currently serialize both an encryption, and the result of an execution, to be able to send those between different parties. We implement the serialize/unserialize methods for that. However, calling unserialize requires passing the client parameters object, which can be found under the FHECircuit object as _client_parameters.
This will be much simpler in the next release, but you should at least work around it for now.
Thank you very much for your reponse. Sorry, but where can I find the serialize/unserialize functions in python implementation? I am not able to find them.
Sorry @alberto but I was wrong about the version I was assuming to be the latest released. This workaround isn’t available currently unfortunately. So you shouldn’t worry about this workaround, because next release is going to have a clear API for your usecase.