diff options
author | lloyd <[email protected]> | 2010-02-25 19:43:23 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-02-25 19:43:23 +0000 |
commit | bb8112e7b5fd018b3c653c139a03cf14f163e3cb (patch) | |
tree | 20b32ec8ff3c7707ce527674b6384e68a2cc00f1 /src/math | |
parent | 9d1cbc6d07a81289612d09625fc57afcbd9ac995 (diff) |
Use Modular_Reducer instead of GFpElement in operator*=
Diffstat (limited to 'src/math')
-rw-r--r-- | src/math/gfpmath/point_gfp.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/math/gfpmath/point_gfp.cpp b/src/math/gfpmath/point_gfp.cpp index 9bf221ddb..1515e6759 100644 --- a/src/math/gfpmath/point_gfp.cpp +++ b/src/math/gfpmath/point_gfp.cpp @@ -157,19 +157,14 @@ PointGFp& PointGFp::operator*=(const BigInt& scalar) */ if(H.coord_z != 1) { - GFpElement point_x(curve.get_p(), H.coord_x); - GFpElement point_y(curve.get_p(), H.coord_y); - GFpElement point_z(curve.get_p(), H.coord_z); - - // Converts to affine coordinates - GFpElement z = inverse(point_z); - GFpElement z2 = z * z; - z *= z2; - GFpElement x = point_x * z2; - GFpElement y = point_y * z; - - H.coord_x = x.get_value(); - H.coord_y = y.get_value(); + Modular_Reducer mod_p(curve.get_p()); + + BigInt z_inv = inverse_mod(H.coord_z, curve.get_p()); + + BigInt z_inv_2 = mod_p.square(z_inv); + + H.coord_x = mod_p.multiply(H.coord_x, z_inv_2); + H.coord_y = mod_p.multiply(H.coord_y, mod_p.multiply(z_inv, z_inv_2)); H.coord_z = 1; } } |