aboutsummaryrefslogtreecommitdiffstats
path: root/src/math/gfpmath
diff options
context:
space:
mode:
authorlloyd <lloyd@randombit.net>2010-02-24 21:59:30 +0000
committerlloyd <lloyd@randombit.net>2010-02-24 21:59:30 +0000
commit694e221bab3dd325425318ca01c929907883ec56 (patch)
tree56a7548792f8f994da5aa86e06050ca8a84afd95 /src/math/gfpmath
parent896fb20a4c2eb6ca0c1b6ff0bfd35cadf1a48e18 (diff)
Inline small funcs. Remove mult2
Diffstat (limited to 'src/math/gfpmath')
-rw-r--r--src/math/gfpmath/point_gfp.cpp43
-rw-r--r--src/math/gfpmath/point_gfp.h15
2 files changed, 12 insertions, 46 deletions
diff --git a/src/math/gfpmath/point_gfp.cpp b/src/math/gfpmath/point_gfp.cpp
index 11708d3ea..f3fd3e588 100644
--- a/src/math/gfpmath/point_gfp.cpp
+++ b/src/math/gfpmath/point_gfp.cpp
@@ -275,21 +275,6 @@ GFpElement PointGFp::get_affine_y() const
return mY * z3.inverse_in_place();
}
-GFpElement PointGFp::get_jac_proj_x() const
- {
- return GFpElement(mX);
- }
-
-GFpElement PointGFp::get_jac_proj_y() const
- {
- return GFpElement(mY);
- }
-
-GFpElement PointGFp::get_jac_proj_z() const
- {
- return GFpElement(mZ);
- }
-
// Is this the point at infinity?
bool PointGFp::is_zero() const
{
@@ -317,10 +302,7 @@ void PointGFp::check_invariants() const
{
GFpElement ax = mC.get_a() * mX;
if(y2 != (x3 + ax + mC.get_b()))
- {
throw Illegal_Point();
- }
-
}
GFpElement Zpow2 = mZ * mZ;
@@ -342,29 +324,12 @@ void PointGFp::swap(PointGFp& other)
mZ.swap(other.mZ);
}
-PointGFp mult2(const PointGFp& point)
- {
- return (PointGFp(point)).mult2_in_place();
- }
-
-bool operator==(const PointGFp& lhs, PointGFp const& rhs)
+bool PointGFp::operator==(const PointGFp& other) const
{
- if(lhs.is_zero() && rhs.is_zero())
- {
- return true;
- }
- if((lhs.is_zero() && !rhs.is_zero()) || (!lhs.is_zero() && rhs.is_zero()))
- {
+ if(get_curve() != other.get_curve())
return false;
- }
- // neither operand is zero, so we can call get_z_to_one()
- //assert(!lhs.is_zero());
- //assert(!rhs.is_zero());
- PointGFp aff_lhs = lhs.get_z_to_one();
- PointGFp aff_rhs = rhs.get_z_to_one();
- return (aff_lhs.get_curve() == aff_rhs.get_curve() &&
- aff_lhs.get_jac_proj_x() == aff_rhs.get_jac_proj_x() &&
- aff_lhs.get_jac_proj_y() == aff_rhs.get_jac_proj_y());
+
+ return (mX == other.mX && mY == other.mY && mZ == other.mZ);
}
// arithmetic operators
diff --git a/src/math/gfpmath/point_gfp.h b/src/math/gfpmath/point_gfp.h
index e413e2311..ea73b9e0d 100644
--- a/src/math/gfpmath/point_gfp.h
+++ b/src/math/gfpmath/point_gfp.h
@@ -144,19 +144,19 @@ class BOTAN_DLL PointGFp
* get the jacobian projective x coordinate
* @result jacobian projective x coordinate
*/
- GFpElement get_jac_proj_x() const;
+ const GFpElement& get_jac_proj_x() const { return mX; }
/**
* get the jacobian projective y coordinate
* @result jacobian projective y coordinate
*/
- GFpElement get_jac_proj_y() const;
+ const GFpElement& get_jac_proj_y() const { return mY; }
/**
* get the jacobian projective z coordinate
* @result jacobian projective z coordinate
*/
- GFpElement get_jac_proj_z() const;
+ const GFpElement& get_jac_proj_z() const { return mZ; }
/**
* Is this the point at infinity?
@@ -180,6 +180,10 @@ class BOTAN_DLL PointGFp
static GFpElement decompress(bool yMod2, GFpElement const& x, const CurveGFp& curve);
+ /**
+ * Equality operator
+ */
+ bool operator==(const PointGFp& other) const;
private:
CurveGFp mC;
mutable GFpElement mX; // NOTE: these values must be mutable (affine<->proj)
@@ -188,10 +192,9 @@ class BOTAN_DLL PointGFp
};
// relational operators
-bool BOTAN_DLL operator==(const PointGFp& lhs, const PointGFp& rhs);
inline bool operator!=(const PointGFp& lhs, const PointGFp& rhs )
{
- return !operator==(lhs, rhs);
+ return !(rhs == lhs);
}
// arithmetic operators
@@ -202,8 +205,6 @@ PointGFp BOTAN_DLL operator-(const PointGFp& lhs);
PointGFp BOTAN_DLL operator*(const BigInt& scalar, const PointGFp& point);
PointGFp BOTAN_DLL operator*(const PointGFp& point, const BigInt& scalar);
-PointGFp BOTAN_DLL mult2(const PointGFp& point);
-
PointGFp BOTAN_DLL create_random_point(RandomNumberGenerator& rng,
const CurveGFp& curve);