1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//! 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 |
pub use *;
pub use *;
pub use var_noise_gglwe_product_v2;
pub use *;
pub use *;
pub use *;
pub
pub
pub
pub