File tree 1 file changed +59
-9
lines changed
1 file changed +59
-9
lines changed Original file line number Diff line number Diff line change 23
23
generator_brainpoolp160r1 ,
24
24
curve_brainpoolp160r1 ,
25
25
generator_112r2 ,
26
+ curve_112r2 ,
26
27
)
27
28
from .numbertheory import inverse_mod
28
29
from .util import randrange
@@ -433,30 +434,79 @@ def test_add_different_scale_points_static(self):
433
434
434
435
self .assertEqual (c , x + y )
435
436
436
- def test_add_different_scale_points_static (self ):
437
+ def test_add_different_points_same_scale_static (self ):
437
438
j_g = generator_brainpoolp160r1
438
439
p = curve_brainpoolp160r1 .p ()
439
440
a = j_g * 11
440
441
a .scale ()
441
- z1 = 13
442
+ b = j_g * 12
443
+ z = 13
442
444
x = PointJacobi (
443
445
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 ,
447
449
)
448
- z2 = 29
449
450
y = PointJacobi (
450
451
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 ,
454
479
)
455
480
456
481
c = a + a
457
482
458
483
self .assertEqual (c , x + y )
459
484
485
+ def test_add_to_infinity_static (self ):
486
+ j_g = generator_112r2
487
+ p = curve_112r2 .p ()
488
+
489
+ z = 11
490
+ a = j_g * z
491
+ a .scale ()
492
+
493
+ b = - a
494
+
495
+ x = PointJacobi (
496
+ curve_112r2 ,
497
+ a .x (),
498
+ a .y (),
499
+ 1 ,
500
+ )
501
+ y = PointJacobi (
502
+ curve_112r2 ,
503
+ b .x (),
504
+ b .y (),
505
+ 1 ,
506
+ )
507
+
508
+ self .assertEqual (INFINITY , x + y )
509
+
460
510
def test_add_point_3_times (self ):
461
511
j_g = PointJacobi .from_affine (generator_256 )
462
512
You can’t perform that action at this time.
0 commit comments