fhelium.config
CKKS parameter, NTT-policy, and security-assessment interfaces.
Public modules are named for the configured subject: ckks owns the CKKS parameter model, ntt owns NTT execution policies, and security assesses complete modulus sets against the published table built into FHElium. Private resource mechanisms use a leading underscore, as in _prime_catalog.
DEFAULT_CPU_NTT_BACKEND
constant View source
DEFAULT_CPU_NTT_BACKEND: Final[str] = 'radix2_indexed'DEFAULT_NTT_BACKEND
constant View source
DEFAULT_NTT_BACKEND: Final[str] = 'radix2_compact_group8_smem8'SUPPORTED_NTT_BACKENDS
constant View source
SUPPORTED_NTT_BACKENDS: Final = tuple(NTT_BACKEND_POLICIES)CkksConfig
class View source
CkksConfig(*, default_scale: float, q_depth_groups: tuple[tuple[int, ...], ...], p_moduli: tuple[int, ...], logN: int, sigma: float=3.19, security_bits: int=128, enforce_security_budget: bool=True, galois_generator: int=3)Immutable CKKS mathematical and security parameters.
The configuration defines CKKS over
q_depth_groups contains ordered Q groups. At depth d, the active Q basis is the concatenation of groups d:. A rescale removes group d and advances to d + 1. The last group is the terminal basis: max_depth == len(q_depth_groups) - 1 and no further rescale exists there. Depth identifies the active basis; it does not count multiplications or record how the value reached that basis.
p_moduli contains the special primes whose product is the key-switch modulus P. default_scale is used only when value creation omits a scale; every live plaintext and ciphertext carries its own actual scale. The Engine selects the residue dtype and Montgomery radix from these exact primes, and each device-local RNS context materializes the corresponding arithmetic tables.
parse
method
def parse(src: Mapping[str, Any] | Preset, **overrides: Any) -> 'CkksConfig': ...Resolve a preset or a serialized exact configuration.
dumps
method
def dumps() -> dict[str, object]: ...Return a versioned dictionary containing the exact parameter set.
N
property
N: intPolynomial ring dimension.
num_slots
property
num_slots: intNumber of complex CKKS slots,
max_depth
property
max_depth: intGreatest public CKKS depth represented by this Q chain.
depth_remaining
method
def depth_remaining(depth: int) -> int: ...Return the public rescale transitions remaining at depth.
q_moduli
property
q_moduli: tuple[int, ...]Q primes in depth-group and within-group order.
moduli
property
moduli: tuple[int, ...]Complete QP prime sequence used by RNS resources.
num_q_primes
property
num_q_primes: intNumber of prime rows in the complete Q chain.
num_p_primes
property
num_p_primes: intNumber of special-prime rows in P.
total_num_primes
property
total_num_primes: intNumber of prime rows in the complete QP basis.
rescale_divisor
method
def rescale_divisor(depth: int) -> int: ...Return the Q-group product removed at one public depth.
q_row_start
method
def q_row_start(depth: int) -> int: ...Return the first Q row active at depth.
active_q_moduli
method
def active_q_moduli(depth: int) -> tuple[int, ...]: ...Return the ordered Q primes active at depth.
inverse_ntt_scale
property
inverse_ntt_scale: tuple[int, ...]Return
total_modulus_bits
property
total_modulus_bits: intBit width of the complete QP product.
maximum_modulus_bits
property
maximum_modulus_bits: intBuilt-in complete-QP budget for the selected security category.
security_assessment
property
security_assessment: SecurityAssessmentReturn the built-in assessment of the complete QP product.
validate_security_budget
method
def validate_security_budget() -> SecurityAssessment: ...Require the complete QP product to meet the configured budget.
Preset
class View source
Preset()Bases: Enum
Built-in CKKS parameter presets.
Each member name records the complex slot capacity, default scale bits, maximum public depth, and the Engine's selected residue dtype for its prime set. All baselines select the 128-bit classical security category, Gaussian error standard deviation 3.19, uniform-ternary secret sampling, and a ring-specific P-prime count. CkksConfig.parse accepts keyword overrides when an application needs a derived configuration.
Attributes
| Name | Type | Default/value |
|---|---|---|
slots8192_scale30_depth9_int64 | 'slots8192-scale30-depth9-int64' | |
slots8192_scale40_depth7_int64 | 'slots8192-scale40-depth7-int64' | |
slots8192_scale50_depth5_int64 | 'slots8192-scale50-depth5-int64' | |
slots16384_scale30_depth21_int64 | 'slots16384-scale30-depth21-int64' | |
slots16384_scale40_depth16_int64 | 'slots16384-scale40-depth16-int64' | |
slots16384_scale50_depth12_int64 | 'slots16384-scale50-depth12-int64' | |
slots32768_scale30_depth45_int64 | 'slots32768-scale30-depth45-int64' | |
slots32768_scale40_depth34_int64 | 'slots32768-scale40-depth34-int64' | |
slots32768_scale50_depth27_int64 | 'slots32768-scale50-depth27-int64' | |
slots32768_scale50_depth29_int64 | 'slots32768-scale50-depth29-int64' | |
slots65536_scale30_depth95_int64 | 'slots65536-scale30-depth95-int64' | |
slots65536_scale40_depth72_int64 | 'slots65536-scale40-depth72-int64' | |
slots65536_scale50_depth58_int64 | 'slots65536-scale50-depth58-int64' | |
slots8192_scale25_depth14_int32 | 'slots8192-scale25-depth14-int32' | |
slots16384_scale25_depth29_int32 | 'slots16384-scale25-depth29-int32' | |
slots32768_scale25_depth24_int32 | 'slots32768-scale25-depth24-int32' | |
slots65536_scale25_depth14_int32 | 'slots65536-scale25-depth14-int32' |
SecurityAssessment
class View source
SecurityAssessment(status: Literal['meets', 'exceeds', 'unsupported'], ring_dimension: int, target_bits: int, secret_distribution: str, error_stddev: float, modulus_bits: int, maximum_modulus_bits: int | None, modulus_margin_bits: int | None, reason: str | None)Immutable result of a built-in parameter assessment.
status is "meets" when "exceeds" when it is larger, and "unsupported" when no table row matches the assumptions. An unsupported result has None for maximum_modulus_bits and modulus_margin_bits. A negative modulus margin reports how far a supported parameter tuple exceeds its modulus budget; it is not a bit-security margin.
Attributes
| Name | Type | Default/value |
|---|---|---|
status | Literal['meets', 'exceeds', 'unsupported'] | |
ring_dimension | int | |
target_bits | int | |
secret_distribution | str | |
error_stddev | float | |
modulus_bits | int | |
maximum_modulus_bits | int | None | |
modulus_margin_bits | int | None | |
reason | str | None |
assess_config_security
function View source
def assess_config_security(config: CkksConfig) -> SecurityAssessment: ...Assess a fhelium.config.CkksConfig complete QP modulus.
assess_security
function View source
def assess_security(ring_dimension: int, *, modulus: int | None=None, moduli: Sequence[int] | None=None, target_bits: int=128, secret_distribution: str='ternary', error_stddev: float=_TABLE_ERROR_STANDARD_DEVIATION) -> SecurityAssessment: ...Assess a complete modulus against one built-in budget row.
Parameters
ring_dimension: Polynomial-ring dimensionN.modulus: Complete parameter modulusq. For CKKS hybrid key switching this isQ * P.moduli: Factors of the complete parameter modulus. Specify this ormodulus, but not both.target_bits: Classical security category.secret_distribution: Table secret distribution,"ternary"or"gaussian".error_stddev: Gaussian error standard deviation. The built-in budgets support exactly3.19.
Returns
A structured assessment with status, modulus-bit width, budget, margin, and an unsupported reason when applicable. Parameters without a matching row return status="unsupported"; this function never interpolates or extrapolates.
Raises
TypeError: If an input has the wrong structural type.ValueError: If a numeric input is non-positive or non-finite, or the modulus inputs are missing or ambiguous.
compatible_ntt_backends
function View source
def compatible_ntt_backends(log_ring_dimension: int) -> tuple[str, ...]: ...Return registered policy names executable for one logN.
Names retain registry order. Strict fixed-radix policies whose digit width does not divide log_ring_dimension are omitted; grouped radix-2 policies remain available for every supported ring dimension. A non-positive dimension raises ValueError.