concrete.ml.deployment.fhe_client_server.md

arrow-up-right

module concrete.ml.deployment.fhe_client_server

APIs for FHE deployment.

Global Variables

  • CML_VERSION

  • AVAILABLE_MODEL


arrow-up-right

class FHEModelServer

Server API to load and run the FHE circuit.

arrow-up-right

method __init__

__init__(path_dir: str)

Initialize the FHE API.

Args:

  • path_dir (str): the path to the directory where the circuit is saved


arrow-up-right

method load

Load the circuit.


arrow-up-right

method run

Run the model on the server over encrypted data.

Args:

  • serialized_encrypted_quantized_data (cnp.PublicArguments): the encrypted, quantized and serialized data

  • serialized_evaluation_keys (cnp.EvaluationKeys): the serialized evaluation keys

Returns:

  • cnp.PublicResult: the result of the model


arrow-up-right

class FHEModelDev

Dev API to save the model and then load and run the FHE circuit.

arrow-up-right

method __init__

Initialize the FHE API.

Args:

  • path_dir (str): the path to the directory where the circuit is saved

  • model (Any): the model to use for the FHE API


arrow-up-right

method save

Export all needed artifacts for the client and server.

Raises:

  • Exception: path_dir is not empty


arrow-up-right

class FHEModelClient

Client API to encrypt and decrypt FHE data.

arrow-up-right

method __init__

Initialize the FHE API.

Args:

  • path_dir (str): the path to the directory where the circuit is saved

  • key_dir (str): the path to the directory where the keys are stored


arrow-up-right

method deserialize_decrypt

Deserialize and decrypt the values.

Args:

  • serialized_encrypted_quantized_result (cnp.PublicArguments): the serialized, encrypted and quantized result

Returns:

  • numpy.ndarray: the decrypted and deserialized values


arrow-up-right

method deserialize_decrypt_dequantize

Deserialize, decrypt and dequantize the values.

Args:

  • serialized_encrypted_quantized_result (cnp.PublicArguments): the serialized, encrypted and quantized result

Returns:

  • numpy.ndarray: the decrypted (dequantized) values


arrow-up-right

method generate_private_and_evaluation_keys

Generate the private and evaluation keys.

Args:

  • force (bool): if True, regenerate the keys even if they already exist


arrow-up-right

method get_serialized_evaluation_keys

Get the serialized evaluation keys.

Returns:

  • cnp.EvaluationKeys: the evaluation keys


arrow-up-right

method load

Load the quantizers along with the FHE specs.


arrow-up-right

method quantize_encrypt_serialize

Quantize, encrypt and serialize the values.

Args:

  • x (numpy.ndarray): the values to quantize, encrypt and serialize

Returns:

  • cnp.PublicArguments: the quantized, encrypted and serialized values

Last updated

Was this helpful?