diff options
author | lloyd <[email protected]> | 2008-09-07 16:42:23 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-09-07 16:42:23 +0000 |
commit | b357bc7ab072cfac8c9a77a1f30406aa9883f5e0 (patch) | |
tree | 63fc64b3dea7ce8c271bbfa88747699dda8e8d03 /src/mp_monty.cpp | |
parent | 8713c3cee77a9a1802e41038fc4bfced89260a64 (diff) |
Inline bigint_sub2 into bigint_monty_redc
Diffstat (limited to 'src/mp_monty.cpp')
-rw-r--r-- | src/mp_monty.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/mp_monty.cpp b/src/mp_monty.cpp index 57c29137f..bafa679c9 100644 --- a/src/mp_monty.cpp +++ b/src/mp_monty.cpp @@ -151,9 +151,12 @@ s32bit bigint_cmp(const word x[], u32bit x_size, */ + word carry = 0; + const u32bit blocks = x_size - (x_size % 8); + if(z[x_size + x_size]) { - assert(bigint_cmp(z + x_size, x_size + 1, x, x_size) > 0); + //assert((bigint_cmp(z + x_size, x_size + 1, x, x_size) > 0); goto do_sub; } @@ -161,21 +164,33 @@ s32bit bigint_cmp(const word x[], u32bit x_size, { if(z[x_size + j - 1] > x[j-1]) { - assert(bigint_cmp(z + x_size, x_size + 1, x, x_size) > 0); + //assert((bigint_cmp(z + x_size, x_size + 1, x, x_size) > 0); goto do_sub; } if(z[x_size + j - 1] < x[j-1]) { - assert(bigint_cmp(z + x_size, x_size + 1, x, x_size) < 0); + //assert((bigint_cmp(z + x_size, x_size + 1, x, x_size) < 0); goto done; } } - assert(bigint_cmp(z + x_size, x_size + 1, x, x_size) == 0); + // default to subtraction (equal) + + //assert(m(bigint_cmp(z + x_size, x_size + 1, x, x_size) == 0); do_sub: - bigint_sub2(z + x_size, x_size + 1, x, x_size); + + //bigint_sub2(z + x_size, x_size + 1, x, x_size); + + for(u32bit j = 0; j != blocks; j += 8) + carry = word8_sub2(z + x_size + j, x + j, carry); + + for(u32bit j = blocks; j != x_size; ++j) + z[x_size + j] = word_sub(z[x_size + j], x[j], &carry); + + if(carry) + --z[x_size+x_size]; done: return; |