Documentation

CompPoly.Fields.KoalaBear

KoalaBear Field 2^{31} - 2^{24} + 1 #

This is the field used for lean Ethereum spec.

@[reducible]
Equations
    Instances For
      @[reducible, inline]
      Equations
        Instances For

          Constants #

          These are convenience constants to match the Python module:

          @[reducible]
          Equations
            Instances For
              @[reducible]
              Equations
                Instances For

                  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.

                  Equations
                    Instances For

                      Statements requested by the Python spec translation. We leave them with sorry proofs to be filled later.

                      theorem KoalaBear.inv_eq_pow (a : Field) (ha : a 0) :

                      Fermat-style inversion in ZMod fieldSize.

                      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.

                      theorem KoalaBear.twoAdicGenerators_pow_twoPow_ne_one_of_lt {bits : Fin (twoAdicity + 1)} {m : } (hm : m < bits) :

                      If m < bits, then (twoAdicGenerators[bits])^(2^m) ≠ 1.

                      The order of twoAdicGenerators[bits] equals 2^bits.