Closed 0xbok closed 7 months ago
pow fn comment says it handles negative exponent but it doesn't. This PR fixes it. Here's the reasoning behind the fix:
pow
$$ a^{-e} = (a^{-1})^e \mod p $$
So pow(a, -e) == pow(inv(a), e)
pow(a, -e) == pow(inv(a), e)
note that the pow test uses 12 as the order. A field with a non-prime order may not have an inverse for every element in the set.
pow
fn comment says it handles negative exponent but it doesn't. This PR fixes it. Here's the reasoning behind the fix:$$ a^{-e} = (a^{-1})^e \mod p $$
So
pow(a, -e) == pow(inv(a), e)