Documentation

CompPoly.Fields.KoalaBear

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

This is the field used for lean Ethereum spec.

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

      Constants #

      These are convenience constants to match the Python module:

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

          Provide instances so KoalaBear.Field = ZMod fieldSize is available as a Field and as a NonBinaryField (char ≠ 2).

          @[implicit_reducible]

          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.

          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.

          twoAdicity is maximal: 2^(twoAdicity+1) does not divide fieldSize - 1.

          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 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 order of twoAdicGenerators[bits] equals 2^bits.