AntonKueltz / fastecdsa

Python library for fast elliptic curve crypto
https://pypi.python.org/pypi/fastecdsa
The Unlicense
263 stars 76 forks source link

[fastecdsa/tests] regression test: multiplication by large scalars #72

Closed bbbrumley closed 3 years ago

bbbrumley commented 3 years ago

5ddb75238943a683b756ab9943fcdd85a3f65e29 (from #58) removed the scalar reduction modulo q, which previously yielded incorrect results for points with order different from q.

Unfortunately that broke multiplication with negative scalars. Reported in #70, fixed in bc203c56e5f785d1eaf373da2249c381e2069be1.

@AntonKueltz says

I'm surprised the test suite didn't catch this regression when I added it back in, everything looks green still.

These are the regression tests for that.

bbbrumley commented 3 years ago

@AntonKueltz I tested with the d394335b6b6f71604a50f0c8336e62abd45936ff diff, but would appreciate it if you could independently verify!

AntonKueltz commented 3 years ago

🎉 thanks for this regression test @bbbrumley! was able to verify that this catches the regression from d394335 -

======================================================================
FAIL: test_mul_by_large (fastecdsa.tests.test_prime_field_curve_math.TestPrimeFieldCurve)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/fastecdsa/fastecdsa/tests/test_prime_field_curve_math.py", line 256, in test_mul_by_large
    self.assertEqual(R, expected)
AssertionError: X: 0x203e274d51c3f652c13881df9c9ea6bbb0e11e3b7[108 chars]519>) != X: 0x6de4fd40d8d2e42039e6b5020b25164896391266c[108 chars]519>)