Nat-level quotient in Shoup multiplication.
Equations
- Hex.ZMod64.Ntt.shoupQuot w t p = w * UInt64.word / p * t / UInt64.word
Instances For
Redundant Shoup product w*t - floor(floor(w*β/p)*t/β)*p.
Equations
- Hex.ZMod64.Ntt.shoupValue w t p = w * t - Hex.ZMod64.Ntt.shoupQuot w t p * p
Instances For
Shoup multiplication without its final adjustment returns a representative
below 2p when the multiplicand is below 4p.
The redundant Shoup product represents the ordinary product modulo p.
The small-modulus class leaves enough word room for a fourfold redundant representative.
Twice the modulus as a faithful machine word.
Equations
- Hex.ZMod64.Ntt.twiceModulusWord p = UInt64.ofNatLT (2 * p) ⋯
Instances For
Observation of the doubled modulus word.
Reduce a faithful representative below 4p into [0, 2p) by at most
one word subtraction.
Equations
- Hex.ZMod64.Ntt.reduceTwice p value = if Hex.ZMod64.Ntt.twiceModulusWord p ≤ value then value - Hex.ZMod64.Ntt.twiceModulusWord p else value
Instances For
Reduce a faithful representative below 4p into a bounded raw word.
Equations
- Hex.ZMod64.Ntt.reduceTwiceRaw2 value hvalue = { val := Hex.ZMod64.Ntt.reduceTwice p value, isLt := ⋯ }
Instances For
Add 2p and subtract a smaller raw representative without word wrap or
borrow.
Equations
- Hex.ZMod64.Ntt.addTwiceSubWord p left right = left + Hex.ZMod64.Ntt.twiceModulusWord p - right
Instances For
Logical Shoup multiplication, returning the unadjusted representative in
[0, 2p).
Equations
- Hex.ZMod64.Ntt.shoupMul twiddle value = { val := UInt64.ofNatLT (Hex.ZMod64.Ntt.shoupValue twiddle.value.toNat value.val.toNat p) ⋯, isLt := ⋯ }
Instances For
Nat observation of logical Shoup multiplication.
Word implementation of Shoup multiplication, using the existing verified high-word primitive.
Equations
Instances For
The word implementation agrees with the Nat-level Shoup formula.
Compiled Shoup multiplication.
Equations
- Hex.ZMod64.Ntt.shoupMulImpl twiddle value = { val := Hex.ZMod64.Ntt.shoupWord twiddle value, isLt := ⋯ }
Instances For
Nat observation of compiled Shoup multiplication.
Kernel-reducible and word-level Shoup multiplication agree.
Equations
- Hex.ZMod64.Ntt.raw2OfNat value h = { val := UInt64.ofNatLT value ⋯, isLt := ⋯ }
Instances For
Equations
- Hex.ZMod64.Ntt.raw4OfNat value h = { val := UInt64.ofNatLT value ⋯, isLt := ⋯ }
Instances For
Harvey's forward butterfly. Inputs and outputs remain in [0, 2p);
the second output uses an unadjusted Shoup product.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Division-free word implementation of the forward butterfly.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Raw observation of the logical forward twiddled difference.
Raw observation of the compiled forward twiddled difference.
The forward butterfly's kernel-reducible and division-free word implementations agree.
The first forward output is the sum residue.
The second forward output is the twiddled difference residue.
Harvey's inverse butterfly. Inputs and outputs remain in [0, 4p);
only the left input is reduced to [0, 2p) before the add/subtract pair.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Division-free word implementation of the inverse butterfly.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Raw observation of the logical inverse difference.
Raw observation of the compiled inverse difference.
The inverse butterfly's kernel-reducible and division-free word implementations agree.
The first inverse output is the sum with the twiddled right input.
The second inverse output is the corresponding difference.