aboutsummaryrefslogtreecommitdiffstats
path: root/checks/ec_tests.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-02-25 21:09:28 +0000
committerlloyd <[email protected]>2010-02-25 21:09:28 +0000
commit78616a7ee3a5176838ba4cc295b6998f9666afbb (patch)
treecf1f825ff49e73660fba28ad8e75e71886125fe7 /checks/ec_tests.cpp
parentd3c42f9fbd38b060696b7a6ee4376be38888a4e0 (diff)
Change create_random_point to use Modular_Reducer
Diffstat (limited to 'checks/ec_tests.cpp')
-rw-r--r--checks/ec_tests.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/checks/ec_tests.cpp b/checks/ec_tests.cpp
index 5e1ad98c6..0c814a136 100644
--- a/checks/ec_tests.cpp
+++ b/checks/ec_tests.cpp
@@ -18,7 +18,6 @@ void do_ec_tests(RandomNumberGenerator&) { return; }
#include <botan/numthry.h>
#include <botan/curve_gfp.h>
#include <botan/point_gfp.h>
-#include <botan/gfp_element.h>
#include <botan/ecdsa.h>
using namespace Botan;
@@ -40,23 +39,22 @@ PointGFp create_random_point(RandomNumberGenerator& rng,
{
const BigInt& p = curve.get_p();
+ const Modular_Reducer& mod_p = curve.mod_p();
+
while(true)
{
- BigInt r(rng, p.bits());
+ BigInt x(rng, p.bits());
- GFpElement x = GFpElement(p, r);
- GFpElement x3 = x * x * x;
+ BigInt x3 = mod_p.multiply(x, mod_p.square(x));
- GFpElement ax(curve.get_p(), curve.get_a());
- ax *= x;
+ BigInt ax = mod_p.multiply(curve.get_a(), x);
- GFpElement bx3(curve.get_p(), curve.get_b());
- bx3 *= x3;
+ BigInt bx3 = mod_p.multiply(curve.get_b(), x3);
- GFpElement y = ax + bx3;
+ BigInt y = mod_p.reduce(ax + bx3);
- if(ressol(y.get_value(), p) > 0)
- return PointGFp(curve, x.get_value(), y.get_value());
+ if(ressol(y, p) > 0)
+ return PointGFp(curve, x, y);
}
}