aboutsummaryrefslogtreecommitdiffstats
path: root/src/zpow.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/zpow.c')
-rw-r--r--src/zpow.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/zpow.c b/src/zpow.c
index 16988f7..c064f60 100644
--- a/src/zpow.c
+++ b/src/zpow.c
@@ -37,7 +37,7 @@ zpow(z_t a, z_t b, z_t c)
zset(tc, c);
zsetu(a, 1);
- for (i = 0; i < n; i++) {
+ for (i = 0; i < n; i++) { /* Remember, n is floored. */
x = tc->chars[i];
for (j = BITS_PER_CHAR; j--; x >>= 1) {
if (x & 1)
@@ -45,4 +45,10 @@ zpow(z_t a, z_t b, z_t c)
zsqr(tb, tb);
}
}
+ x = tc->chars[i];
+ for (; x; x >>= 1) {
+ if (x & 1)
+ zmul(a, a, tb);
+ zsqr(tb, tb);
+ }
}