diff options
Diffstat (limited to 'frozen_deps/ecdsa/test_eddsa.py')
-rw-r--r-- | frozen_deps/ecdsa/test_eddsa.py | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/frozen_deps/ecdsa/test_eddsa.py b/frozen_deps/ecdsa/test_eddsa.py index 7a09ad7..6821b3b 100644 --- a/frozen_deps/ecdsa/test_eddsa.py +++ b/frozen_deps/ecdsa/test_eddsa.py @@ -1,3 +1,4 @@ +import sys import pickle import hashlib import pytest @@ -162,6 +163,27 @@ def test_ed25519_eq_x_different_y(): assert a != b +def test_ed25519_mul_by_order(): + g = PointEdwards( + curve_ed25519, + generator_ed25519.x(), + generator_ed25519.y(), + 1, + generator_ed25519.x() * generator_ed25519.y(), + ) + + assert g * generator_ed25519.order() == INFINITY + + +def test_radd(): + + a = PointEdwards(curve_ed25519, 1, 1, 1, 1) + + p = INFINITY + a + + assert p == a + + def test_ed25519_test_normalisation_and_scaling(): x = generator_ed25519.x() y = generator_ed25519.y() @@ -259,6 +281,22 @@ class TestEd25519(unittest.TestCase): self.assertIn("different curve", str(e.exception)) +def test_generate_with_point(): + x1 = int( + "427838232691226969392843410947554224151809796397784248136826" + "78720006717057747" + ) + y1 = int( + "463168356949264781694283940034751631413079938662562256157830" + "33603165251855960" + ) + p = PointEdwards(curve_ed25519, x1, y1, 1, x1 * y1) + + pk = PublicKey(generator_ed25519, b"0" * 32, public_point=p) + + assert pk.public_point() == p + + def test_ed25519_mul_to_order_min_1(): x1 = int( "427838232691226969392843410947554224151809796397784248136826" @@ -500,6 +538,7 @@ class TestEdDSAEquality(unittest.TestCase): key2 = PublicKey(generator_ed25519, b"\x01" * 32) self.assertEqual(key1, key2) + # verify that `__ne__` works as expected self.assertFalse(key1 != key2) def test_unequal_public_points(self): @@ -519,6 +558,7 @@ class TestEdDSAEquality(unittest.TestCase): key2 = PublicKey(generator_ed448, b"\x03" * 56 + b"\x00") self.assertNotEqual(key1, key2) + # verify that `__ne__` works as expected self.assertTrue(key1 != key2) def test_equal_private_keys(self): @@ -526,6 +566,7 @@ class TestEdDSAEquality(unittest.TestCase): key2 = PrivateKey(generator_ed25519, b"\x01" * 32) self.assertEqual(key1, key2) + # verify that `__ne__` works as expected self.assertFalse(key1 != key2) def test_unequal_private_keys(self): @@ -533,6 +574,7 @@ class TestEdDSAEquality(unittest.TestCase): key2 = PrivateKey(generator_ed25519, b"\x02" * 32) self.assertNotEqual(key1, key2) + # verify that `__ne__` works as expected self.assertTrue(key1 != key2) def test_unequal_privatekey_to_string(self): @@ -643,7 +685,10 @@ class TestInvalidEdDSAInputs(unittest.TestCase): HYP_SETTINGS = dict() -HYP_SETTINGS["max_examples"] = 10 +if "--fast" in sys.argv: # pragma: no cover + HYP_SETTINGS["max_examples"] = 2 +else: + HYP_SETTINGS["max_examples"] = 10 @settings(**HYP_SETTINGS) |