diff options
author | lloyd <[email protected]> | 2012-08-01 19:42:20 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-08-01 19:42:20 +0000 |
commit | cf445ea944734e3ace1c496c43971f1dfadb9e02 (patch) | |
tree | f7e8428666a29459b0afc7cb4183d76cfa569f0b /src/math/numbertheory/powm_mnt.cpp | |
parent | 7dbcedf896b78db3920368d7dabf2dbc2fa50e09 (diff) |
Move monty_invert to numthry.h and use it in CurveGFp as well
Diffstat (limited to 'src/math/numbertheory/powm_mnt.cpp')
-rw-r--r-- | src/math/numbertheory/powm_mnt.cpp | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/math/numbertheory/powm_mnt.cpp b/src/math/numbertheory/powm_mnt.cpp index 1928cef9d..53e75d2b1 100644 --- a/src/math/numbertheory/powm_mnt.cpp +++ b/src/math/numbertheory/powm_mnt.cpp @@ -11,56 +11,6 @@ namespace Botan { -namespace { - -/* -* Compute -input^-1 mod 2^MP_WORD_BITS. We are assured that the -* inverse exists because input is odd (checked by checking that the -* modulus is odd in the Montgomery_Exponentiator constructor, and -* input is the low word of the modulus and thus also odd), and thus -* input and 2^n are relatively prime. -*/ -word monty_inverse(word input) - { - word b = input; - word x2 = 1, x1 = 0, y2 = 0, y1 = 1; - - // First iteration, a = n+1 - word q = bigint_divop(1, 0, b); - word r = (MP_WORD_MAX - q*b) + 1; - word x = x2 - q*x1; - word y = y2 - q*y1; - - word a = b; - b = r; - x2 = x1; - x1 = x; - y2 = y1; - y1 = y; - - while(b > 0) - { - q = a / b; - r = a - q*b; - x = x2 - q*x1; - y = y2 - q*y1; - - a = b; - b = r; - x2 = x1; - x1 = x; - y2 = y1; - y1 = y; - } - - // Now invert in addition space - y2 = (MP_WORD_MAX - y2) + 1; - - return y2; - } - -} - /* * Set the exponent */ |