fhelium.experimental.mpc._ops
Process-local tensor operations for collective CKKS key and output protocols.
The functions form share-generation and aggregation steps for collective key generation, evaluation-key generation, collective decryption arithmetic, and public-key switching arithmetic. Their supported scope is arithmetic correctness for compatible FHElium values and engine tensors. The implementation accepts a CPU or CUDA Engine. The module provides no authentication, transcript binding, transport, replay protection, malicious-party security, secure aggregation, lineage or persistence policy, reviewed output-error sampler, supported smudging/useful-precision parameter profile, or privacy guarantee. Functions whose names begin with unsafe_ implement secret-dependent output arithmetic with caller-provided randomness and errors. Zero or small errors are correctness fixtures with no privacy property.
Each call operates against one fhelium.eager.Engine. Secret shares and ephemeral Protocol-2 secrets are ordinary process-local fhelium.SecretKey values in the complete depth-zero QP basis. Common randomness and protocol messages are raw integral tensors on their protocol-selected device. The caller owns party membership, all-party participation, freshness, delivery, and pairing each aggregate key with the correct additive shares.
aggregate_ckg
function View source
def aggregate_ckg(engine: Engine, shares: Sequence[torch.Tensor], common_a: torch.Tensor) -> PublicKey: ...Aggregate Protocol-1 shares into an ordinary FHElium public key.
aggregate_conjugation_key
function View source
def aggregate_conjugation_key(engine: Engine, shares: Sequence[torch.Tensor], common_a_by_digit: torch.Tensor) -> ConjugationKey: ...Aggregate distributed shares into one ordinary conjugation key.
aggregate_rkg_round1
function View source
def aggregate_rkg_round1(engine: Engine, shares: Sequence[RkgMessage]) -> RkgMessage: ...Aggregate each Protocol-2 round-one message family independently.
aggregate_rkg_round2
function View source
def aggregate_rkg_round2(engine: Engine, shares: Sequence[RkgMessage], aggregate_round1: RkgMessage) -> RelinearizationKey: ...Aggregate Protocol-2 round two into a relinearization key.
aggregate_rotation_key
function View source
def aggregate_rotation_key(engine: Engine, shares: Sequence[torch.Tensor], common_a_by_digit: torch.Tensor, rotation_step: int) -> RotationKey: ...Aggregate distributed shares into one ordinary rotation key.
ckg_share
function View source
def ckg_share(engine: Engine, secret_share: SecretKey, common_a: torch.Tensor) -> torch.Tensor: ...Return one Protocol-1 share
conjugation_key_share
function View source
def conjugation_key_share(engine: Engine, secret_share: SecretKey, common_a_by_digit: torch.Tensor) -> torch.Tensor: ...Return one distributed conjugation-key share.
rkg_round1_share
function View source
def rkg_round1_share(engine: Engine, secret_share: SecretKey, ephemeral_share: SecretKey, common_a_by_digit: torch.Tensor) -> RkgMessage: ...Return the two separate Protocol-2 round-one message families.
rkg_round2_share
function View source
def rkg_round2_share(engine: Engine, secret_share: SecretKey, ephemeral_share: SecretKey, aggregate_round1: RkgMessage) -> RkgMessage: ...Return the two separate Protocol-2 round-two message families.
rotation_key_share
function View source
def rotation_key_share(engine: Engine, secret_share: SecretKey, common_a_by_digit: torch.Tensor, rotation_step: int) -> torch.Tensor: ...Return one distributed rotation-key share for a signed slot step.
sample_common_uniform
function View source
def sample_common_uniform(engine: Engine, *, basis: Basis, count: int | None=None, device: torch.device | str | None=None) -> torch.Tensor: ...Sample raw common uniform NTT/Montgomery tensors.
The direct row-wise residues are interpreted as uniform NTT/Montgomery values, matching ordinary FHElium key generation. Omitting count returns one unbatched [limb, N] tensor. Every explicit positive count, including count=1, returns [count, limb, N] with a leading item/digit axis. The caller must distribute the returned values to every participant.
sample_secret_share
function View source
def sample_secret_share(engine: Engine, *, device: torch.device | str | None=None) -> SecretKey: ...Sample one additive secret share in complete depth-zero QP form.
unsafe_collective_decryption_share
function View source
def unsafe_collective_decryption_share(engine: Engine, ciphertext: Ciphertext, secret_share: SecretKey, *, smudging_error_coefficients: torch.Tensor) -> torch.Tensor: ...Return arithmetic-only
smudging_error_coefficients must have [*ciphertext.batch_shape, N] contiguous engine-integral layout on the ciphertext device. Distribution selection and privacy analysis belong to the caller.
unsafe_fuse_collective_decryption
function View source
def unsafe_fuse_collective_decryption(engine: Engine, ciphertext: Ciphertext, shares: Sequence[torch.Tensor]) -> Plaintext: ...Fuse arithmetic-only shares and apply the bounded tail-Q decoder.
unsafe_fuse_public_key_switch
function View source
def unsafe_fuse_public_key_switch(engine: Engine, ciphertext: Ciphertext, destination_public_key: PublicKey, shares: Sequence[RkgMessage]) -> Ciphertext: ...Fuse arithmetic-only Protocol-4 shares into a Q ciphertext.
unsafe_public_key_switch_share
function View source
def unsafe_public_key_switch_share(engine: Engine, ciphertext: Ciphertext, secret_share: SecretKey, destination_public_key: PublicKey, *, ephemeral_coefficients: torch.Tensor, smudging_error0_coefficients: torch.Tensor, error1_coefficients: torch.Tensor) -> RkgMessage: ...Return arithmetic-only Protocol-4 share components.
All caller-provided coefficient tensors must have [*ciphertext.batch_shape, N] contiguous engine-integral layout on the ciphertext device. Freshness, smallness, smudging adequacy, and destination-key provenance are caller responsibilities.