diff options
author | lloyd <[email protected]> | 2010-02-25 20:50:47 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-02-25 20:50:47 +0000 |
commit | 2713464d38711fba803399992627525bd980f5e6 (patch) | |
tree | ec89fb912dce6dbd36eaa901a57c52a567f364e2 /src/math/gfpmath/point_gfp.cpp | |
parent | e5719d76098b94fdf1e9e53b5b4ce337290caedb (diff) |
Cache the Modular_Reducer of p in CurveGFp; speedup of 3-4x
Diffstat (limited to 'src/math/gfpmath/point_gfp.cpp')
-rw-r--r-- | src/math/gfpmath/point_gfp.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/math/gfpmath/point_gfp.cpp b/src/math/gfpmath/point_gfp.cpp index dc55e2fa6..c28b1eb62 100644 --- a/src/math/gfpmath/point_gfp.cpp +++ b/src/math/gfpmath/point_gfp.cpp @@ -50,7 +50,7 @@ PointGFp& PointGFp::operator+=(const PointGFp& rhs) return *this; } - Modular_Reducer mod_p(curve.get_p()); + const Modular_Reducer& mod_p = curve.mod_p(); BigInt rhs_z2 = mod_p.square(rhs.coord_z); BigInt U1 = mod_p.multiply(coord_x, rhs_z2); @@ -148,7 +148,7 @@ PointGFp& PointGFp::operator*=(const BigInt& scalar) */ if(H.coord_z != 1) { - Modular_Reducer mod_p(curve.get_p()); + const Modular_Reducer& mod_p = curve.mod_p(); BigInt z_inv = inverse_mod(H.coord_z, curve.get_p()); @@ -183,7 +183,7 @@ void PointGFp::mult2_in_place() return; } - Modular_Reducer mod_p(curve.get_p()); + const Modular_Reducer& mod_p = curve.mod_p(); BigInt y_2 = mod_p.square(coord_y); @@ -216,7 +216,7 @@ BigInt PointGFp::get_affine_x() const if(is_zero()) throw Illegal_Transformation("cannot convert to affine"); - Modular_Reducer mod_p(curve.get_p()); + const Modular_Reducer& mod_p = curve.mod_p(); BigInt z2 = mod_p.square(coord_z); return mod_p.multiply(coord_x, inverse_mod(z2, curve.get_p())); @@ -227,7 +227,7 @@ BigInt PointGFp::get_affine_y() const if(is_zero()) throw Illegal_Transformation("cannot convert to affine"); - Modular_Reducer mod_p(curve.get_p()); + const Modular_Reducer& mod_p = curve.mod_p(); BigInt z3 = mod_p.multiply(coord_z, mod_p.square(coord_z)); return mod_p.multiply(coord_y, inverse_mod(z3, curve.get_p())); @@ -251,7 +251,7 @@ void PointGFp::check_invariants() const if(is_zero()) return; - Modular_Reducer mod_p(curve.get_p()); + const Modular_Reducer& mod_p = curve.mod_p(); BigInt y2 = mod_p.square(coord_y); BigInt x3 = mod_p.multiply(coord_x, mod_p.square(coord_x)); |