diff options
-rw-r--r-- | checks/ec_tests.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/checks/ec_tests.cpp b/checks/ec_tests.cpp index 4115a84f1..2915eb2da 100644 --- a/checks/ec_tests.cpp +++ b/checks/ec_tests.cpp @@ -35,6 +35,31 @@ using namespace Botan; namespace { +PointGFp create_random_point(RandomNumberGenerator& rng, + const CurveGFp& curve) + { + const BigInt& p = curve.get_p(); + + while(true) + { + BigInt r(rng, p.bits()); + + GFpElement x = GFpElement(p, r); + GFpElement x3 = x * x * x; + + GFpElement ax(curve.get_p(), curve.get_a()); + ax *= x; + + GFpElement bx3(curve.get_p(), curve.get_b()); + bx3 *= x3; + + GFpElement y = ax + bx3; + + if(ressol(y.get_value(), p) > 0) + return PointGFp(curve, x.get_value(), y.get_value()); + } + } + void test_point_turn_on_sp_red_mul() { std::cout << "." << std::flush; |