5 # based on Algorithm ExtEucdInv from:
6 # https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.90.5233&rep=rep1&type=pdf
8 assert p
>= 2, "GFPRIME isn't a prime"
9 assert a
!= 0, "TODO: decide what happens for division by zero"
10 assert isinstance(a
, int) and 0 < a
< p
, "a out of range"
12 return 1 # the only value possible
19 # implementations could use count-zeros on
20 # both u and r to save cycles
27 # implementations could use count-zeros on
28 # both v and s to save cycles