diff options
author | lloyd <[email protected]> | 2009-11-18 01:44:04 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-11-18 01:44:04 +0000 |
commit | 866a1be9b5a0136c600c463a140bd0aaa69173ff (patch) | |
tree | ff8c5ece4c8388dda4a29a8491819e063427c21c /src/math | |
parent | 061733a4f765a4a40ae12108bc8e61a9bcf3a4d8 (diff) |
Remove accidentally checked in change to powm_fw.cpp
Diffstat (limited to 'src/math')
-rw-r--r-- | src/math/numbertheory/powm_fw.cpp | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/src/math/numbertheory/powm_fw.cpp b/src/math/numbertheory/powm_fw.cpp index e4272f20d..b764ee7aa 100644 --- a/src/math/numbertheory/powm_fw.cpp +++ b/src/math/numbertheory/powm_fw.cpp @@ -77,40 +77,17 @@ BigInt Fixed_Window_Exponentiator::execute() const { const u32bit exp_nibbles = (exp.bits() + window_bits - 1) / window_bits; - if(exp_nibbles == 0) - return 1; - - BigInt x1 = 1; - - for(u32bit j = 0; j != exp_nibbles / 2; ++j) - { - for(u32bit k = 0; k != window_bits; ++k) - x1 = reducer.square(x1); - - u32bit nibble = exp.get_substring(window_bits*(exp_nibbles-1-j), - window_bits); - - if(nibble) - x1 = reducer.multiply(x1, g[nibble-1]); - } - - for(u32bit k = 0; k != window_bits; ++k) - x1 = reducer.square(x1); - BigInt x2 = 1; - - for(u32bit j = exp_nibbles / 2; j != exp_nibbles; ++j) + BigInt x = 1; + for(u32bit j = exp_nibbles; j > 0; --j) { for(u32bit k = 0; k != window_bits; ++k) - x2 = reducer.square(x2); - - u32bit nibble = exp.get_substring(window_bits*(exp_nibbles-1-j), - window_bits); + x = reducer.square(x); + u32bit nibble = exp.get_substring(window_bits*(j-1), window_bits); if(nibble) - x2 = reducer.multiply(x2, g[nibble-1]); + x = reducer.multiply(x, g[nibble-1]); } - - return reducer.multiply(x1, x2); + return x; } /* |