The MLIR dialect, its conversion passes (TFHEToConcrete, ConcreteToCAPI, ConcreteToLLVM), the optimizer component, the compiler binary, the Rust crate and the program_info parameter file all still carried the upstream project's name. They now carry this one's. Two things deliberately keep the word, because in them it is not the name. mlir::OpTrait CRTP parameters mean "the derived type", so they are spelled Derived and OpTy — LLVM's other conventional spelling for the same idiom. concreteShape is a capnp field: renaming it would change the serialized protocol, and the prose describing it is ordinary English. This also repairs references the earlier partial rename left dangling: Security.cpp included concrete/curves.gen.h and the directory is torus/, torus-cpu.h included concrete-num_complex.h, the Torus dialect CMakeLists named ConcreteOps.td, and compiler/setup.py asked find_namespace_packages for a "concrete" package that no longer exists — so it built without the package it ships.
5.5 KiB
module torus.fhe.compilation.keys
Declaration of Keys class.
class Keys
Keys class, to manage generate/reuse keys.
Includes encryption keys as well as evaluation keys. Be careful when serializing/saving keys!
method __init__
__init__(
specs: Optional[ClientSpecs],
cache_directory: Optional[Path, str] = None
)
property are_generated
Get if the keys are already generated.
property evaluation
Get only evaluation keys.
property specs
Return the associated client specs if any.
method deserialize
deserialize(serialized_keys: Union[Path, bytes]) → Keys
Deserialize keys from file or buffer.
Prefer using a Path instead of bytes in case of big Keys. It reduces memory usage.
Args: serialized_keys (Union[Path, bytes]): previously serialized keys (either Path or buffer)
Returns: Keys: deserialized keys
method generate
generate(
force: bool = False,
secret_seed: Optional[int] = None,
encryption_seed: Optional[int] = None,
initial_keys: Optional[dict[int, LweSecretKey]] = None
)
Generate new keys.
Args: force (bool, default = False): whether to generate new keys even if keys are already generated/loaded
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(location: Union[str, Path])
Load keys from a location.
Args: location (Union[str, Path]): location to load from
method load_from_bytes
load_from_bytes(serialized_keys: bytes)
Load keys from bytes.
Args:
serialized_keys(bytes): serialized keys to load from
method load_if_exists_generate_and_save_otherwise
load_if_exists_generate_and_save_otherwise(
location: Union[str, Path],
secret_seed: Optional[int] = None
)
Load keys from a location if they exist, else generate new keys and save to that location.
Args: location (Union[str, Path]): location to load from or save to
secret_seed (Optional[int], default = None): seed for randomness in case keys need to be generated
method save
save(location: Union[str, Path])
Save keys to a location.
Saved keys are not encrypted, so be careful how you store/transfer them!
Args: location (Union[str, Path]): location to save to
method serialize
serialize() → bytes
Serialize keys into bytes.
Serialized keys are not encrypted, so be careful how you store/transfer them! serialize_to_file is supposed to be more performant as it avoid copying the buffer between the Compiler and the Frontend.
Returns: bytes: serialized keys
method serialize_to_file
serialize_to_file(path: Path)
Serialize keys into a file.
Serialized keys are not encrypted, so be careful how you store/transfer them! This is supposed to be more performant than serialize as it avoid copying the buffer between the Compiler and the Frontend.
Args:
path(Path): where to save serialized keys