fhelium.experimental.bootstrap.arithmetic
CKKS arithmetic and depth-dependent scale targets for Bootstrap components.
BootstrapArithmetic
class View source
BootstrapArithmetic(engine: Engine, constant_cache: MutableMapping[object, object] | None = None, retain_ntt: bool = True)Execute Bootstrap CKKS arithmetic with depth-dependent scale targets.
target_scales gives an inspectable multiplication schedule derived from Q group products. Scalar and diagonal products select their plaintext scales to reach that schedule; ciphertext products retain actual scales. constant_cache retains prepared scalar and monomial plaintexts for reuse across evaluation calls. retain_ntt=False selects coefficient-domain results for callers that compose Bootstrap without NTT-retaining Eager operations. FullSlotBootstrap creates this owner internally; custom compositions pass it to linear, polynomial, and periodic-reduction evaluators.
Attributes
| Name | Type | Default/value |
|---|---|---|
engine | Engine | |
constant_cache | MutableMapping[object, object] | None | None |
retain_ntt | bool | True |
target_scales
property
target_scales: tuple[float, ...]Return the selected per-depth arithmetic scales.
The default selection is computed backward from the terminal default scale using for_input follows an actual input scale forward over the requested depths. scaled_targets instead describes coefficient accumulators multiplied by unscaled basis nodes.
for_input
method
def for_input(ciphertext: Ciphertext, required_depths: int) -> BootstrapArithmetic: ...Follow
Polynomial basis nodes use this recurrence through their required depths; coefficient products may select a different output scale.
scaled_targets
method
def scaled_targets(factor: float) -> BootstrapArithmetic: ...Use a common scale factor for polynomial coefficient accumulators.
plaintext_scale
method
def plaintext_scale(input_scale: float, depth: int) -> float: ...Choose
multiply_by_monomial
method
def multiply_by_monomial(ciphertext: Ciphertext, exponent: int) -> Ciphertext: ...Return
align_depths
method
def align_depths(lhs: Ciphertext, rhs: Ciphertext) -> tuple[Ciphertext, Ciphertext]: ...Advance the shallower value to the deeper value's Q depth.
advance_depth
method
def advance_depth(ciphertext: Ciphertext) -> Ciphertext: ...Advance one Q group and return at the next target scale.
multiply_relinearize_rescale
method
def multiply_relinearize_rescale(lhs: Ciphertext, rhs: Ciphertext, *, relinearization_key: RelinearizationKey) -> Ciphertext: ...Return relinearized
multiply_scalar
method
def multiply_scalar(ciphertext: Ciphertext, scalar: complex) -> Ciphertext: ...Multiply by one encoded scalar, rescale, and return target scale.
weighted_scalar_sum
method
def weighted_scalar_sum(terms: Sequence[tuple[Ciphertext, complex]]) -> Ciphertext: ...Return
add_scalar
method
def add_scalar(ciphertext: Ciphertext, scalar: complex) -> Ciphertext: ...Add a scalar without changing depth, scale, domain, or RNS basis.