Files
concrete/docs/dev/api/concrete.compiler.client_support.md
2024-10-07 08:45:33 +02:00

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 decryption
  • keyset (KeySet): keyset used for decryption
  • public_result (PublicResult): public result to decrypt
  • circuit_name (str): name of the circuit for which to decrypt

Raises:

  • TypeError: if keyset is not of type KeySet
  • TypeError: if public_result is not of type PublicResult
  • TypeError: if circuit_name is not of type str
  • RuntimeError: 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 specification
  • keyset (KeySet): keyset used to encrypt arguments that require encryption
  • args (List[Union[int, np.ndarray]]): list of scalar or tensor arguments
  • circuit_name (str): the name of the circuit for which to encrypt

Raises:

  • TypeError: if client_parameters is not of type ClientParameters
  • TypeError: if keyset is not of type KeySet
  • TypeError: 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 specification
  • keyset_cache (Optional[KeySetCache], optional): keyset cache. Defaults to None.
  • secret_seed (Optional[int]): secret seed, must be a positive 128 bits integer
  • encryption_seed (Optional[int]): encryption seed, must be a positive 128 bits integer
  • initial_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 ClientParameters
  • TypeError: if keyset_cache is not of type KeySetCache
  • AssertionError: if seed components is not uint64

Returns:

  • KeySet: generated or loaded keyset

method new

new()  ClientSupport

Build a ClientSupport.

Returns: ClientSupport