Files
concrete/docs/dev/api/concrete.fhe.compilation.client.md
2025-01-07 09:17:59 +01:00

6.1 KiB

module concrete.fhe.compilation.client

Declaration of Client class.


class Client

Client class, which can be used to manage keys, encrypt arguments and decrypt results.

method __init__

__init__(
    client_specs: ClientSpecs,
    keyset_cache_directory: Optional[Path, str] = None,
    is_simulated: bool = False
)

property evaluation_keys

Get evaluation keys for encrypted computation.

Returns: EvaluationKeys evaluation keys for encrypted computation


property keys

Get the keys for the client.


property specs

Get the client specs for the client.


method decrypt

decrypt(
    *results: Union[Value, Tuple[Value, ]],
    function_name: Optional[str] = None
)  Union[int, ndarray, Tuple[Union[int, ndarray, NoneType], ], NoneType]

Decrypt result(s) of evaluation.

Args: *results (Union[Value, Tuple[Value, ...]]): result(s) of evaluation function_name (str): name of the function to decrypt for

Returns: Optional[Union[int, np.ndarray, Tuple[Optional[Union[int, np.ndarray]], ...]]]: decrypted result(s) of evaluation


method encrypt

encrypt(
    *args: Optional[int, ndarray, List],
    function_name: Optional[str] = None
)  Union[Value, Tuple[Optional[Value], ], NoneType]

Encrypt argument(s) to for evaluation.

Args: *args (Optional[Union[int, np.ndarray, List]]): argument(s) for evaluation function_name (str): name of the function to encrypt

Returns: Optional[Union[Value, Tuple[Optional[Value], ...]]]: encrypted argument(s) for evaluation


method keygen

keygen(
    force: bool = False,
    secret_seed: Optional[int] = None,
    encryption_seed: Optional[int] = None,
    initial_keys: Optional[Dict[int, LweSecretKey]] = None
)

Generate keys required for homomorphic evaluation.

Args: force (bool, default = False): whether to generate new keys even if keys are already generated

secret_seed (Optional[int], default = None): seed for private keys randomness

encryption_seed (Optional[int], default = None): seed for encryption randomness

initial_keys (Optional[Dict[int, LweSecretKey]] = None): initial keys to set before keygen


method load

load(
    path: Union[str, Path],
    keyset_cache_directory: Optional[Path, str] = None,
    is_simulated: bool = False
)  Client

Load the client from the given path in zip format.

Args: path (Union[str, Path]): path to load the client from

keyset_cache_directory (Optional[Union[str, Path]], default = None): keyset cache directory to use

is_simulated (bool, default = False): should perform

Returns: Client: client loaded from the filesystem


method save

save(path: Union[str, Path])

Save the client into the given path in zip format.

Args: path (Union[str, Path]): path to save the client


method simulate_decrypt

simulate_decrypt(
    *results: Union[Value, Tuple[Value, ]],
    function_name: Optional[str] = None
)  Union[int, ndarray, Tuple[Union[int, ndarray, NoneType], ], NoneType]

Simulate decryption of result(s) of evaluation.

Args: *results (Union[Value, Tuple[Value, ...]]): result(s) of evaluation function_name (str): name of the function to decrypt for

Returns: Optional[Union[int, np.ndarray, Tuple[Optional[Union[int, np.ndarray]], ...]]]: decrypted result(s) of evaluation


method simulate_encrypt

simulate_encrypt(
    *args: Optional[int, ndarray, List],
    function_name: Optional[str] = None
)  Union[Value, Tuple[Optional[Value], ], NoneType]

Simulate encryption of argument(s) for evaluation.

Args: *args (Optional[Union[int, np.ndarray, List]]): argument(s) for evaluation function_name (str): name of the function to encrypt

Returns: Optional[Union[Value, Tuple[Optional[Value], ...]]]: encrypted argument(s) for evaluation