diff options
author | lloyd <[email protected]> | 2010-02-23 18:20:12 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-02-23 18:20:12 +0000 |
commit | d3ba30e826ad8d541b0e859d79c90db755f04eb0 (patch) | |
tree | 26d8b538814d4a0e5afffae23f4eb7947ead4676 /src | |
parent | cdc5e1aa4761da1a353aa71b9b35cb02bdf9800d (diff) |
Cleanups. Remove PointGFp::mult_loop
Diffstat (limited to 'src')
-rw-r--r-- | src/math/gfpmath/point_gfp.cpp | 45 | ||||
-rw-r--r-- | src/math/gfpmath/point_gfp.h | 2 |
2 files changed, 14 insertions, 33 deletions
diff --git a/src/math/gfpmath/point_gfp.cpp b/src/math/gfpmath/point_gfp.cpp index c57ceebba..abf4451a6 100644 --- a/src/math/gfpmath/point_gfp.cpp +++ b/src/math/gfpmath/point_gfp.cpp @@ -281,16 +281,18 @@ PointGFp& PointGFp::mult_this_secure(const BigInt& scalar, //assert(mul_bits != 0); - mult_loop(mul_bits-1, m, H, P); + for(int i = mul_bits - 1; i >= 0; i--) + { + H.mult2_in_place(); + + if(m.get_bit(i)) + H += P; + } if(!H.is_zero()) // cannot convert if H == O - { *this = H.get_z_to_one(); - } else - { *this = H; - } mX.turn_off_sp_red_mul(); mY.turn_off_sp_red_mul(); @@ -309,55 +311,36 @@ PointGFp& PointGFp::operator*=(const BigInt& scalar) PointGFp P(*this); P.turn_on_sp_red_mul(); BigInt m(scalar); + if(m < BigInt(0)) { m = -m; P.negate(); } + if(P.is_zero() || (m == BigInt(0))) { *this = H; return *this; } - if(m == BigInt(1)) - { - //*this == P already + + if(m == BigInt(1)) //*this == P already return *this; - } const int l = m.bits() - 1; - for(int i=l; i >=0; i--) + for(int i = l; i >= 0; --i) { - H.mult2_in_place(); if(m.get_bit(i)) - { H += P; - } } if(!H.is_zero()) // cannot convert if H == O - { *this = H.get_z_to_one(); - }else - { + else *this = H; - } - return *this; - } -void PointGFp::mult_loop(int l, - const BigInt& m, - PointGFp& H, - const PointGFp& P) - { - for(int i=l; i >=0; i--) - { - H.mult2_in_place(); - - if(m.get_bit(i)) - H += P; - } + return *this; } PointGFp& PointGFp::negate() diff --git a/src/math/gfpmath/point_gfp.h b/src/math/gfpmath/point_gfp.h index 1e47fa783..5f8231fcb 100644 --- a/src/math/gfpmath/point_gfp.h +++ b/src/math/gfpmath/point_gfp.h @@ -211,8 +211,6 @@ class BOTAN_DLL PointGFp static GFpElement decompress(bool yMod2, GFpElement const& x, const CurveGFp& curve); private: - void mult_loop(int l, const BigInt& m, PointGFp& H, const PointGFp& P); - CurveGFp mC; mutable GFpElement mX; // NOTE: these values must be mutable (affine<->proj) mutable GFpElement mY; |