Skip to content

Commit 2848eb8

Browse files
committed
more complete test coverage for Jacobi points without hypothesis
1 parent 8299e28 commit 2848eb8

File tree

1 file changed

+59
-9
lines changed

1 file changed

+59
-9
lines changed

src/ecdsa/test_jacobi.py

+59-9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
generator_brainpoolp160r1,
2424
curve_brainpoolp160r1,
2525
generator_112r2,
26+
curve_112r2,
2627
)
2728
from .numbertheory import inverse_mod
2829
from .util import randrange
@@ -433,30 +434,79 @@ 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+
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+
460510
def test_add_point_3_times(self):
461511
j_g = PointJacobi.from_affine(generator_256)
462512

0 commit comments

Comments
 (0)