KoalaBear Field 2^{31} - 2^{24} + 1 #
This is the field used for lean Ethereum spec.
Constants #
These are convenience constants to match the Python module:
pBits = 31twoAdicity = 24withfieldSize - 1 = 2^24 * 127
Provide instances so KoalaBear.Field = ZMod fieldSize is available as a Field
and as a NonBinaryField (char ≠ 2).
Two-adicity and roots of unity table #
We record the factorization of fieldSize - 1 and provide a precomputed table
of 2^n-th roots of unity for 0 ≤ n ≤ twoAdicity.
A table of 2^n-th roots of unity. The element at index n generates the
multiplicative subgroup of order 2^n.
The first entry n = 0 is 1.
Statements requested by the Python spec translation. We leave them with sorry proofs
to be filled later.
Bijectivity of the cube map on the unit group, using gcd(3, fieldSize-1)=1.
The cube map x ↦ x^3 is an automorphism on the multiplicative group because
Nat.coprime 3 (fieldSize - 1) holds. We record the coprimality here.
Additional statements matching the Python spec API, left as sorry per request.
twoAdicity is maximal: 2^(twoAdicity+1) does not divide fieldSize - 1.
The precomputed element at index bits is a primitive 2^bits-th root of unity.
As a unit, the precomputed element is a member of rootsOfUnity (2^bits).
The power (twoAdicGenerators[bits])^(2^bits) = 1.
If m < bits, then (twoAdicGenerators[bits])^(2^m) ≠ 1.
The order of twoAdicGenerators[bits] equals 2^bits.