zk-kit icon indicating copy to clipboard operation
zk-kit copied to clipboard

test(eddsa-poseidon): Targeted tests for compatibility & security of secret scalar modulus

Open artwyman opened this issue 10 months ago • 3 comments

Is your feature request related to a problem? Please describe.

This is a follow-on suggestion to #257 which added mod reduction to secret scalar generation. Existing tests confirm that this results in the same public key for one test case, but nothing to confirm that the default private key used actually causes an overflow. I suggest adding some more targeted test cases for the specific situations and vulnerabilities targeted by this change.

Describe the solution you'd like

A few things I'd suggest for additional test cases:

  • Check that the secret scalar is in the intended range in all tests.
  • Pick multiple secret keys which do and don't cause the overflow targeted here.
  • Pick secret keys tailored to the attack scenario which motivated this (those which cause overflow but result in the same public key). Confirm they result in the same secret scalar now as well.

Describe alternatives you've considered May be too late for this now, but an approach I've found valuable particularly with security-related bugs is based on TDD. Write a test first which will fail and prove the existence of a security bug. Then make the fix and prove the test now passes.

artwyman avatar Apr 24 '24 20:04 artwyman