Fast KoalaBear Field Operations #
This module provides a native-word implementation of KoalaBear arithmetic as a sidecar
to the canonical KoalaBear.Field := ZMod KoalaBear.fieldSize model.
Fast field values are stored as Montgomery UInt32 residues below KoalaBear.fieldSize,
representing x * 2^32 modulo the KoalaBear prime. Addition, subtraction, and
negation operate directly on Montgomery words; multiplication uses Montgomery
reduction on a native UInt64 product.
KoalaBear modulus as a 64-bit word for modular reduction.
Instances For
2^32 mod KoalaBear.fieldSize. This is the Montgomery representation of one.
Instances For
(2^32)^2 mod KoalaBear.fieldSize, used to enter Montgomery representation.
Instances For
-KoalaBear.fieldSize⁻¹ mod 2^32, used by Montgomery reduction.
Instances For
The fast native-word KoalaBear field carrier, stored as a Montgomery residue.
Instances For
The raw Montgomery word backing a fast KoalaBear element.
Instances For
Montgomery reduction of a 64-bit word. Hot bounded callers use montgomeryReduceBounded.
Instances For
Reduce a UInt64 modulo the KoalaBear prime and return a Montgomery fast element.
Instances For
Convert a natural number into fast Montgomery representation.
Instances For
Convert a 32-bit word into fast Montgomery representation.
Instances For
Convert an integer into fast Montgomery representation.
Instances For
Convert a fast element to its canonical native-word representative.
Instances For
Convert a fast KoalaBear element to its canonical natural representative.
Instances For
Converting a canonical natural representative to fast form preserves its value.
ofCanonicalNat embeds a canonical representative into the canonical field.
Reducing a UInt64 gives the canonical natural residue modulo KoalaBear.
Reducing a UInt64 agrees with casting that word into the canonical field.
Fast modular addition in Montgomery form.
Instances For
Fast modular negation in Montgomery form.
Instances For
Fast modular subtraction in Montgomery form.
Instances For
Fast modular multiplication in Montgomery form.
Instances For
Exponentiation over the fast representation using repeated squaring.
Instances For
Fermat exponent used for inversion in the KoalaBear prime field.
Instances For
Inversion in Montgomery form by a fixed 4-bit Fermat chain.
Instances For
Division through inversion and fast multiplication.
Instances For
Converting from the canonical field to fast form and back is the identity.
The canonical-field interpretation distinguishes fast KoalaBear values.
toField maps fast zero to canonical zero.
toField maps fast one to canonical one.
Ring equivalence between the fast Montgomery representation and canonical KoalaBear.Field.
Instances For
Applying the inverse ringEquiv is conversion into fast Montgomery form.
Natural casts into fast form agree with natural casts into the canonical field.
Integer casts into fast form agree with integer casts into the canonical field.
Nonnegative rational casts into fast form agree with canonical-field casts.
Rational casts into fast form agree with canonical-field casts.
Field instance transferred from canonical KoalaBear through toField.
Commutative-ring instance inherited from the transferred field structure.
Fast KoalaBear is a non-binary field.