File tree Expand file tree Collapse file tree 1 file changed +58
-9
lines changed Expand file tree Collapse file tree 1 file changed +58
-9
lines changed Original file line number Diff line number Diff line change 2323 generator_brainpoolp160r1 ,
2424 curve_brainpoolp160r1 ,
2525 generator_112r2 ,
26+ curve_112r2 ,
2627)
2728from .numbertheory import inverse_mod
2829from .util import randrange
@@ -433,30 +434,78 @@ def test_add_different_scale_points_static(self):
433434
434435 self .assertEqual (c , x + y )
435436
436- def test_add_different_scale_points_static (self ):
437+ def test_add_different_points_same_scale_static (self ):
437438 j_g = generator_brainpoolp160r1
438439 p = curve_brainpoolp160r1 .p ()
439440 a = j_g * 11
440441 a .scale ()
441- z1 = 13
442+ b = j_g * 12
443+ z = 13
442444 x = PointJacobi (
443445 curve_brainpoolp160r1 ,
444- a .x () * z1 ** 2 % p ,
445- a .y () * z1 ** 3 % p ,
446- z1 ,
446+ a .x () * z ** 2 % p ,
447+ a .y () * z ** 3 % p ,
448+ z ,
447449 )
448- z2 = 29
449450 y = PointJacobi (
450451 curve_brainpoolp160r1 ,
451- a .x () * z2 ** 2 % p ,
452- a .y () * z2 ** 3 % p ,
453- z2 ,
452+ b .x () * z ** 2 % p ,
453+ b .y () * z ** 3 % p ,
454+ z ,
455+ )
456+
457+ c = a + b
458+
459+ self .assertEqual (c , x + y )
460+
461+ def test_add_same_point_different_scale_second_z_1_static (self ):
462+ j_g = generator_112r2
463+ p = curve_112r2 .p ()
464+ z = 11
465+ a = j_g * z
466+ a .scale ()
467+
468+ x = PointJacobi (
469+ curve_112r2 ,
470+ a .x () * z ** 2 % p ,
471+ a .y () * z ** 3 % p ,
472+ z ,
473+ )
474+ y = PointJacobi (
475+ curve_112r2 ,
476+ a .x (),
477+ a .y (),
478+ 1 ,
454479 )
455480
456481 c = a + a
457482
458483 self .assertEqual (c , x + y )
459484
485+ def test_add_to_infinity_static (self ):
486+ j_g = generator_112r2
487+
488+ z = 11
489+ a = j_g * z
490+ a .scale ()
491+
492+ b = - a
493+
494+ x = PointJacobi (
495+ curve_112r2 ,
496+ a .x (),
497+ a .y (),
498+ 1 ,
499+ )
500+ y = PointJacobi (
501+ curve_112r2 ,
502+ b .x (),
503+ b .y (),
504+ 1 ,
505+ )
506+
507+ self .assertEqual (INFINITY , x + y )
508+
460509 def test_add_point_3_times (self ):
461510 j_g = PointJacobi .from_affine (generator_256 )
462511
You can’t perform that action at this time.
0 commit comments