X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/34e4f738bcba58e6d8c4cabbb0b3232a65b42a9d..92c494cebdce7068e6c9c0fe4363467719c8ed67:/mpmont-mexp.c diff --git a/mpmont-mexp.c b/mpmont-mexp.c index 7589990..884d660 100644 --- a/mpmont-mexp.c +++ b/mpmont-mexp.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: mpmont-mexp.c,v 1.8 2004/04/01 12:50:09 mdw Exp $ + * $Id: mpmont-mexp.c,v 1.9 2004/04/08 01:36:15 mdw Exp $ * * Multiple simultaneous exponentiations * @@ -27,42 +27,6 @@ * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: mpmont-mexp.c,v $ - * Revision 1.8 2004/04/01 12:50:09 mdw - * Add cyclic group abstraction, with test code. Separate off exponentation - * functions for better static linking. Fix a buttload of bugs on the way. - * Generally ensure that negative exponents do inversion correctly. Add - * table of standard prime-field subgroups. (Binary field subgroups are - * currently unimplemented but easy to add if anyone ever finds a good one.) - * - * Revision 1.7 2002/01/13 13:49:14 mdw - * Make @const@-correct. - * - * Revision 1.6 2001/06/16 13:00:20 mdw - * Use the generic exponentiation functions. - * - * Revision 1.5 2000/10/08 12:11:22 mdw - * Use @MP_EQ@ instead of @MP_CMP@. - * - * Revision 1.4 2000/06/17 11:45:09 mdw - * Major memory management overhaul. Added arena support. Use the secure - * arena for secret integers. Replace and improve the MP management macros - * (e.g., replace MP_MODIFY by MP_DEST). - * - * Revision 1.3 1999/12/10 23:18:39 mdw - * Change interface for suggested destinations. - * - * Revision 1.2 1999/11/21 11:35:10 mdw - * Performance improvement: use @mp_sqr@ and @mpmont_reduce@ instead of - * @mpmont_mul@ for squaring in exponentiation. - * - * Revision 1.1 1999/11/19 13:19:29 mdw - * Simultaneous exponentiation support. - * - */ - /*----- Header files ------------------------------------------------------*/ #include "mp.h" @@ -93,7 +57,6 @@ static mp *mexpr(mpmont *mm, mp *d, mp_expfactor *f, size_t n) { mp *a = MP_COPY(mm->r); mp *spare = MP_NEW; - mp *g = MP_NEW; size_t i; for (i = 0; i < n; i++) { @@ -102,12 +65,10 @@ static mp *mexpr(mpmont *mm, mp *d, mp_expfactor *f, size_t n) spare = MP_NEWSEC; if (f[i].exp->f & MP_NEG) { t = mpmont_reduce(mm, f[i].base, f[i].base); - mp_gcd(&g, 0, &t, mm->m, t); - assert(MP_EQ(g, MP_ONE)); + t = mp_modinv(t, t, mm->m); f[i].base = mpmont_mul(mm, t, t, mm->r2); } } - mp_drop(g); EXP_SIMUL(a, f, n); mp_drop(d); mp_drop(spare);