Choosing parameters
A pipeline's homomorphic parameters are defined in HomParams. Four fields need an explicit choice on almost every pipeline: full_q_list_precision, n, pt_scale, and num_special_primes. The rest are covered at the end of this page.
Primary parameters
Bit precision of each RNS prime in the modulus chain. Write it as a tuple of tuples, for example ((61,), (61,)) for two levels at 61 bits each. Each inner tuple corresponds to one level (a row in RNS form). The full row-and-column structure is covered on Level budget.
n to stay secure.Ring dimension. A single ciphertext has internal_n = n / 2 physical slots in CKKS, and together with the total modulus (and secret-key Hamming weight) it sets the pipeline's security parameter. Packed data uses n_slots, which defaults to internal_n. For most large enough pipelines, n = 2**16 is the usual starting point when you need about 128-bit security; smaller powers of two can work for shallow pipelines if an estimator still reports enough security.
n up. Security depends on the size of n relative to the total modulus of the chain, so a larger total modulus needs a larger n to stay secure. Slot capacity also matters: each ciphertext holds internal_n = n / 2 physical slots in CKKS, but a larger input does not always require a larger n; you can batch across multiple ciphertexts at a smaller secure n, which is often faster overall. Pick the smallest n that stays secure for your chain. Setting n_slots smaller than internal_n does not shrink n or the ciphertext. Advanced parameters covers that packing field.n you need for security.Plaintext encryption scale. In CKKS, encryption has the form ct = a·sk + pt_scale·m + e. It sets the starting error-to-plaintext ratio for the encoded message, and it is the starting scale carried on each ciphertext (Ciphertext state).
pt_scale gives more initial accuracy headroom for deeper pipelines, because the signal-to-error ratio of the underlying plaintext drops as operations accumulate. Two scale rules matter in practice: after a mod-switch that drops a prime of size B, scale becomes A / B; after multiplying two ciphertexts at scales A and B, the result is at A * B. Raising pt_scale does not by itself force a longer chain, but you still need primes that can hold the scales your pipeline produces, and the resulting total modulus must stay secure for your n.n.pt_scale must be at least 2**30. Common working values are in the 2**30 to 2**50 range.Number of special primes used during hybrid key switching. Almost every pipeline needs an explicit choice here, even though it is not part of the modulus chain itself.
decomposition_type=DecompositionType.HYBRID). Each special prime is 61 bits. A larger value lowers dnum, which shrinks the digit dimension of auxiliary keys (rotation and square keys) and speeds digit decomposition during key switching. A smaller value reduces the number of limbs on those keys and speeds the modDown step: a memory tradeoff. The best value for a pipeline depends on its size; find it by trying a few candidates.dnum, smaller digit dimension on auxiliary keys, faster digit decomposition.decomposition_type=DecompositionType.BV, set bv_gadget_bits instead; see Advanced parameters.Pick them in this order
full_q_list_precisionmodulus chain precisionstage_sizes setting you plan to use. Settle the chain first.nring dimensioninternal_n = n / 2 slots per ciphertext in CKKS; if needed, batch across multiple ciphertexts instead of raising n. A smaller n_slots does not let you pick a smaller n.pt_scaleplaintext encryption scale2**30. Remember that mod-switch divides scale by the dropped prime and multiplication multiplies scales. Tune upward if results drift.num_special_primeshybrid key-switchingDecompositionType.BV, configure bv_gadget_bits instead.Security
There is no built-in security parameter. Nothing in HomParams sets or checks a security level for you. Security is a property of the values you chose, and confirming it is your responsibility before deploying.
n, the total modulus of the chain, and the secret-key Hamming weight sk_hw. A larger total modulus needs a larger n (or a different sk_hw) to stay secure. The framework validates structural constraints (power-of-two n, prime bit ranges) but does not compute a bit-security estimate.n, the total modulus size, and the error distribution), or use your own in-house estimation. We do not ship a calculator.Because total modulus size feeds the security requirement, every level you save through careful depth counting is not just speed. A shorter chain lets you hold the same security at a smaller n, which is faster everywhere.
A starter set
from lattica_build.params import DecompositionType, HomParams params = HomParams( full_q_list_precision=((61,), (45,)), n=2 ** 8, pt_scale=2 ** 20, decomposition_type=DecompositionType.BV, )
pt_scale. If key size or key-switch time dominates, try nearby num_special_primes values.Advanced parameters
HomParams. Most pipelines leave these at their defaults until a specific need appears.n_slotsint | None (power of two)Block size used to pack the primary input. Unset (the default) means dense packing: n_slots becomes internal_n (n / 2 in CKKS). When set, must be a power of two and ≤ internal_n. Does not shrink the ring or the ciphertext. Encryption repeats the block to fill the physical ring; see Ciphertext state for the pad-and-repeat layout. Other named inputs use custom_n_slots, not this field.err_stdfloatStandard deviation of the encryption error distribution. Keep the default 3.19: smaller values make the pipeline susceptible to attacks independently of n and Q; larger values reduce accuracy. Public estimators often assume 3.19 as an input.sk_hwintHamming weight of the secret key. 0 (the default) gives a uniform ternary key, each coefficient uniform in −1, 0, 1. A value above 0 forces exactly that many nonzero coefficients: a sparse key, which reduces noise growth and can speed evaluation. A sparse key changes the security parameter, so any nonzero value must go into your external security estimate along with n and the total modulus precision.decomposition_typeDecompositionTypeKey-switching decomposition strategy. Default is HYBRID. See Decomposition types below.bv_gadget_bitsintRequired when decomposition_type=DecompositionType.BV: bit size of each digit in the gadget decomposition of auxiliary keys. Larger values mean a smaller key at the cost of more key-switch noise. Default is 4; must be a positive integer under BV.bootstrapping_variantslim | realWhen the pipeline includes Bootstrap or HomRingSwitch, which bootstrap variant the pipeline uses (REAL or SLIM). See Bootstrap.num_init_rowsint | NoneHow many rows of q_list form the initial modulus of the input ciphertext. Default None encrypts under the full pipeline q_list. Valid values are from 1 (first prime only) through the number of rows (same as None). When the pipeline includes Bootstrap or HomRingSwitch, the pipeline also has an extra prime q0 not listed in q_list, and num_init_rows=0 encrypts under q0 alone.n_slots on HomParams is the block size used to pack the primary input. Leave it unset for dense packing, where the block is the whole ring: n_slots becomes internal_n. Set a smaller power of two and encryption repeats that block internal_n / n_slots times to fill the ring. The layout is on Ciphertext state.from lattica_build.params import HomParams params = HomParams( n=2 ** 16, # ring degree → internal_n = 2**15 in CKKS n_slots=2 ** 10, # pack into 1024 slots, tile 32 times # ... other HomParams fields )
params.n_slots. For each named input that needs a smaller block, set HomomorphicPipeline.custom_n_slots[input_name]. A named input with no entry there is packed densely (internal_n), even when the primary input uses a smaller block. Do not list the primary input in custom_n_slots; it is set only through HomParams.n_slots.n_slots on the input ciphertext, which is where you see it when you print the graph. Operators such as HomExpand read it from there, so you set the block size here, not on the operator.bootstrapping flag on HomParams.Decomposition types
decomposition_type controls how key-switching decomposes ciphertexts. With the default HYBRID, tune num_special_primes; with BV, set bv_gadget_bits. These choices affect key size, noise, and key-switch cost; they do not change your pipeline graph, shapes, or level budget.HYBRIDdefaultBVgadgetnum_special_primes you chose above.