Skip to main content

NttModulus

Trait NttModulus 

Source
pub trait NttModulus: Modulus {
    const ZETA: u32;
    const ZETAS: &'static [u32];
    const N_INV: u32;
    const MONT_R: u32;
    const NEG_QINV: u32;
    const PSIS: &'static [u32];
    const INV_PSIS: &'static [u32];
    const POST_INVNTT_MODE: PostInvNtt = PostInvNtt::Standard;
}
Expand description

Extended trait for NTT-enabled moduli

Required Associated Constants§

Source

const ZETA: u32

Primitive root of unity (generator)

Source

const ZETAS: &'static [u32]

Precomputed twiddle factors for forward NTT CRITICAL: For Dilithium, these are stored in MONTGOMERY domain (ζ·R mod q) exactly as in the FIPS-204 reference implementation. Do NOT convert them again - that would give ζ·R² mod q!

Source

const N_INV: u32

N^-1 mod Q for final scaling in inverse NTT This should be in Montgomery form: (N^-1 * R) mod Q

Source

const MONT_R: u32

Montgomery parameter R = 2^32 mod Q

Source

const NEG_QINV: u32

-Q^-1 mod 2^32 for Montgomery reduction (sometimes called NEG_QINV or MONT_QINV)

Source

const PSIS: &'static [u32]

Twist factors ψ_i = ω^(bitrev(i)) in STANDARD domain (length N) These are the N-th roots of the primitive 2N-th root of unity Required for twisted/negacyclic NTT (Dilithium) NOTE: FIPS-204 reference implementation does NOT use these!

Source

const INV_PSIS: &'static [u32]

Inverse twist factors ψ_i^(-1) in STANDARD domain (length N) Required for inverse twisted/negacyclic NTT (Dilithium) NOTE: FIPS-204 reference implementation does NOT use these!

Provided Associated Constants§

Source

const POST_INVNTT_MODE: PostInvNtt = PostInvNtt::Standard

How the coefficients should be post-processed after the inverse NTT.

  • Standard → Kyber / Saber style
  • Montgomery → Dilithium style (invntt_tomont)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl NttModulus for DilithiumParams

Source§

const ZETA: u32 = 1753

Source§

const ZETAS: &'static [u32]

Source§

const N_INV: u32 = 16_382

Source§

const MONT_R: u32 = 4_193_792

Source§

const NEG_QINV: u32 = 4_236_238_847

Source§

const PSIS: &'static [u32]

Source§

const INV_PSIS: &'static [u32]

Source§

const POST_INVNTT_MODE: PostInvNtt = PostInvNtt::Standard

Source§

impl NttModulus for DilithiumParamsMont

Source§

const ZETA: u32 = 1753

Source§

const ZETAS: &'static [u32]

Source§

const N_INV: u32 = 16_382

Source§

const MONT_R: u32 = 4_193_792

Source§

const NEG_QINV: u32 = 4_236_238_847

Source§

const PSIS: &'static [u32]

Source§

const INV_PSIS: &'static [u32]

Source§

const POST_INVNTT_MODE: PostInvNtt = PostInvNtt::Montgomery

Source§

impl NttModulus for Kyber256Params

Source§

const ZETA: u32 = 17

Source§

const ZETAS: &'static [u32]

Source§

const N_INV: u32 = 2385

Source§

const MONT_R: u32 = 1353

Source§

const NEG_QINV: u32 = 0x94570CFF

Source§

const PSIS: &'static [u32]

Source§

const INV_PSIS: &'static [u32]

Source§

const POST_INVNTT_MODE: PostInvNtt = PostInvNtt::Standard