Documentation

CompPoly.Fields.KoalaBear.Basic

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

This is the field used for lean Ethereum spec.

@[reducible]

The KoalaBear field modulus, 2^31 - 2^24 + 1.

Instances For
    @[reducible, inline]

    The KoalaBear prime field as a ZMod.

    Instances For

      The KoalaBear modulus is prime.

      Constants #

      These are convenience constants to match the Python module:

      @[reducible]

      Bit width of the KoalaBear modulus.

      Instances For
        @[reducible]

        The largest supported power-of-two root-of-unity exponent for KoalaBear.

        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.

          The factorization fieldSize - 1 = 2^twoAdicity * 127.

          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.

          Precomputed generators for the KoalaBear two-adic subgroups.

          Instances For

            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.

            Primitive generator used by the smooth field-root splitter.

            Instances For

              The smooth field-root splitter generator has full multiplicative order.

              Smooth subgroup refinement schedule for fieldSize - 1 = 2^24 * 127.

              Instances For

                The KoalaBear smooth schedule refines the multiplicative group down to singleton cosets.