@@ -195,6 +195,33 @@ def test_compare_non_zero_with_infinity(self):
195
195
196
196
self .assertNotEqual (pj , INFINITY )
197
197
198
+ def test_compare_non_zero_bad_scale_with_infinity (self ):
199
+ pj = PointJacobi (curve_256 , 1 , 1 , 0 )
200
+ self .assertEqual (pj , INFINITY )
201
+
202
+ def test_eq_x_0_on_curve_with_infinity (self ):
203
+ c_23 = CurveFp (23 , 1 , 1 )
204
+ pj = PointJacobi (c_23 , 0 , 1 , 1 )
205
+
206
+ self .assertTrue (c_23 .contains_point (0 , 1 ))
207
+
208
+ self .assertNotEqual (pj , INFINITY )
209
+
210
+ def test_eq_y_0_on_curve_with_infinity (self ):
211
+ c_23 = CurveFp (23 , 1 , 1 )
212
+ pj = PointJacobi (c_23 , 4 , 0 , 1 )
213
+
214
+ self .assertTrue (c_23 .contains_point (4 , 0 ))
215
+
216
+ self .assertNotEqual (pj , INFINITY )
217
+
218
+ def test_eq_with_same_x_different_y (self ):
219
+ c_23 = CurveFp (23 , 1 , 1 )
220
+ p_a = PointJacobi (c_23 , 0 , 22 , 1 )
221
+ p_b = PointJacobi (c_23 , 0 , 1 , 1 )
222
+
223
+ self .assertNotEqual (p_a , p_b )
224
+
198
225
def test_compare_zero_point_with_infinity (self ):
199
226
pj = PointJacobi (curve_256 , 0 , 0 , 1 )
200
227
@@ -671,6 +698,41 @@ def test_add_to_infinity(self):
671
698
self .assertEqual (p3 , INFINITY )
672
699
self .assertIs (p3 , INFINITY )
673
700
701
+ def test_mul_to_x_0 (self ):
702
+ c_23 = CurveFp (23 , 1 , 1 )
703
+ p = PointJacobi (c_23 , 9 , 7 , 1 )
704
+
705
+ p2 = p * 13
706
+ self .assertEqual ((p2 .x (), p2 .y ()), (0 , 22 ))
707
+
708
+ def test_mul_to_y_0 (self ):
709
+ c_23 = CurveFp (23 , 1 , 1 )
710
+ p = PointJacobi (c_23 , 9 , 7 , 1 )
711
+
712
+ p2 = p * 14
713
+ self .assertEqual ((p2 .x (), p2 .y ()), (4 , 0 ))
714
+
715
+ def test_add_to_x_0 (self ):
716
+ c_23 = CurveFp (23 , 1 , 1 )
717
+ p = PointJacobi (c_23 , 9 , 7 , 1 )
718
+
719
+ p2 = p * 12 + p
720
+ self .assertEqual ((p2 .x (), p2 .y ()), (0 , 22 ))
721
+
722
+ def test_add_to_y_0 (self ):
723
+ c_23 = CurveFp (23 , 1 , 1 )
724
+ p = PointJacobi (c_23 , 9 , 7 , 1 )
725
+
726
+ p2 = p * 13 + p
727
+ self .assertEqual ((p2 .x (), p2 .y ()), (4 , 0 ))
728
+
729
+ def test_add_diff_z_to_infinity (self ):
730
+ c_23 = CurveFp (23 , 1 , 1 )
731
+ p = PointJacobi (c_23 , 9 , 7 , 1 )
732
+
733
+ c = p * 20 + p * 8
734
+ self .assertIs (c , INFINITY )
735
+
674
736
def test_pickle (self ):
675
737
pj = PointJacobi (curve = CurveFp (23 , 1 , 1 , 1 ), x = 2 , y = 3 , z = 1 , order = 1 )
676
738
self .assertEqual (pickle .loads (pickle .dumps (pj )), pj )
0 commit comments