5.9 KiB
module concrete.compiler.client_support
Client support.
Global Variables
- ACCEPTED_INTS
- ACCEPTED_NUMPY_UINTS
- ACCEPTED_TYPES
class ClientSupport
Client interface for doing key generation and encryption.
It provides features that are needed on the client side:
- Generation of public and private keys required for the encrypted computation
- Encryption and preparation of public arguments, used later as input to the computation
- Decryption of public result returned after execution
method __init__
__init__(client_support: ClientSupport)
Wrap the native Cpp object.
Args:
client_support(_ClientSupport): object to wrap
Raises:
TypeError: if client_support is not of type _ClientSupport
method decrypt_result
decrypt_result(
client_parameters: ClientParameters,
keyset: KeySet,
public_result: PublicResult,
circuit_name: str
) → Union[int, ndarray]
Decrypt a public result using the keyset.
Args:
client_parameters(ClientParameters): client parameters for decryptionkeyset(KeySet): keyset used for decryptionpublic_result(PublicResult): public result to decryptcircuit_name(str): name of the circuit for which to decrypt
Raises:
TypeError: if keyset is not of type KeySetTypeError: if public_result is not of type PublicResultTypeError: if circuit_name is not of type strRuntimeError: if the result is of an unknown type
Returns:
Union[int, np.ndarray]: plain result
method encrypt_arguments
encrypt_arguments(
client_parameters: ClientParameters,
keyset: KeySet,
args: List[Union[int, ndarray]],
circuit_name: str
) → PublicArguments
Prepare arguments for encrypted computation.
Pack public arguments by encrypting the ones that requires encryption, and leaving the rest as plain. It also pack public materials (public keys) that are required during the computation.
Args:
client_parameters(ClientParameters): client parameters specificationkeyset(KeySet): keyset used to encrypt arguments that require encryptionargs(List[Union[int, np.ndarray]]): list of scalar or tensor argumentscircuit_name(str): the name of the circuit for which to encrypt
Raises:
TypeError: if client_parameters is not of type ClientParametersTypeError: if keyset is not of type KeySetTypeError: if circuit_name is not of type str
Returns:
PublicArguments: public arguments for execution
method key_set
key_set(
client_parameters: ClientParameters,
keyset_cache: Optional[KeySetCache] = None,
secret_seed: Optional[int] = None,
encryption_seed: Optional[int] = None,
initial_lwe_secret_keys: Optional[Dict[int, LweSecretKey]] = None
) → KeySet
Generate a key set according to the client parameters.
If the cache is set, and include equivalent keys as specified by the client parameters, the keyset is loaded, otherwise, a new keyset is generated and saved in the cache. If keygen is required, it will first initialize the secret keys provided, if any.
Args:
client_parameters(ClientParameters): client parameters specificationkeyset_cache(Optional[KeySetCache], optional): keyset cache. Defaults to None.secret_seed(Optional[int]): secret seed, must be a positive 128 bits integerencryption_seed(Optional[int]): encryption seed, must be a positive 128 bits integerinitial_lwe_secret_keys(Optional[Dict[int, LweSecretKey]]): keys to init the keyset with before keygen. It maps keyid to secret key
Raises:
TypeError: if client_parameters is not of type ClientParametersTypeError: if keyset_cache is not of type KeySetCacheAssertionError: if seed components is not uint64
Returns:
KeySet: generated or loaded keyset
method new
new() → ClientSupport
Build a ClientSupport.
Returns: ClientSupport