Skip to main content

Crate poulpy_core

Crate poulpy_core 

Source
Expand description

Backend-agnostic Module-LWE-based homomorphic encryption primitives.

poulpy-core implements the cryptographic building blocks of a Module-LWE (MLWE) fully homomorphic encryption (FHE) scheme on top of the hardware-abstraction layer provided by poulpy_hal. The public operation traits live in api, while their blanket implementations on poulpy_hal::layouts::Module<BE> delegate to backend extension points in oep. This makes the crate portable across CPU, AVX, and future backends.

§Architecture

§Three-layer layout system

Every ciphertext and key type exists in three representations, defined in the layouts module:

LayerPurposeGeneric params
Standard (GLWE<D>, GGSW<D>, …)Serializable, platform-independentD: Data
Compressed (GLWECompressed<D>, …)Reduced storage via seed-based mask regenerationD: Data
Prepared (GLWEPrepared<D, B>, …)DFT-domain, optimised for fast polynomial arithmeticD: Data, B: Backend

D: Data abstracts ownership: Vec<u8> (owned), &[u8] (borrowed), or &mut [u8] (mutable borrow).

§Scratch-space allocation

Operations never allocate on the heap internally. Instead, callers supply a poulpy_hal::layouts::ScratchArena borrow from which temporaries are arena-allocated via ScratchArenaTakeCore. Every operation that needs scratch space has a companion *_tmp_bytes method returning the required byte count.

§Parameter newtypes

Domain quantities are wrapped in u32-backed newtypes with saturating arithmetic: layouts::Degree, layouts::Base2K, layouts::TorusPrecision, layouts::Rank, layouts::Dnum, layouts::Dsize.

§Ciphertext types

  • layouts::LWE – Learning With Errors ciphertext (scalar ring element).
  • layouts::GLWE – Generalised LWE ciphertext (polynomial ring).
  • layouts::GGLWE – Gadget GLWE, a matrix of GLWE rows used for key-switching.
  • layouts::GGSW – Gadget GSW ciphertext, used as the left operand of external products.

§Module overview

ModuleResponsibility
apiSafe, user-facing operation traits
layoutsType definitions for all ciphertext, key, plaintext, and secret layouts
encryptionSecret-key, public-key, and compressed encryption
decryptionDecryption of GLWE, LWE, and tensor ciphertexts
operationsCiphertext arithmetic (add, sub, rotate, shift, normalize, mul)
external_productGGSW x GLWE external product (core HE multiplication)
keyswitchingKey-switching for GLWE, GGLWE, GGSW, and LWE
automorphismGalois automorphisms on ciphertexts and keys
conversionLWE / GLWE and GGLWE -> GGSW conversions
glwe_packerOn-the-fly GLWE packing with O(log N) memory
glwe_packingHashMap-based GLWE slot packing
glwe_traceGLWE trace (sum of automorphisms)
noiseNoise-variance estimation for parameter selection
distSecret-key distribution descriptors
scratchArena-style scratch allocation for ciphertext temporaries

Re-exports§

pub use api::*;
pub use default::encryption::*;
pub use default::operations::*;

Modules§

api
Safe, user-facing trait definitions for Module-LWE operations.
default
layouts
Ciphertext, key, plaintext, and secret-key layout types.
oep
Open extension points for poulpy-core.
test_suite

Macros§

core_backend_test_suite
impl_conversion_defaults_full
Implements [ConversionDefault] for Module<$be> by forwarding every method to the corresponding [conversion_defaults] free function.
impl_decryption_defaults_full
Implements [DecryptionDefault] for Module<$be> by forwarding every method to the corresponding [decryption_defaults] free function.
impl_encryption_defaults_full
Marker opt-in for [EncryptionDefault] on Module<$be>.
impl_gglwe_automorphism_defaults_full
Implements [GGLWEAutomorphismDefault] for Module<$be> by forwarding every method to the corresponding [gglwe_automorphism_defaults] free function.
impl_gglwe_external_product_defaults_full
Implements [GGLWEExternalProductDefault] for Module<$be> by forwarding every method to the corresponding [gglwe_external_product_defaults] free function.
impl_gglwe_keyswitch_defaults_full
Implements [GGLWEKeyswitchDefault] for Module<$be> by forwarding every method to the corresponding [gglwe_keyswitch_defaults] free function.
impl_ggsw_automorphism_defaults_full
Implements [GGSWAutomorphismDefault] for Module<$be> by forwarding every method to the corresponding [ggsw_automorphism_defaults] free function.
impl_ggsw_external_product_defaults_full
Implements [GGSWExternalProductDefault] for Module<$be> by forwarding every method to the corresponding [ggsw_external_product_defaults] free function.
impl_ggsw_keyswitch_defaults_full
Implements [GGSWKeyswitchDefault] for Module<$be> by forwarding every method to the corresponding [ggsw_keyswitch_defaults] free function.
impl_glwe_automorphism_defaults_full
Implements [GLWEAutomorphismDefault] for Module<$be> by forwarding every method to the corresponding [glwe_automorphism_defaults] free function.
impl_glwe_external_product_defaults_full
Implements [GLWEExternalProductDefault] for Module<$be> by forwarding every method to the corresponding [glwe_external_product_defaults] free function.
impl_glwe_keyswitch_defaults_full
Implements [GLWEKeyswitchDefault] for Module<$be> by forwarding every method to the corresponding [glwe_keyswitch_defaults] free function.
impl_glwe_packing_defaults_full
Implements [GLWEPackingDefault] for Module<$be> by forwarding every method to the corresponding [glwe_packing_defaults] free function.
impl_glwe_rotate_impl_from
Delegate the GLWERotateImpl family to another host backend through the module-owned transfer API.
impl_glwe_trace_defaults_full
Implements [GLWETraceDefault] for Module<$be> by forwarding every method to the corresponding [glwe_trace_defaults] free function.
impl_lwe_keyswitch_defaults_full
Implements [LWEKeyswitchDefault] for Module<$be> by forwarding every method to the corresponding [lwe_keyswitch_defaults] free function.

Enums§

Distribution
Describes the probability distribution used to sample secret-key coefficients.

Traits§

GetDistribution
Read-only access to the Distribution associated with a secret key.
GetDistributionMut
Mutable access to the Distribution associated with a secret key.
ScratchArenaTakeCore
Backend-native arena allocation for core ciphertext/key layouts.