diff options
author | lloyd <[email protected]> | 2010-02-25 01:40:02 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-02-25 01:40:02 +0000 |
commit | aab1529d89961521e9cb6f2d65de98729107891a (patch) | |
tree | 83ba632f2d91331cc9ea932fe6c48d16d316fbf5 /src | |
parent | 4457657ac6048b5e0766dcc38d902d8fe99f2827 (diff) |
Remove clutter. Add note about bug in mult by scalar (mult by -1 is wrong)
Diffstat (limited to 'src')
-rw-r--r-- | src/math/gfpmath/point_gfp.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/math/gfpmath/point_gfp.cpp b/src/math/gfpmath/point_gfp.cpp index 9947ea41b..e32cd14d8 100644 --- a/src/math/gfpmath/point_gfp.cpp +++ b/src/math/gfpmath/point_gfp.cpp @@ -128,43 +128,40 @@ PointGFp& PointGFp::operator+=(const PointGFp& rhs) mZ = z; return *this; - } + PointGFp& PointGFp::operator-=(const PointGFp& rhs) { PointGFp minus_rhs = PointGFp(rhs).negate(); if(is_zero()) - { *this = minus_rhs; - } else - { *this += minus_rhs; - } + return *this; } PointGFp& PointGFp::operator*=(const BigInt& scalar) { - // use montgomery mult. in this operation - PointGFp H(this->mC); // create as zero PointGFp P(*this); BigInt m(scalar); if(m < BigInt(0)) { - m = -m; + m.flip_sign(); P.negate(); } + // Move upwards if(P.is_zero() || (m == BigInt(0))) { *this = H; return *this; } + // FIXME: *this != P if m was -1 ! if(m == BigInt(1)) //*this == P already return *this; |