pub struct RnsContext {
pub moduli: Vec<u64>,
pub ariths: Vec<Ntt64Arith>,
pub ntt_ctxs: Vec<Ntt64Context>,
pub poly_degree: usize,
}Expand description
RNS context: a set of coprime moduli.
Precomputes modular arithmetic and NTT contexts for each modulus, enabling efficient component-wise polynomial operations.
Fields§
§moduli: Vec<u64>The moduli q₁, q₂, …, q_L.
ariths: Vec<Ntt64Arith>Modular arithmetic contexts for each modulus (Barrett, Montgomery).
ntt_ctxs: Vec<Ntt64Context>NTT contexts for each modulus.
poly_degree: usizePolynomial degree N.
Implementations§
Source§impl RnsContext
impl RnsContext
Sourcepub fn new(poly_degree: usize, moduli: Vec<u64>) -> Self
pub fn new(poly_degree: usize, moduli: Vec<u64>) -> Self
Creates an RNS context with the given moduli.
Precomputes all modular arithmetic and NTT contexts. Each modulus must be NTT-friendly for the given polynomial degree.
§Panics
- If
poly_degreeis not a power of 2 - If
moduliis empty - If any modulus is not NTT-friendly for the given degree
Sourcepub fn num_moduli(&self) -> usize
pub fn num_moduli(&self) -> usize
Number of moduli (= total number of levels).
Auto Trait Implementations§
impl Freeze for RnsContext
impl RefUnwindSafe for RnsContext
impl Send for RnsContext
impl Sync for RnsContext
impl Unpin for RnsContext
impl UnsafeUnpin for RnsContext
impl UnwindSafe for RnsContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more