fhelium.engine.ckks_encryptor
CKKS encryption for exact Plaintext values.
CkksEncryptor
class View source
CkksEncryptor(*, config: CkksConfig, device: torch.device, rng: Csprng, rns_layout: RnsLayout, rns_runtime: RnsRuntime, montgomery_parameters: MontgomeryParameters, plaintext_codec: CkksPlaintextCodec, engine_id: str, validate_public_level: Callable[[object], int], ciphertext_from_components: Callable[..., Ciphertext])Encrypt exact coefficients under one engine-owned public key policy.
The component constructs two-component phases fhelium.engine.CkksEngine.
encrypt
method
def encrypt(plaintext: Plaintext, public_key: PublicKey) -> Ciphertext: ...Encrypt exact integer coefficients under public_key.
For
Slots input is encoded first using its stored actual scale. Decode-only approximate_coefficients and RNS input are rejected. Input layout [*batch, coefficient] has engine integral dtype/device and final extent [component=2, *batch, limb, coefficient] layout, coefficient domain, canonical standard residues, Q or QP basis selected by the public key, exact active prime_ids, unchanged level, and
encrypt_message
method
def encrypt_message(message, public_key: PublicKey, *, level: int=0, scale=None) -> Ciphertext: ...Encode and encrypt one CKKS message at the provided per-value scale.
For canonical slots
and encrypt so that
Coefficients are quantized with the codec's stochastic-rounding law. Ordinary bounded coefficients use the native CUDA lift. If any scaled coefficient exceeds int64, safe coefficients are still stochastically rounded while already-integral wide binary64 coefficients are converted to Python integers and reduced into each RNS row. Both paths produce the same semantic ciphertext representation. Output has layout [component=2, *batch, limb, coefficient], engine integral dtype/device, coefficient domain, canonical standard residues, exact Q or QP prime_ids selected by the key, requested level, and actual scale