4.1 KiB
module concrete.fhe.tfhers.bridge
Declaration of tfhers.Bridge class.
function new_bridge
new_bridge(circuit: 'Circuit') → Bridge
Create a TFHErs bridge from a circuit.
Args:
circuit(Circuit): compiled circuit
Returns:
Bridge: TFHErs bridge
class Bridge
TFHErs Bridge extend a Circuit with TFHErs functionalities.
input_types (List[Optional[TFHERSIntegerType]]): maps every input to a type. None means a non-tfhers type output_types (List[Optional[TFHERSIntegerType]]): maps every output to a type. None means a non-tfhers type
method __init__
__init__(
circuit: 'Circuit',
input_types: List[Optional[TFHERSIntegerType]],
output_types: List[Optional[TFHERSIntegerType]]
)
method export_value
export_value(value: 'Value', output_idx: int) → bytes
Export a value as a serialized TFHErs integer.
Args:
value(fhe.Value): value to exportoutput_idx(int): the index corresponding to this output
Returns:
bytes: serialized fheuint8
method import_value
import_value(buffer: bytes, input_idx: int) → Value
Import a serialized TFHErs integer as a Value.
Args:
buffer(bytes): serialized integerinput_idx(int): the index of the input expecting this value
Returns:
fhe.Value: imported value
method keygen_with_initial_keys
keygen_with_initial_keys(
input_idx_to_key_buffer: Dict[int, bytes],
force: bool = False,
seed: Optional[int] = None,
encryption_seed: Optional[int] = None
)
Generate keys using an initial set of secret keys.
Args: force (bool, default = False): whether to generate new keys even if keys are already generated
seed (Optional[int], default = None): seed for private keys randomness
encryption_seed (Optional[int], default = None): seed for encryption randomness
input_idx_to_key_buffer(Dict[int, bytes]): initial keys to set before keygen
Raises:
RuntimeError: if failed to deserialize the key
method serialize_input_secret_key
serialize_input_secret_key(input_idx: int) → bytes
Serialize secret key used for a specific input.
Args:
input_idx(int): input index corresponding to the key to serialize
Returns:
bytes: serialized key