X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/373641eaacc86b56715a2ebf0b603fce25c16051..bd4902364e73cb062407b972ef7fecef3998d46a:/math/strongprime.c diff --git a/math/strongprime.c b/math/strongprime.c index 9eab8b20..5b136534 100644 --- a/math/strongprime.c +++ b/math/strongprime.c @@ -140,17 +140,10 @@ mp *strongprime_setup(const char *name, mp *d, pfilt *f, unsigned nbits, * This computes %$p_0 = 2 s (s^{r - 2} \bmod r) - 1$%. */ - { - mpmont mm; - - mpmont_create(&mm, q); - rr = mp_sub(rr, q, MP_TWO); - rr = mpmont_exp(&mm, rr, s, rr); - mpmont_destroy(&mm); - rr = mp_mul(rr, rr, s); - rr = mp_lsl(rr, rr, 1); - rr = mp_sub(rr, rr, MP_ONE); - } + rr = mp_modinv(rr, s, q); + rr = mp_mul(rr, rr, s); + rr = mp_lsl(rr, rr, 1); + rr = mp_sub(rr, rr, MP_ONE); /* --- Pick a starting point for the search --- * *