Is the exponentiation on a modulo field conmutative/distributive?

49 Views Asked by At

I'm trying to wrap my head around exponentiation on a modulo field (specifically the modulo field defined by the Secp256k1 Weirstrass curve).

I'm currently implementing a bignum library on a lesser known language where no other implementation exists (GDScript, looks like python but isn't remotely as capable for big numbers as it).

I basically need to calculate exponentiation like this:

$$Y = X^P \mod F$$

Where F is the field modulo.

And need to do several optimizations (i.e. can't calculate P times X by X, as P is a bignum itself and could take hours for just 1 operation) that are based around conmutative and distributive properties of multiplication to reduce algorithm complexity and make it run on a fast enough timeframe.