Definitions for GF(2) circular convolution via NTT #
The transform below uses the standard toolkit for number-theoretic transforms: a
2³⁰-smooth prime modulus, Montgomery arithmetic for modular multiplication, and a
radix-4 decimation. See [Har14] for a general treatment of fast NTT arithmetic.
Montgomery negated inverse p' = -p⁻¹ mod 2³² (= 3221225471), used by montMul.
Equations
- montPprime = 3221225471
Instances For
base ^ exp mod mod_, computed by square-and-multiply via powModAuxU64.
Equations
- powModU64 base exp mod_ = powModAuxU64 mod_ 64 (base % mod_) exp 1
Instances For
roots[2^k + j] = w_{2^(k+1)}^j · R mod mod64 (Montgomery domain)
Equations
- ensureRoots n = if hn0 : n = 0 then #v[] else ensureRoots.outer n (Vector.replicate n 0) 2 ⋯ 64
Instances For
Equations
- One or more equations did not get rendered due to their size.
- radix2Pass 0 x✝¹ x✝ = x✝
Instances For
── Radix-4 butterfly ──────────────────────────────────────────────────────── #
Two-stage DIF decomposition. Stage 1 applies the same twiddle t1 to both
aB (at offset s) and aD (at offset len + s) — this is intentional:
in this grouping both elements occupy the "odd" slot of their respective
half-group and share the same first-stage twiddle. t2 and t3 are the
distinct second-stage twiddles applied after the first-stage ±-combine.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- radix4Inner inverse roots s len i2 0 x✝¹ x✝ = x✝
- radix4Inner inverse roots s len i2 k.succ x✝¹ x✝ = radix4Inner inverse roots s len i2 k (x✝¹ + 1) (butterfly4 x✝ inverse roots s len i2 x✝¹)
Instances For
Equations
- radix4Middle inverse roots s len 0 x✝¹ x✝ = x✝
- radix4Middle inverse roots s len k.succ x✝¹ x✝ = radix4Middle inverse roots s len k (x✝¹ + 1) (radix4Inner inverse roots s len (x✝¹ * 2 * len) s 0 x✝)
Instances For
Equations
- nttInplace.go 0 a✝¹ a✝ = a✝
- nttInplace.go f.succ a✝¹ a✝ = if a✝¹ ≤ 1 then a✝ else nttInplace.go f (a✝¹ >>> 1) (a✝ + 1)
Instances For
GF(2) circular convolution: (a * b)[i] = ⊕ₖ (a[k] ∧ b[(i−k) mod n]).
Equivalently, multiplication in GF(2)[X] / (Xⁿ − 1).
Computed via radix-4 NTT with Montgomery arithmetic.
Uses 2n-point NTT to avoid aliasing; folds result[i] + result[i+n] to recover
the circular (period-n) convolution from the linear product.
This is only correct for n < 2 ^ 29 ≈ 2.6e8.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Specification of circular convolution on bit vectors.
Note that for Bool, summing is xor, while multiplication is and.