Bounded coefficient vector used as a finite-index code for reduced packed polynomials.
Equations
- Hex.GF2Poly.reducedCoeffVector bound p i = p.coeff ↑i
Instances For
Two reduced packed polynomials below the same bound are equal when their bounded coefficient vectors agree.
The internal Boolean coefficient enumeration has exactly the two field coefficients.
Every Boolean coefficient appears in the internal coefficient enumeration.
The internal Boolean coefficient enumeration contains no duplicates, so coefficient-list enumeration does not duplicate choices at one position.
Internal enumeration of all Boolean coefficient lists of length d,
ordered lexicographically by the head coefficient.
Equations
Instances For
Base case of the coefficient-list enumeration: the only length-0 Boolean
list is the empty list.
Recursion equation for the coefficient-list enumeration: every length-d+1
list is obtained by prepending each Boolean head value to a length-d list.
Every list produced by coeffBoolLists d has length exactly d.
Membership in coeffBoolLists d is exactly having length d.
The Boolean coefficient-list enumeration has exactly 2 ^ d entries.
The fixed-length Boolean coefficient-list enumeration has no duplicates.
Internal builder for the finite-enumeration proof: interpret bs[i] as
the coefficient of x^(start + i) in a packed GF2Poly.
Equations
- Hex.GF2Poly.Internal.ofBoolListFrom start [] = 0
- Hex.GF2Poly.Internal.ofBoolListFrom start (b :: bs) = (if b = true then Hex.GF2Poly.monomial start else 0) + Hex.GF2Poly.Internal.ofBoolListFrom (start + 1) bs
Instances For
Internal builder for the finite-enumeration proof: interpret bs[i] as
the coefficient of x^i in a packed GF2Poly.
Equations
Instances For
The packed polynomial built from a coefficient list shifted by start reads
back the matching list entry, defaulting to false past the end.
Coefficient correctness for ofBoolList: indices below the length read the
matching list entry, indices at or above the length read false.
The packed polynomial built from a length-d Boolean coefficient list is
either zero or has degree strictly below d.
GF(2^n) for arbitrary n, represented by reduced GF2Poly residues
modulo an irreducible polynomial.
- val : GF2Poly
The canonical residue representing this field element, reduced modulo
f. The representative is reduced modulo
f: it is either zero or of degree below the modulus, so each field element has exactly one packed spelling. Zero is called out separately because the packed degree of the zero polynomial is0, not-∞.
Instances For
GF(2^n) packed into one machine word. The modulus stores only the lower
n coefficients; the leading x^n term is implicit in
GF2Poly.ofUInt64Monic irr n.
- val : UInt64
The packed canonical representative: the lower
ncoefficients of the residue modulo the implicit modulusx^n + irr. The representative is reduced: only the lower
nbits are set, so each field element has exactly one packed spelling and equality of elements is equality of words.
Instances For
The packed irreducible modulus polynomial defining this extension field.
Equations
Instances For
The low-word mask selecting canonical representatives of degree < n.
Equations
Instances For
Convert a machine word into its packed polynomial representative.
Equations
Instances For
Convert a UInt64 × UInt64 carry-less product into a packed polynomial.
Equations
- Hex.GF2n.toPolyWide hi lo = Hex.GF2Poly.ofWords #[lo, hi]
Instances For
Reduce a packed polynomial modulo the fixed irreducible and read back the single-word representative.
Equations
- Hex.GF2n.reducePoly p = Hex.GF2Poly.packedReduceWord n irr p
Instances For
Repackage a word as a canonical representative below 2^n.
Equations
- Hex.GF2n.canonicalWord w = Hex.GF2Poly.canonicalWordLT n hn64 w
Instances For
Canonical words are bounded by the extension degree.
Canonical constructor from a raw word by reduction modulo the field modulus.
Equations
- Hex.GF2n.reduce w = { val := Hex.GF2n.canonicalWord (Hex.GF2n.reducePoly (Hex.GF2n.toPolyWord w)), val_lt := ⋯ }
Instances For
Canonical constructor from a packed 128-bit carry-less product.
Equations
- Hex.GF2n.reduceWide hi lo = { val := Hex.GF2n.canonicalWord (Hex.GF2n.reducePoly (Hex.GF2n.toPolyWide hi lo)), val_lt := ⋯ }
Instances For
Natural-number literals in characteristic two reduce to their parity.
Equations
- Hex.GF2n.natCast k = if k % 2 = 0 then { val := 0, val_lt := ⋯ } else Hex.GF2n.reduce 1
Instances For
Canonical additive identity.
Equations
- Hex.GF2n.zero = { val := 0, val_lt := ⋯ }
Instances For
Equations
- Hex.GF2n.instZero = { zero := Hex.GF2n.zero }
Canonical multiplicative identity.
Equations
Instances For
Equations
- Hex.GF2n.instOne = { one := Hex.GF2n.one }
Equations
- Hex.GF2n.instNatCast = { natCast := Hex.GF2n.natCast }
Equations
- Hex.GF2n.instOfNat k = { ofNat := Hex.GF2n.natCast k }
Addition in characteristic two is word-wise XOR followed by canonical reduction.
Instances For
Equations
- Hex.GF2n.instAdd = { add := Hex.GF2n.add }
Negation is the identity in characteristic two.
Instances For
Equations
- Hex.GF2n.instNeg = { neg := Hex.GF2n.neg }
Subtraction coincides with addition in characteristic two.
Instances For
Equations
- Hex.GF2n.instSub = { sub := Hex.GF2n.sub }
Natural scalar multiplication in characteristic two depends only on the parity of the scalar.
Instances For
Equations
- Hex.GF2n.instSMulNat = { smul := Hex.GF2n.nsmul }
Multiplication uses the carry-less word primitive followed by reduction modulo the packed irreducible.
Instances For
Equations
- Hex.GF2n.instMul = { mul := Hex.GF2n.mul }
Natural power in GF(2^n) by repeated squaring.
Equations
- a.pow k = Hex.GF2n.pow.go 1 a k
Instances For
Square-and-multiply accumulator loop for GF2n.pow: go acc base k
computes acc * base ^ k.
Equations
Instances For
Equations
- Hex.GF2n.instPowNat = { pow := Hex.GF2n.pow }
Integer literals also reduce to parity because -1 = 1 in characteristic
two.
Equations
Instances For
Equations
- Hex.GF2n.instIntCast = { intCast := Hex.GF2n.intCast }
Integer scalar multiplication depends only on parity as well.
Instances For
Equations
- Hex.GF2n.instSMulInt = { smul := Hex.GF2n.zsmul }
The extended Euclidean witness supplies an inverse candidate modulo the packed irreducible.
Equations
- Hex.GF2n.invWord w = Hex.GF2Poly.packedInvWord n irr w
Instances For
Inversion follows the packed extended-GCD path and uses the usual junk
value 0⁻¹ = 0.
Equations
Instances For
Equations
- Hex.GF2n.instInv = { inv := Hex.GF2n.inv }
Division is multiplication by the inverse candidate.
Instances For
Equations
- Hex.GF2n.instDiv = { div := Hex.GF2n.div }
Integer exponentiation uses inversion for negative exponents.
Instances For
Equations
- Hex.GF2n.instHPowInt = { hPow := Hex.GF2n.zpow }
Division in GF2n unfolds to multiplication by the multiplicative inverse.
The inverse of 0 in GF2n is 0 (the field convention that makes
inversion total).
Every nonzero element of GF2n cancels against its inverse, witnessing that
GF2n is a field.