Skip to main content

pow

Function pow 

Source
pub fn pow(base: u64, exp: u64) -> u64
Expand description

base ^ exp mod p via right-to-left binary square-and-multiply.

Used by inv for Fermat’s-little-theorem inversion. Naïve algorithm (~64 squares + popcount(exp) muls) — Plonky3 uses a faster addition chain for inversion specifically, but for a benchmark of “how each VM handles exponentiation hot loops” this is what we want: predictable branchy dependent multiplies, exactly what the unoptimized algorithm looks like.