How do I get/set keys in a FHEModelClient?

The documentation/examples tell me how to get the evaluation key out of a, but not the encryption or decryption keys. And when I dive into the python source code, I find that I eventually hit a KeyStore object, which is just a wrapper around .cpp object with no described interface. So, how (in python) do I get or set the encryption or decryption keys?

Hello @jcherzog,
Indeed, it is currently not possible to access the private keys directly as for the evaluation ones. You can however initialize your FheModelClient object with a directory path to use for storing the keys in :


We will however improve the key management in the near future by providing a dedicated method to this feature.

I hope this helps !

Thanks for the tip about the key_dir. When I look in that directory, I see a file like


Is there a way to extract a public encryption key from that file?


Could you explain what you want to achieve? I am not sure what you mean by “extract”.

Currently, data are encrypted using the private key which is the one stored in the secretKey file. In FHE you have evaluation keys which are somehow public since you have to share them with a server for the FHE evaluation to be done properly. These keys are stored in ksKey_ksk_v0 and pbsKey_bsk_v0.

Now if you are asking about actual public key encryption then it’s a feature to come in concrete-ml but not yet available.

I want to determine which workflows are possible with concrete-ML. For example, I’d like to know if concrete-ML can support a workflow in which the client is actually two principals:

  • One principal who is trusted to collect the features and encrypt them for the server, but not trusted to know the predictions, and
  • Another principal who is trusted to know the predictions.

This is very possible if TFHE is a public-key encryption scheme, and I assumed it was. But your answer fills me with doubt. Can you please clarify: is the TFHE scheme, as implemented in Concrete, a symmetric-key or asymmetric-key encryption scheme?


The scheme itself support both private key encryption (symmetric way) or public key encryption (asymmetric way) but right now we have just the API for the private key encryption.

We will soon add the it in Concrete (so both symmetric and asymmetric ways will be supported)

To give you some insights on what you could do with public key encryption, we are also working on
threshold decryption, that will allow to have multiple parties handling the decryption in the asymmetric mode.

Let me explain it a bit more:

you could consider a use case where 3 parties A, B and C:

  • encrypt data with the same public key
  • do some operations then
  • to decrypt the result you could set a threshold of 2 over 3, meaning you need 2 out of 3 parties to agree to combine their private key pieces to do the decryption
A Encrypt-pubkey(dataA) \
B Encrypt-pubkey(dataB) | -->  FHE Operations on dataA, dataB and dataC --> Enc Result --> ThresholdDecryption_privKeyA_privKeyB(EncResult) ---> Clear Result
C Encrypt-pubkey(dataC) /

Got it. Thanks for explaining.