Skip to main content

Crate poulpy_ckks

Crate poulpy_ckks 

Source
Expand description

§poulpy-ckks

Backend-agnostic implementation of the CKKS (Cheon-Kim-Kim-Song) homomorphic encryption scheme, built on top of the low-level primitives provided by poulpy-core, poulpy-hal, and the available compute backends (poulpy-cpu-ref, poulpy-cpu-avx).

The crate uses a bivariate polynomial representation over the Torus (base-2^{base2k} digits) instead of the RNS representation used by most other CKKS libraries. Public precision management is exposed through CKKSMeta:

  • log_delta: base-2 logarithm of the encoded plaintext scaling factor
  • log_budget: remaining homomorphic headroom, also tracked in bits

CKKSMeta also records the SlotsKind of a value: whether its slots are known to be real, or may carry an imaginary part. Operations compose that claim, keeping Real only when every operand is real, so a caller can state it once at encoding time and have the pipelines specialize on it.

Together they define the semantic torus width of a value: k() = log_delta + log_budget. Storage is rounded up to the next multiple of base2k, so the allocated capacity max_k() may exceed the effective width k(). Arithmetic APIs update this metadata for you; buffers always stay at their allocated width, and allocating a destination at exactly the k you want is how results are narrowed.

Safe add/sub operations return K-normalized ciphertexts. Their unnormalized variants live on api::CKKSAddOps and api::CKKSSubOps and write into an layouts::UnnormalizedCKKSCiphertext for callers who want to fuse several linear steps before normalizing explicitly. Limb digits in that wrapper may hold un-propagated carries (wider than base2k bits), so passing it to any DFT-domain primitive (keyswitching, convolution, automorphisms) would produce incorrect decryptions. The wrapper does not implement GLWEToBackendRef or GLWEToBackendMut, making such misuse a compile error. Call layouts::UnnormalizedCKKSCiphertext::normalize before the next keyswitching or convolution step.

§Modules

ModuleRole
approximationReusable minimax fitting, precision/depth selection, composite sign generation, and prepared interval-mapped polynomial evaluation
encodingCKKS encoders/decoders, including slot-wise real/imaginary packing
layoutsCKKS ciphertext/plaintext wrappers and metadata-aware allocation helpers
presetsReady-to-use parameter sets
apiThe public op traits: leveled arithmetic (add, sub, mul, neg, rotate, conjugate), encryption, decryption, rescale, and scratch sizing
api::CKKSBootstrappingOpsThe CKKS bootstrapping pipeline: its one native primitive ModUp (modulus raise), plus CoeffsToSlots / SlotsToCoeffs and EvalMod re-exported as supertraits (api::CKKSDFTOps / api::CKKSEvalModOps); parameterized by layouts::BootstrappingPlan
api::CKKSPaCoOpsPaCo bootstrapping without ModUp or EvalMod; parameterized by layouts::PaCoPlan and a compiled layouts::PaCoContext

Re-exports§

pub use scalar::Quad;

Modules§

api
approximation
Reusable host-side polynomial approximation planning.
default
encoding
Backend-independent CKKS encoding algorithms.
layouts
CKKS-level data structures.
oep
Backend override seams: one unsafe trait CKKS*Impl<BE> per op family.
polynomial
power_basis
prelude
One-stop imports for the common CKKS path.
presets
Ready-to-use CKKS parameter sets.
scalar
Portable quad-precision (IEEE 754 binary128) scalar for high-precision CKKS.

Macros§

impl_ckks_add_defaults
impl_ckks_conjugate_defaults
impl_ckks_copy_defaults
impl_ckks_dft_defaults
Wires a backend into the reference homomorphic-DFT chain: implements the [DFTDefault] and [DFTMatrixDefault] marker impls, inheriting every default-bodied method (which forward to crate::default::dft).
impl_ckks_encapsulated_mod_up_default
Opts a backend into the CKKS reference encapsulated-ModUp pipeline.
impl_ckks_encryption_defaults
impl_ckks_imag_defaults
impl_ckks_infos
Implements the full CKKS scratch-view trait bundle for a nominal backend view wrapper: CKKSInfos, SetCKKSInfos, SetK, BSGSMeta, and SetBSGSMeta.
impl_ckks_mul_defaults
impl_ckks_neg_defaults
impl_ckks_plaintext_defaults
impl_ckks_pow2_defaults
impl_ckks_rotate_defaults
impl_ckks_sub_defaults

Structs§

CKKSLayout
Allocation / precision spec for a CKKS value.
CKKSMeta
CKKS semantic precision metadata carried by ciphertexts and plaintexts.
CoeffsMeta
Coefficient metadata for plan-compiled operands: the DFT factor diagonals (layouts::DFTPlan), the EvalMod polynomial coefficients (layouts::EvalModPlan), and the BSGS polynomial encoders (polynomial::EncodeBSGS).

Enums§

CKKSCompositionError
CKKS composition and alignment errors returned by high-level operations.
CKKSError
Typed error returned by every fallible CKKS operation (the api op traits and the layers backing them).
SlotsKind
Which subfield the encoded slots are known to live in.

Traits§

CKKSCtBounds
Marker bound for CKKS ciphertext type parameters.
CKKSInfos
Common metadata accessors for CKKS ciphertext and plaintext containers.
CKKSPlaintextToBackendMut
Backend-compatible mutable CKKS plaintext storage.
CKKSPlaintextToBackendRef
Backend-compatible shared CKKS plaintext storage.
SetCKKSInfos
Mutable CKKS metadata access for ciphertext/plaintext containers.

Type Aliases§

CKKSResult
Result type of every fallible CKKS operation.