pub struct PqNtt { /* private fields */ }Expand description
A ready-to-use NTT engine configured for a specific post-quantum scheme.
Wraps Ntt32Context with scheme metadata for safety and convenience.
§Example
use vaea_ntt::pq::{PqScheme, PqNtt};
let ntt = PqNtt::new(PqScheme::MlDsa65);
assert_eq!(ntt.scheme(), PqScheme::MlDsa65);
assert_eq!(ntt.n(), 256);
assert_eq!(ntt.q(), 8380417);
let mut data = vec![0u32; 256];
data[0] = 1;
ntt.forward(&mut data);
ntt.inverse(&mut data);
assert_eq!(data[0], 1);Implementations§
Source§impl PqNtt
impl PqNtt
Sourcepub fn new(scheme: PqScheme) -> Self
pub fn new(scheme: PqScheme) -> Self
Creates a new PQ-NTT engine for the given scheme.
This precomputes all twiddle factors and modular arithmetic constants. The context can be reused for multiple NTT calls.
Sourcepub fn security_level(&self) -> u8
pub fn security_level(&self) -> u8
Returns the NIST security level.
Sourcepub fn context(&self) -> &Ntt32Context
pub fn context(&self) -> &Ntt32Context
Returns a reference to the underlying Ntt32Context.
Sourcepub fn forward(&self, data: &mut [u32])
pub fn forward(&self, data: &mut [u32])
Applies forward NTT in-place.
Transforms from coefficient domain to evaluation (NTT) domain. In NTT domain, polynomial multiplication is pointwise O(N).
§Panics
If data.len() != self.n().
Sourcepub fn inverse(&self, data: &mut [u32])
pub fn inverse(&self, data: &mut [u32])
Applies inverse NTT in-place.
Transforms from evaluation (NTT) domain back to coefficient domain. Includes the N⁻¹ normalization factor.
§Panics
If data.len() != self.n().
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PqNtt
impl RefUnwindSafe for PqNtt
impl Send for PqNtt
impl Sync for PqNtt
impl Unpin for PqNtt
impl UnsafeUnpin for PqNtt
impl UnwindSafe for PqNtt
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