diff options
author | lloyd <[email protected]> | 2010-03-13 01:42:06 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-03-13 01:42:06 +0000 |
commit | c732c77cd0d082c962e987e921a72a11303930f0 (patch) | |
tree | 6379be375bdb612a54d76fa99059fd06fd5c7acf /src/math/numbertheory | |
parent | 1eb4a0fdd973094d3618756212222661652ae5ab (diff) |
Remove access to the Jacobian coordinate getters get_{x,y,z}, as well
as the 4-argument constructor.
Define operator==() in terms of the affine coordinates.
Rewrite tests that assumed access to the Jacobian coodinates in terms
of the affine coordinates.
This change allows for using arbitrary coordinate systems in PointGFp,
as long as it can convert to the normal affine coordinates (which are
what is used by all ECC algorithms implemented currently, and probably
all interesting ECC algorithms in general).
Diffstat (limited to 'src/math/numbertheory')
-rw-r--r-- | src/math/numbertheory/point_gfp.cpp | 13 | ||||
-rw-r--r-- | src/math/numbertheory/point_gfp.h | 29 |
2 files changed, 9 insertions, 33 deletions
diff --git a/src/math/numbertheory/point_gfp.cpp b/src/math/numbertheory/point_gfp.cpp index db422c8aa..90885bc94 100644 --- a/src/math/numbertheory/point_gfp.cpp +++ b/src/math/numbertheory/point_gfp.cpp @@ -268,10 +268,15 @@ void PointGFp::swap(PointGFp& other) bool PointGFp::operator==(const PointGFp& other) const { - return (coord_x == other.coord_x && - coord_y == other.coord_y && - coord_z == other.coord_z && - get_curve() == other.get_curve()); + if(get_curve() != other.get_curve()) + return false; + + // If this is zero, only equal if other is also zero + if(is_zero()) + return other.is_zero(); + + return (get_affine_x() == other.get_affine_x() && + get_affine_y() == other.get_affine_y()); } // encoding and decoding diff --git a/src/math/numbertheory/point_gfp.h b/src/math/numbertheory/point_gfp.h index 2f31421fc..3417c7b7f 100644 --- a/src/math/numbertheory/point_gfp.h +++ b/src/math/numbertheory/point_gfp.h @@ -62,17 +62,6 @@ class BOTAN_DLL PointGFp const BigInt& x, const BigInt& y) : curve(curve), coord_x(x), coord_y(y), coord_z(1) {} - /** - * Construct a point given its jacobian projective coordinates - * @param curve the base curve - * @param x jacobian projective x coordinate - * @param y jacobian projective y coordinate - * @param z jacobian projective z coordinate - */ - PointGFp(const CurveGFp& curve, - const BigInt& x, const BigInt& y, const BigInt& z) : - curve(curve), coord_x(x), coord_y(y), coord_z(z) {} - //PointGFp(const PointGFp& other) = default; //PointGFp& operator=(const PointGFp& other) = default; @@ -129,24 +118,6 @@ class BOTAN_DLL PointGFp BigInt get_affine_y() const; /** - * get the jacobian projective x coordinate - * @result jacobian projective x coordinate - */ - const BigInt& get_x() const { return coord_x; } - - /** - * get the jacobian projective y coordinate - * @result jacobian projective y coordinate - */ - const BigInt& get_y() const { return coord_y; } - - /** - * get the jacobian projective z coordinate - * @result jacobian projective z coordinate - */ - const BigInt& get_z() const { return coord_z; } - - /** * Is this the point at infinity? * @result true, if this point is at infinity, false otherwise. */ |