fhelium.experimental.mpc
Tensor operations for collective CKKS key and output protocols.
The package exposes share-generation and aggregation functions for collective key generation, evaluation-key generation, collective decryption arithmetic, and public-key switching arithmetic. Its supported scope is arithmetic correctness for compatible FHElium values and engine tensors. The implementation accepts a local CPU or CUDA CkksEngine. The package provides no authentication, transcript binding, malicious-party security, reviewed output-error sampler, supported smudging/useful-precision parameter profile, or privacy guarantee. Functions whose names begin with unsafe_ require caller-supplied output randomness and errors.
aggregate_ckg
function View source
def aggregate_ckg(engine: CkksEngine, 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: CkksEngine, 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: CkksEngine, shares: Sequence[RkgMessage]) -> RkgMessage: ...Aggregate each Protocol-2 round-one message family independently.
aggregate_rkg_round2
function View source
def aggregate_rkg_round2(engine: CkksEngine, 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: CkksEngine, 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: CkksEngine, 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: CkksEngine, 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: CkksEngine, 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: CkksEngine, 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: CkksEngine, 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: CkksEngine, *, basis: Basis, count: int | 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 exact returned values to every participant.
sample_secret_share
function View source
def sample_secret_share(engine: CkksEngine) -> SecretKey: ...Sample one additive secret share in complete level-zero QP form.
unsafe_collective_decryption_share
function View source
def unsafe_collective_decryption_share(engine: CkksEngine, ciphertext: Ciphertext, secret_share: SecretKey, *, smudging_error_coefficients: torch.Tensor) -> torch.Tensor: ...Return arithmetic-only
smudging_error_coefficients must have exact [*ciphertext.batch_shape, N] contiguous engine-integral layout on engine.device. Distribution selection and privacy analysis belong to the caller.
unsafe_fuse_collective_decryption
function View source
def unsafe_fuse_collective_decryption(engine: CkksEngine, 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: CkksEngine, 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: CkksEngine, 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 exact [*ciphertext.batch_shape, N] contiguous engine-integral layout on engine.device. Freshness, smallness, smudging adequacy, and destination-key provenance are caller responsibilities.