fhelium/ckks_parameters.h
#include <fhelium/ckks_parameters.h> · namespace fhelium::ckks
CKKS parameter presets, the packaged prime catalog, and the security budget table.
A parameter set defines CKKS over
CkksParameters
struct View source
A resolved CKKS parameter set.
| Member | Description |
|---|---|
int64_t log_n = 0 | |
std::vector<int64_t> q_moduli | Ordered Q primes. |
std::vector<std::vector<int64_t>> q_bases | Increasing Q prime ids of each depth's basis. |
std::vector<double> scales | Default scale of each depth. |
std::vector<int64_t> p_moduli | Primes reserved for key-switch auxiliary moduli. |
KeyLayout
struct View source
Prime rows of a hybrid key-switch layout: active Q rows, auxiliary P rows, and the Q rows of each digit.
| Member | Description |
|---|
| Function | Devices | Summary |
|---|---|---|
scaling_primes | Any device | Returns the catalog's ordered scaling-prime candidates of width prime_bits for ring dimension ring_dimension. |
special_primes | Any device | Returns the catalog's ordered special-prime candidates of width prime_bits (28 or 60) for ring dimension ring_dimension. |
preset_names | Any device | Returns the names of the built-in presets. |
preset_parameters | Any device | Resolves the built-in preset name to its primes. |
validate_moduli | Any device | Checks that moduli are distinct odd integers above two with |
modulus_bits | Any device | Returns moduli. |
key_digit_sizes | Any device | Returns the sizes of the hybrid key-switching digits of q_moduli. |
plan_key_layout | Any device | Hybrid key-switch layout of the active Q rows q_prime_ids of a chain whose configured primes are moduli (Q and P, indexed by prime id). |
maximum_modulus_bits | Any device | Returns the maximum bit width of the complete modulus in the built-in security table, or no value when no row matches. |
scaling_primes
function View source
std::vector<int64_t> fhelium::ckks::scaling_primes(
int64_t prime_bits,
int64_t ring_dimension);2
3
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.scaling_primes
fhelium_ckks_ops::scaling_primes(int prime_bits, int ring_dimension) -> int[]Returns the catalog's ordered scaling-prime candidates of width prime_bits for ring dimension ring_dimension.
Every candidate is an NTT prime of the given bit width. The catalog covers widths 20 to 50 in steps of 5 and
special_primes
function View source
std::vector<int64_t> fhelium::ckks::special_primes(
int64_t prime_bits,
int64_t ring_dimension);2
3
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.special_primes
fhelium_ckks_ops::special_primes(int prime_bits, int ring_dimension) -> int[]Returns the catalog's ordered special-prime candidates of width prime_bits (28 or 60) for ring dimension ring_dimension.
preset_names
function View source
std::vector<std::string> fhelium::ckks::preset_names();Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.preset_names
fhelium_ckks_ops::preset_names() -> str[]Returns the names of the built-in presets.
preset_parameters
function View source
CkksParameters fhelium::ckks::preset_parameters(
std::string_view name);2
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.preset_parameters
fhelium_ckks_ops::preset_parameters(str name) -> (int, int[], int[], int[], float[], int[])Resolves the built-in preset name to its primes.
Every preset uses NTT primes below scripts/generate_ckks_presets.py generates the table.
validate_moduli
function View source
void fhelium::ckks::validate_moduli(
int64_t log_n,
c10::ArrayRef<int64_t> moduli);2
3
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.validate_moduli
fhelium_ckks_ops::validate_moduli(int log_n, int[] moduli) -> ()Checks that moduli are distinct odd integers above two with
modulus_bits
function View source
int64_t fhelium::ckks::modulus_bits(
c10::ArrayRef<int64_t> moduli);2
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.modulus_bits
fhelium_ckks_ops::modulus_bits(int[] moduli) -> intReturns moduli.
key_digit_sizes
function View source
std::vector<int64_t> fhelium::ckks::key_digit_sizes(
c10::ArrayRef<int64_t> q_moduli,
c10::ArrayRef<int64_t> p_moduli);2
3
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.key_digit_sizes
fhelium_ckks_ops::key_digit_sizes(int[] q_moduli, int[] p_moduli) -> int[]Returns the sizes of the hybrid key-switching digits of q_moduli.
Digits are consecutive groups of q_moduli, taken in order, each the longest group whose product is below p_moduli. A modulus at or above
plan_key_layout
function View source
KeyLayout fhelium::ckks::plan_key_layout(
c10::ArrayRef<int64_t> moduli,
c10::ArrayRef<int64_t> q_prime_ids);2
3
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.plan_key_layout
fhelium_ckks_ops::plan_key_layout(int[] moduli, int[] q_prime_ids) -> (int[], int[])Hybrid key-switch layout of the active Q rows q_prime_ids of a chain whose configured primes are moduli (Q and P, indexed by prime id).
The auxiliary primes P are the largest configured primes outside the active rows, ties to the lower id. With q active rows, p auxiliary primes, and k digits, one key switch lifts and multiplies k(q + p) rows and divides q + p rows by P; the layout minimizes the row work (k + 1)(q + p), then the key rows k(q + p), then p, where k is the number of greedy runs below P. The digits are k consecutive runs of the active rows that minimize the largest run product.
maximum_modulus_bits
function View source
std::optional<int64_t> fhelium::ckks::maximum_modulus_bits(
int64_t ring_dimension,
int64_t target_bits,
std::string_view secret_distribution,
double error_stddev);2
3
4
5
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.maximum_modulus_bits
fhelium_ckks_ops::maximum_modulus_bits(int ring_dimension, int target_bits, str secret_distribution, float error_stddev) -> int?Returns the maximum bit width of the complete modulus in the built-in security table, or no value when no row matches.
The table reproduces the limits of Security Guidelines for Implementing Homomorphic Encryption (IACR Communications in Cryptology 2025), computed with lattice-estimator under the classical RC.MATZOV cost model. Rows exist for secret_distribution "ternary" and "gaussian", target_bits 128, 192, and 256, error_stddev exactly 3.19.