Keyset and model circuit correlation

Hi,
I’ve recently built a FHE-compliant model using a fitted scikit-learn model (XGBClassifier) and I’ve obtained the client.zip and server.zip files.

I’d like to explore the relationship between the specific keyset was generated and the circuit. I’d like to understand why I have a certain number of lweSecretKeys, lweBootstrapKeys, lweKeyswitchKeys and packingKeyswitchKeys and where they come in.

I seem to get that it depends on the circuit, so is there a way to clearly see and understand this connection?

Thank you

Hello @CardoFlare ,

Thanks for getting in touch :slightly_smiling_face:

The goal of concrete is to relieve the user from the burden of thinking about the cryptographic details, so you don’t strictly need to understand all those details if you just intend to use concrete. That being said, there is nothing wrong in asking, and I’ll try to give a comprehensive answer :slightly_smiling_face:

Here is a quick overview of the compilation process performed by concrete:

  • The program is traced, to create an in-memory representation of the operations.
  • This representation is transformed into an equivalent circuit that uses the operations available in the TFHE scheme, while preserving the semantic of the circuit.
  • The crypto parameters are optimized so as to guarantee a certain level of security, while guaranteeing a certain level of correctness (up to a certain probability of error). Those two objectives are in tension.

There are roughly two kinds of keys in your applications:

  • The secret keys. Those are used on the client to encrypt the inputs and decrypt the outputs.
  • The evaluation keys. Those are used to execute some TFHE operations: Bootstrap keys, keyswitch keys, packing keyswitch keys and the likes. Those keys are public and are sent to the server to be used for the execution.

Basically, the more precision is needed for an operation in the original circuit, the bigger the evaluation keys to perform the same operation in FHE.

For high level informations you can see:

For more in-depth informations on the TFHE operations we use see:

Hope that helps !

@apere Thank you very much for your answer. I have cleared up some doubts.

Is there a way to inspect what TFHE operations are involved within the circuit? maybe a graph of the IR?

I’d like to have a better understanding of the steps occuring when I do TFHE inference.

Thanks

You can add the following flags to the configuration:

This should give you the IR at different levels during the compilation.