Composable CKKS bootstrapping
FHElium composes bootstrapping from replaceable mathematical components executed through the ordinary CkksEngine, Ciphertext, NTT, and native operator stack. The built-in FullSlotBootstrap makes its linear maps, periodic reduction, level budget, primitive-key requirements, and private scale policy visible.
The mathematical map
Let:
be the ring dimension and the complex slot count; beconfig.default_scale; be the structural base Q prime; and be the unscaled CoeffsToSlots and SlotsToCoeffs maps, with in FHElium's cyclotomic slot order; be a periodic reducer'sinput_bound.
After the final public scale-prime drop, centered ModRaise extends each ciphertext component from [q_b] into the selected target Q prefix. If
The values
Both built-in periodic reductions approximate
For
The polynomial fit, CKKS rounding, key switching, and internal scale reinterpretations perturb this idealized expression. input_bound is therefore a mathematical input precondition, not a range measured from ciphertext data. Applications must establish
Full-slot state flow
The built-in callable executes:
All public pipeline ciphertexts have axes [component, *batch, limb, coefficient], two components, Q basis, and exact prime_ids. They remain in coefficient domain with standard residues between operations. NTT-domain Montgomery values are temporary arithmetic inputs. Each linear stage consumes one leading Q row and follows the actual scale recurrence
The bootstrap's scalar and ciphertext-multiplication helpers reinterpret their rescale results at default_scale.
Raw and normalized reducer coordinates
CosineDoubleAngleReduction and ExponentialSquaringReduction have two related but intentionally different input-coordinate conventions:
reference(values)always consumes normalized and never divides byinput_bound;evaluate(...)consumes raw whenfuse_input_normalization=Falseand spends one level computing ;- with
fuse_input_normalization=True, the caller must already provide .FullSlotBootstrapdoes so by folding into CoeffsToSlots.
Both routes target
Replaceable decisions
A polynomial evaluator chooses a homomorphic multiplication directed acyclic graph (DAG) for the stored approximation.
| Component | Replaceable decision |
|---|---|
| polynomial approximator | How a function becomes basis-tagged coefficients |
| polynomial evaluator | Which homomorphic multiplication DAG evaluates them |
| linear-transform compiler | How a basis map becomes executable stages |
| linear-transform evaluator | Direct, BSGS, or another stage schedule |
periodic reduction (modular_reduction) | Cosine, exponential, or another periodic approximation |
| ordinary Python | Complete algorithm topology and control flow |
A PolynomialApproximation stores coefficients in ascending degree. Power basis means
Direct and BSGS linear evaluation
A cyclic-diagonal stage represents
The direct evaluator computes every term independently. The baby-step/giant-step (BSGS) evaluator writes
They therefore implement the same mathematical map, output level, actual-scale recurrence, domain, basis, and prime_ids. Their operation grouping and CKKS rounding can differ, so residue tensors need not be bit-identical.
Primitive key dependencies and factories
The built-in callable accepts a RotationKeySet, RelinearizationKey, and ConjugationKey as separate keyword arguments. Its required_rotations and key_steps() queries report the transform rotation schedule, and create_rotation_keys() generates either the exact inventory or the compact signed-power-of-two inventory. Built-in periodic reductions require the relinearization key for ciphertext products. Full branch handling requires the conjugation key; the exponential reduction also uses it for sine extraction.
The versioned experimental logn16 factories identify measured component configurations; they are not numerical certificates. The documented end-to-end configuration is derived from Preset.slots32768_scale50_levels27_int64 with base_prime_bits=50 and is bound to an engine using galois_generator=5. Construction checks transform slot counts, structural-base/default-scale proximity, and modulus-chain depth. It does not enforce the deployment identity, inspect the encrypted branch range, or guarantee an application tolerance. Other configurations require independent range, depth, precision, and performance validation.