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:
| Layer | Purpose | Generic params |
|---|---|---|
Standard (GLWE<D>, GGSW<D>, …) | Serializable, platform-independent | D: Data |
Compressed (GLWECompressed<D>, …) | Reduced storage via seed-based mask regeneration | D: Data |
Prepared (GLWEPrepared<D, B>, …) | DFT-domain, optimised for fast polynomial arithmetic | D: 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
| Module | Responsibility |
|---|---|
api | Safe, user-facing operation traits |
layouts | Type definitions for all ciphertext, key, plaintext, and secret layouts |
| encryption | Secret-key, public-key, and compressed encryption |
| decryption | Decryption of GLWE, LWE, and tensor ciphertexts |
| operations | Ciphertext arithmetic (add, sub, rotate, shift, normalize, mul) |
| external_product | GGSW x GLWE external product (core HE multiplication) |
| keyswitching | Key-switching for GLWE, GGLWE, GGSW, and LWE |
| automorphism | Galois automorphisms on ciphertexts and keys |
| conversion | LWE / GLWE and GGLWE -> GGSW conversions |
| glwe_packer | On-the-fly GLWE packing with O(log N) memory |
| glwe_packing | HashMap-based GLWE slot packing |
| glwe_trace | GLWE trace (sum of automorphisms) |
| noise | Noise-variance estimation for parameter selection |
| dist | Secret-key distribution descriptors |
| scratch | Arena-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] forModule<$be>by forwarding every method to the corresponding [conversion_defaults] free function. - impl_
decryption_ defaults_ full - Implements [
DecryptionDefault] forModule<$be>by forwarding every method to the corresponding [decryption_defaults] free function. - impl_
encryption_ defaults_ full - Marker opt-in for [
EncryptionDefault] onModule<$be>. - impl_
gglwe_ automorphism_ defaults_ full - Implements [
GGLWEAutomorphismDefault] forModule<$be>by forwarding every method to the corresponding [gglwe_automorphism_defaults] free function. - impl_
gglwe_ external_ product_ defaults_ full - Implements [
GGLWEExternalProductDefault] forModule<$be>by forwarding every method to the corresponding [gglwe_external_product_defaults] free function. - impl_
gglwe_ keyswitch_ defaults_ full - Implements [
GGLWEKeyswitchDefault] forModule<$be>by forwarding every method to the corresponding [gglwe_keyswitch_defaults] free function. - impl_
ggsw_ automorphism_ defaults_ full - Implements [
GGSWAutomorphismDefault] forModule<$be>by forwarding every method to the corresponding [ggsw_automorphism_defaults] free function. - impl_
ggsw_ external_ product_ defaults_ full - Implements [
GGSWExternalProductDefault] forModule<$be>by forwarding every method to the corresponding [ggsw_external_product_defaults] free function. - impl_
ggsw_ keyswitch_ defaults_ full - Implements [
GGSWKeyswitchDefault] forModule<$be>by forwarding every method to the corresponding [ggsw_keyswitch_defaults] free function. - impl_
glwe_ automorphism_ defaults_ full - Implements [
GLWEAutomorphismDefault] forModule<$be>by forwarding every method to the corresponding [glwe_automorphism_defaults] free function. - impl_
glwe_ external_ product_ defaults_ full - Implements [
GLWEExternalProductDefault] forModule<$be>by forwarding every method to the corresponding [glwe_external_product_defaults] free function. - impl_
glwe_ keyswitch_ defaults_ full - Implements [
GLWEKeyswitchDefault] forModule<$be>by forwarding every method to the corresponding [glwe_keyswitch_defaults] free function. - impl_
glwe_ packing_ defaults_ full - Implements [
GLWEPackingDefault] forModule<$be>by forwarding every method to the corresponding [glwe_packing_defaults] free function. - impl_
glwe_ rotate_ impl_ from - Delegate the
GLWERotateImplfamily to another host backend through the module-owned transfer API. - impl_
glwe_ trace_ defaults_ full - Implements [
GLWETraceDefault] forModule<$be>by forwarding every method to the corresponding [glwe_trace_defaults] free function. - impl_
lwe_ keyswitch_ defaults_ full - Implements [
LWEKeyswitchDefault] forModule<$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
Distributionassociated with a secret key. - GetDistribution
Mut - Mutable access to the
Distributionassociated with a secret key. - Scratch
Arena Take Core - Backend-native arena allocation for core ciphertext/key layouts.