diff options
author | lloyd <[email protected]> | 2010-02-25 20:12:21 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-02-25 20:12:21 +0000 |
commit | 679a1a57a19484c4cf2720f9b415b8a8df45b209 (patch) | |
tree | b1dd0e013998341895a56a41051f1a51fc66a523 /src/math | |
parent | 0f9e25393e389d2925899df63a061df01cf3da81 (diff) |
s/GFpElement/Modular_Reducer/ in get_affine_{x,y}
Diffstat (limited to 'src/math')
-rw-r--r-- | src/math/gfpmath/point_gfp.cpp | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/math/gfpmath/point_gfp.cpp b/src/math/gfpmath/point_gfp.cpp index febba412c..24aa8d8af 100644 --- a/src/math/gfpmath/point_gfp.cpp +++ b/src/math/gfpmath/point_gfp.cpp @@ -217,14 +217,10 @@ BigInt PointGFp::get_affine_x() const if(is_zero()) throw Illegal_Transformation("cannot convert to affine"); - GFpElement point_x(curve.get_p(), coord_x); - GFpElement point_z(curve.get_p(), coord_z); - - GFpElement z2 = point_z * point_z; - z2.inverse_in_place(); - z2 *= point_x; + Modular_Reducer mod_p(curve.get_p()); - return z2.get_value(); + BigInt z2 = mod_p.square(coord_z); + return mod_p.multiply(coord_x, inverse_mod(z2, curve.get_p())); } BigInt PointGFp::get_affine_y() const @@ -232,14 +228,10 @@ BigInt PointGFp::get_affine_y() const if(is_zero()) throw Illegal_Transformation("cannot convert to affine"); - GFpElement point_y(curve.get_p(), coord_y); - GFpElement point_z(curve.get_p(), coord_z); - - GFpElement z3 = point_z * point_z * point_z; - z3.inverse_in_place(); - z3 *= point_y; + Modular_Reducer mod_p(curve.get_p()); - return z3.get_value(); + BigInt z3 = mod_p.multiply(coord_z, mod_p.square(coord_z)); + return mod_p.multiply(coord_y, inverse_mod(z3, curve.get_p())); } // Is this the point at infinity? |