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
//! RLWE (Ring Learning With Errors) encryption module
//!
//! This module implements RLWE encryption over the ring R_q = Z_q\[X\]/(X^d + 1).
//!
//! # Overview
//!
//! RLWE is a lattice-based cryptosystem where:
//! - Secret key s is a polynomial sampled from error distribution
//! - Ciphertext (a, b) encrypts message m as b = -a·s + e + Δ·m
//! - Δ = ⌊q/p⌋ is the scaling factor
//!
//! # Galois Automorphisms
//!
//! Automorphisms τ_g: R → R defined by τ_g(X) = X^g are used for:
//! - Rotating coefficients within ciphertexts
//! - The InsPIRe packing algorithm (LWE → RLWE)
//!
//! # Example
//!
//! ```ignore
//! use inspire::rlwe::{RlweSecretKey, RlweCiphertext};
//! use inspire::params::InspireParams;
//! use inspire::math::{Poly, GaussianSampler};
//!
//! let params = InspireParams::default();
//! let mut sampler = GaussianSampler::new(params.sigma);
//!
//! // Generate key
//! let sk = RlweSecretKey::generate(¶ms, &mut sampler);
//!
//! // Encrypt message
//! let message = Poly::zero(params.ring_dim, params.q);
//! let a = Poly::random(params.ring_dim, params.q);
//! let error = Poly::sample_gaussian(params.ring_dim, params.q, &mut sampler);
//! let ct = RlweCiphertext::encrypt(&sk, &message, params.delta(), a, &error);
//!
//! // Decrypt
//! let decrypted = ct.decrypt(&sk, params.delta(), params.p);
//! ```
pub use ;
pub use ;