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
//! LWE (Learning With Errors) encryption module.
//!
//! This module implements LWE encryption for the InsPIRe PIR protocol.
//! LWE is the foundation for extracting scalar ciphertexts from RLWE
//! ring ciphertexts during the PIR response phase.
//!
//! # Overview
//!
//! LWE encryption works over vectors in Z_q^d rather than polynomial rings.
//! A ciphertext (a, b) encrypts message m as:
//!
//! ```text
//! b = -<a, s> + e + Δ·m
//! ```
//!
//! where s is the secret key, e is a small error, and Δ = ⌊q/p⌋ is the
//! scaling factor for plaintext space Z_p.
//!
//! # Key Types
//!
//! - [`LweSecretKey`]: Secret key vector sampled from error distribution
//! - [`LweCiphertext`]: Ciphertext pair (a, b) supporting homomorphic operations
//!
//! # CRS Model
//!
//! In the Common Reference String model, the random vector `a` is fixed
//! and publicly known. This enables query compression where clients only
//! send the `b` component of each ciphertext.
//!
//! # Example
//!
//! ```
//! use inspire::lwe::{LweSecretKey, LweCiphertext};
//! use inspire::math::GaussianSampler;
//! use inspire::math::mod_q::DEFAULT_Q;
//!
//! let mut sampler = GaussianSampler::new(3.2);
//! let sk = LweSecretKey::generate(256, DEFAULT_Q, &mut sampler);
//! ```
pub use ;