diff options
author | lloyd <[email protected]> | 2010-03-15 19:28:30 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-03-15 19:28:30 +0000 |
commit | bb3cc0357bc01cca1e50a3a88143c8715c136219 (patch) | |
tree | c76e66046eaba0d6234e239b5bf528a53bd059a7 /src/math/numbertheory | |
parent | 992ef04c673e1eab95d419731062cd813e9360a1 (diff) |
Strength reduce on multiplies in PointGFp
Diffstat (limited to 'src/math/numbertheory')
-rw-r--r-- | src/math/numbertheory/point_gfp.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/math/numbertheory/point_gfp.cpp b/src/math/numbertheory/point_gfp.cpp index fe02d4d00..a74b301ba 100644 --- a/src/math/numbertheory/point_gfp.cpp +++ b/src/math/numbertheory/point_gfp.cpp @@ -151,7 +151,7 @@ void PointGFp::add(const PointGFp& rhs, monty_mult(U2, U1, U2, ws); monty_sqr(x, r, ws); - x -= S2 + U2*2; + x -= S2 + (U2 << 1); while(x.is_negative()) x += p; @@ -163,7 +163,7 @@ void PointGFp::add(const PointGFp& rhs, if(y.is_negative()) y += p; - z = monty_mult(monty_mult(coord_z, rhs.coord_z, ws), H, ws); + monty_mult(z, monty_mult(coord_z, rhs.coord_z, ws), H, ws); coord_x = x; coord_y = y; @@ -292,11 +292,12 @@ void PointGFp::mult2(Workspace& workspace) while(M >= p) M -= p; - x = monty_sqr(M, ws) - 2*S; + x = monty_sqr(M, ws) - (S << 1); while(x.is_negative()) x += p; - U = 8 * monty_sqr(y_2, ws); + U = monty_sqr(y_2, ws); + U <<= 3; while(U >= p) U -= p; |