concrete.ml.deployment.fhe_client_server.md
Last updated
Last updated
concrete.ml.deployment.fhe_client_server
APIs for FHE deployment.
CML_VERSION
FHEModelServer
Server API to load and run the FHE circuit.
__init__
Initialize the FHE API.
Args:
path_dir
(str): the path to the directory where the circuit is saved
load
Load the circuit.
Raises:
ValueError
: if mismatch in versions between serialized file and runtime
run
Run the model on the server over encrypted data.
Args:
serialized_encrypted_quantized_data
(bytes): the encrypted, quantized and serialized data
serialized_evaluation_keys
(bytes): the serialized evaluation keys
Returns:
bytes
: the result of the model
FHEModelDev
Dev API to save the model and then load and run the FHE circuit.
__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
save
Export all needed artifacts for the client and server.
Arguments:
via_mlir
(bool): serialize with via_mlir
option from Concrete-Python. For more details on the topic please refer to Concrete-Python's documentation.
Raises:
Exception
: path_dir is not empty
FHEModelClient
Client API to encrypt and decrypt FHE data.
__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
deserialize_decrypt
Deserialize and decrypt the values.
Args:
serialized_encrypted_quantized_result
(bytes): the serialized, encrypted and quantized result
Returns:
numpy.ndarray
: the decrypted and deserialized values
deserialize_decrypt_dequantize
Deserialize, decrypt and de-quantize the values.
Args:
serialized_encrypted_quantized_result
(bytes): the serialized, encrypted and quantized result
Returns:
numpy.ndarray
: the decrypted (de-quantized) values
generate_private_and_evaluation_keys
Generate the private and evaluation keys.
Args:
force
(bool): if True, regenerate the keys even if they already exist
get_serialized_evaluation_keys
Get the serialized evaluation keys.
Returns:
bytes
: the evaluation keys
load
Load the quantizers along with the FHE specs.
Raises:
ValueError
: if mismatch in versions between serialized file and runtime
quantize_encrypt_serialize
Quantize, encrypt and serialize the values.
Args:
x
(numpy.ndarray): the values to quantize, encrypt and serialize
Returns:
bytes
: the quantized, encrypted and serialized values