aboutsummaryrefslogtreecommitdiffstats
path: root/src/math/numbertheory/point_gfp.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-13 01:42:06 +0000
committerlloyd <[email protected]>2010-03-13 01:42:06 +0000
commitc732c77cd0d082c962e987e921a72a11303930f0 (patch)
tree6379be375bdb612a54d76fa99059fd06fd5c7acf /src/math/numbertheory/point_gfp.cpp
parent1eb4a0fdd973094d3618756212222661652ae5ab (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/point_gfp.cpp')
-rw-r--r--src/math/numbertheory/point_gfp.cpp13
1 files changed, 9 insertions, 4 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