From 53fa580b81c733df549d6820e44d2d684a3377a0 Mon Sep 17 00:00:00 2001 From: Jochen Hoenicke Date: Wed, 5 Aug 2015 22:29:34 +0200 Subject: [PATCH] Added more unit tests - Added Romanz's validate_pubkey test. - Added special test to check that jacobin_point_add can double. --- test_curves.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test_curves.py b/test_curves.py index 6aa4cb4ad4..25e07dfb17 100755 --- a/test_curves.py +++ b/test_curves.py @@ -298,6 +298,19 @@ def test_jacobian_add(curve, r): p_ = p1 + p2 assert (p_.x(), p_.y()) == q +def test_jacobian_add_double(curve, r): + p1 = r.randpoint(curve) + p2 = p1 + prime = int2bn(curve.p) + q = POINT() + jp2 = JACOBIAN() + lib.curve_to_jacobian(to_POINT(p2), jp2, prime) + lib.point_jacobian_add(to_POINT(p1), jp2, curve.ptr) + lib.jacobian_to_curve(jp2, q, prime) + q = from_POINT(q) + p_ = p1 + p2 + assert (p_.x(), p_.y()) == q + def test_jacobian_double(curve, r): p = r.randpoint(curve) p2 = p.double() @@ -330,3 +343,7 @@ def test_sign(curve, r): assert binascii.hexlify(sig) == binascii.hexlify(sig_ref) assert vk.verify_digest(sig, digest, sigdecode) + +def test_validate_pubkey(curve, r): + p = r.randpoint(curve) + assert lib.ecdsa_validate_pubkey(curve.ptr, to_POINT(p))