fhelium.engine.galois
CKKS Galois-automorphism indexing utilities.
rotation_galois_element
function View source
def rotation_galois_element(ring_dimension: int, rotation_step: int, generator: int=3) -> int: ...Map signed rotation_step to odd polynomial galois_element.
The slot convention is torch.roll(slots, shifts=rotation_step). The result
forward_slot_generator_positions
function View source
def forward_slot_generator_positions(ring_dimension: int, generator: int) -> tuple[int, ...]: ...Enumerate canonical coefficient positions by generator powers.
coefficient_galois_gather_indices
function View source
def coefficient_galois_gather_indices(ring_dimension: int, galois_element: int, device: str | torch.device='cpu') -> tuple[torch.Tensor, torch.Tensor]: ...Return gathers implementing
The returned device tensors have shapes [coefficient] with dtypes torch.int32 and torch.int8. For an integral coefficient-domain residue tensor [..., coefficient], destination j reads source_indices[j] and multiplies by source_sign[j]. No RNS limb or batch axis is represented in the tables, so the gather broadcasts across both without mutation.
apply_coefficient_galois_automorphism
function View source
def apply_coefficient_galois_automorphism(residues: torch.Tensor, galois_element: int, moduli: torch.Tensor) -> torch.Tensor: ...Return canonical non-aliasing coefficient residues for
residues has integral [*batch, limb, coefficient] layout on one device in either standard or Montgomery representation. The gather and sign change preserve that representation and exact prime-row order. moduli is a same-dtype/device vector containing the exact modulus for each limb; reducing against it maps signed gather results into canonical