def gfm.pow.go

bend-osdev-gf@0.1.1.0 · gfm.bend:79

import bend-osdev-gf@0.1.1.0/gfm.bend as Gfm
import Base

79# a^e by squaring, over the 32 bits of e from the top
80def gfm.pow.go(n: Nat, +f: GfmField, +a: U32, +e: U32, +r: U32) -> U32:
81  match n:
82    case 0n:
83      r
84    case 1n+k:
85      +sq = Gfm.mul(f, r, r)
86      gfm.pow.go(k, f, a, U32.shl(e), Gfm.mul(f, sq, U32.or(U32.and(a, gfm.mask(U32.shrn(e, 31n))), U32.and(1, U32.not(gfm.mask(U32.shrn(e, 31n)))))))

Uses (10)

Used by (1)