@@ -71,6 +71,20 @@ def test_add_and_mult_equivalence(p, m, check):
7171 assert p * m == check
7272
7373
74+ # from https://github.com/tlsfuzzer/python-ecdsa/issues/373
75+ curve = CurveFp (p = 31 , a = 2 , b = 3 )
76+ point = Point (curve , 6 , 18 )
77+
78+
79+ @pytest .mark .parametrize (
80+ "p, m, check" ,
81+ [(point , n , exp ) for n , exp in enumerate (add_n_times (point , 16 ))],
82+ ids = ["p31 test with mult {0}" .format (i ) for i in range (17 )],
83+ )
84+ def test_add_and_mult_equivalence_2 (p , m , check ):
85+ assert p * m == check
86+
87+
7488class TestCurve (unittest .TestCase ):
7589 @classmethod
7690 def setUpClass (cls ):
@@ -146,6 +160,16 @@ def setUpClass(cls):
146160 cls .c192 = CurveFp (p , - 3 , b )
147161 cls .p192 = Point (cls .c192 , Gx , Gy , r )
148162
163+ def test_points_with_different_curves (self ):
164+ with self .assertRaises (AssertionError ):
165+ self .g_23 + self .p192
166+
167+ def test_add_point_to_negative (self ):
168+ self .assertIs (self .g_23 + (- self .g_23 ), INFINITY )
169+
170+ def test_add_point_to_explicit_negative (self ):
171+ self .assertIs (self .g_23 + Point (self .c_23 , 13 , - 7 ), INFINITY )
172+
149173 def test_p192 (self ):
150174 # Checking against some sample computations presented
151175 # in X9.62:
0 commit comments