-/* --- @mpmont_expr@ --- *
- *
- * Arguments: @mpmont *mm@ = pointer to Montgomery reduction context
- * @mp *d@ = fake destination
- * @mp *a@ = base
- * @mp *e@ = exponent
- *
- * Returns: Result, %$a^e R \bmod m$%.
- */
-
-mp *mpmont_expr(mpmont *mm, mp *d, mp *a, mp *e)
-{
- mpscan sc;
- mp *ar = mpmont_mul(mm, MP_NEW, a, mm->r2);
- mp *x = MP_COPY(mm->r);
- mp *spare = (e->f & MP_BURN) ? MP_NEWSEC : MP_NEW;
-
- mp_scan(&sc, e);
-
- if (MP_STEP(&sc)) {
- size_t sq = 0;
- for (;;) {
- mp *dd;
- if (MP_BIT(&sc)) {
- while (sq) {
- dd = mp_sqr(spare, ar);
- dd = mpmont_reduce(mm, dd, dd);
- spare = ar; ar = dd;
- sq--;
- }
- dd = mpmont_mul(mm, spare, x, ar);
- spare = x; x = dd;
- }
- sq++;
- if (!MP_STEP(&sc))
- break;
- }
- }
- MP_DROP(ar);
- if (spare != MP_NEW)
- MP_DROP(spare);
- if (d != MP_NEW)
- MP_DROP(d);
- return (x);
-}
-
-/* --- @mpmont_exp@ --- *
- *
- * Arguments: @mpmont *mm@ = pointer to Montgomery reduction context
- * @mp *d@ = fake destination
- * @mp *a@ = base
- * @mp *e@ = exponent
- *
- * Returns: Result, %$a^e \bmod m$%.
- */
-
-mp *mpmont_exp(mpmont *mm, mp *d, mp *a, mp *e)
-{
- d = mpmont_expr(mm, d, a, e);
- d = mpmont_reduce(mm, d, d);
- return (d);
-}
-