5.8 KiB
module concrete.compiler.tfhers_int
Import and export TFHErs integers into Concrete.
class TfhersFheIntDescription
A helper class to create TfhersFheIntDescriptions.
method __init__
__init__(desc: TfhersFheIntDescription)
Wrap the native C++ object.
Args: desc (_TfhersFheIntDescription): object to wrap
Raises:
TypeError: if desc is not of type _TfhersFheIntDescription
property carry_modulus
Modulus of the carry part in each ciphertext
property degree
Tracks the number of operations that have been done
property is_signed
Is the integer signed
property ks_first
Keyswitch placement relative to the bootsrap in a PBS
property lwe_size
LWE size
property message_modulus
Modulus of the message part in each ciphertext
property n_cts
Number of ciphertexts
property noise_level
Noise level
property width
Total integer bitwidth
method from_serialized_fheuint8
from_serialized_fheuint8(buffer: bytes) → TfhersFheIntDescription
Get the description of a serialized TFHErs fheuint8.
Args:
buffer(bytes): serialized fheuint8
Raises:
TypeError: buffer is not of type bytes
Returns:
TfhersFheIntDescription: description of the serialized fheuint8
method get_unknown_noise_level
get_unknown_noise_level() → int
Get unknow noise level value.
Returns:
int: unknown noise level value
method new
new(
width: int,
is_signed: bool,
message_modulus: int,
carry_modulus: int,
degree: int,
lwe_size: int,
n_cts: int,
noise_level: int,
ks_first: bool
) → TfhersFheIntDescription
Create a TfhersFheIntDescription.
Args:
width(int): integer widthis_signed(bool): signed or unsignedmessage_modulus(int): message modulus (not its log2)carry_modulus(int): carry modulus (not its log2)degree(int): degreelwe_size(int): LWE sizen_cts(int): number of ciphertextsnoise_level(int): noise levelks_first(bool): PBS order (keyswitch first, or bootstrap first)
Returns:
TfhersFheIntDescription: TFHErs integer description
class TfhersExporter
A helper class to import and export TFHErs big integers.
method export_fheuint8
export_fheuint8(value: Value, info: TfhersFheIntDescription) → bytes
Convert Concrete value to TFHErs and serialize it.
Args:
value(Value): value to exportinfo(TfhersFheIntDescription): description of the TFHErs integer to export to
Raises:
TypeError: if wrong input types
Returns:
bytes: converted and serialized fheuint8
method import_fheuint8
import_fheuint8(
buffer: bytes,
info: TfhersFheIntDescription,
keyid: int,
variance: float
) → Value
Unserialize and convert from TFHErs to Concrete value.
Args:
buffer(bytes): serialized fheuint8info(TfhersFheIntDescription): description of the TFHErs integer to importkeyid(int): id of the key used for encryptionvariance(float): variance used for encryption
Raises:
TypeError: if wrong input types
Returns:
Value: unserialized and converted value