diff options
author | lloyd <[email protected]> | 2010-02-25 02:01:06 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-02-25 02:01:06 +0000 |
commit | 2d1dd244a6714687c97736a809e9dd31f506306c (patch) | |
tree | 25d91133fd81ba0d1404bcec8c7984b4aac71f5b /src/math | |
parent | aab1529d89961521e9cb6f2d65de98729107891a (diff) |
Convert PointGFp::get_affine_{x,y} to return just the BigInt value
Diffstat (limited to 'src/math')
-rw-r--r-- | src/math/gfpmath/point_gfp.cpp | 28 | ||||
-rw-r--r-- | src/math/gfpmath/point_gfp.h | 4 |
2 files changed, 19 insertions, 13 deletions
diff --git a/src/math/gfpmath/point_gfp.cpp b/src/math/gfpmath/point_gfp.cpp index e32cd14d8..f76853085 100644 --- a/src/math/gfpmath/point_gfp.cpp +++ b/src/math/gfpmath/point_gfp.cpp @@ -278,22 +278,28 @@ const PointGFp& PointGFp::set_z_to_one() return *this; } -GFpElement PointGFp::get_affine_x() const +BigInt PointGFp::get_affine_x() const { if(is_zero()) throw Illegal_Transformation("cannot convert to affine"); GFpElement z2 = mZ * mZ; - return mX * z2.inverse_in_place(); + z2.inverse_in_place(); + z2 *= mX; + + return z2.get_value(); } -GFpElement PointGFp::get_affine_y() const +BigInt PointGFp::get_affine_y() const { if(is_zero()) throw Illegal_Transformation("cannot convert to affine"); GFpElement z3 = mZ * mZ * mZ; - return mY * z3.inverse_in_place(); + z3.inverse_in_place(); + z3 *= mY; + + return z3.get_value(); } // Is this the point at infinity? @@ -385,7 +391,7 @@ PointGFp operator*(const PointGFp& point, const BigInt& scalar) SecureVector<byte> EC2OSP(const PointGFp& point, byte format) { if(format == PointGFp::UNCOMPRESSED) - return result = encode_uncompressed(point); + return encode_uncompressed(point); else if(format == PointGFp::COMPRESSED) return encode_compressed(point); else if(format == PointGFp::HYBRID) @@ -412,10 +418,10 @@ SecureVector<byte> encode_compressed(const PointGFp& point) l /= 8; SecureVector<byte> result (l+1); result[0] = 2; - BigInt x = point.get_affine_x().get_value(); + BigInt x = point.get_affine_x(); SecureVector<byte> bX = BigInt::encode_1363(x, l); result.copy(1, bX.begin(), bX.size()); - BigInt y = point.get_affine_y().get_value(); + BigInt y = point.get_affine_y(); if(y.get_bit(0)) { result[0] |= 1; @@ -440,8 +446,8 @@ SecureVector<byte> encode_uncompressed(const PointGFp& point) l /= 8; SecureVector<byte> result (2*l+1); result[0] = 4; - BigInt x = point.get_affine_x().get_value(); - BigInt y = point.get_affine_y().get_value(); + BigInt x = point.get_affine_x(); + BigInt y = point.get_affine_y(); SecureVector<byte> bX = BigInt::encode_1363(x, l); SecureVector<byte> bY = BigInt::encode_1363(y, l); result.copy(1, bX.begin(), l); @@ -467,8 +473,8 @@ SecureVector<byte> encode_hybrid(const PointGFp& point) l /= 8; SecureVector<byte> result (2*l+1); result[0] = 6; - BigInt x = point.get_affine_x().get_value(); - BigInt y = point.get_affine_y().get_value(); + BigInt x = point.get_affine_x(); + BigInt y = point.get_affine_y(); SecureVector<byte> bX = BigInt::encode_1363(x, l); SecureVector<byte> bY = BigInt::encode_1363(y, l); result.copy(1, bX.begin(), bX.size()); diff --git a/src/math/gfpmath/point_gfp.h b/src/math/gfpmath/point_gfp.h index 9c67ae53c..9f29896cb 100644 --- a/src/math/gfpmath/point_gfp.h +++ b/src/math/gfpmath/point_gfp.h @@ -121,13 +121,13 @@ class BOTAN_DLL PointGFp * get affine x coordinate * @result affine x coordinate */ - GFpElement get_affine_x() const; + BigInt get_affine_x() const; /** * get affine y coordinate * @result affine y coordinate */ - GFpElement get_affine_y() const; + BigInt get_affine_y() const; /** * get the jacobian projective x coordinate |