aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/math/numbertheory/curve_gfp.h9
-rw-r--r--src/math/numbertheory/point_gfp.cpp2
2 files changed, 9 insertions, 2 deletions
diff --git a/src/math/numbertheory/curve_gfp.h b/src/math/numbertheory/curve_gfp.h
index 68f07a331..a7be8987c 100644
--- a/src/math/numbertheory/curve_gfp.h
+++ b/src/math/numbertheory/curve_gfp.h
@@ -42,6 +42,8 @@ class BOTAN_DLL CurveGFp
r_inv = inverse_mod(r, p);
p_dash = (((r * r_inv) - 1) / p).word_at(0);
+
+ a_r = reducer_p.multiply(a, r);
}
// CurveGFp(const CurveGFp& other) = default;
@@ -76,6 +78,11 @@ class BOTAN_DLL CurveGFp
const BigInt& get_r_inv() const { return r_inv; }
/**
+ * @return a * r mod p
+ */
+ const BigInt& get_a_r() const { return a_r; }
+
+ /**
* @return Montgomery parameter p-dash
*/
word get_p_dash() const { return p_dash; }
@@ -108,7 +115,7 @@ class BOTAN_DLL CurveGFp
BigInt p, a, b;
// Montgomery parameters
- BigInt r, r_inv;
+ BigInt r, r_inv, a_r;
word p_dash;
Modular_Reducer reducer_p;
diff --git a/src/math/numbertheory/point_gfp.cpp b/src/math/numbertheory/point_gfp.cpp
index 980bbdc3e..6cc13d648 100644
--- a/src/math/numbertheory/point_gfp.cpp
+++ b/src/math/numbertheory/point_gfp.cpp
@@ -201,7 +201,7 @@ void PointGFp::mult2()
BigInt z4 = monty_mult(coord_z, coord_z);
z4 = monty_mult(z4, z4);
- BigInt a_z4 = monty_mult(mod_p.multiply(curve.get_r(), curve.get_a()), z4);
+ BigInt a_z4 = monty_mult(curve.get_a_r(), z4);
BigInt M = mod_p.reduce(a_z4 + 3 * monty_mult(coord_x, coord_x));