tests: Improve _scalar_check_overflow tests #1812

issue real-or-random openend this issue on January 28, 2026
  1. real-or-random commented at 7:40 am on January 28, 2026: contributor

    At the moment, the only test is this one: https://github.com/bitcoin-core/secp256k1/blob/1605b02f751cf7762dc9ae9a23d6d1daeb4d52df/src/tests.c#L2262-L2267

    That is, even a blank return 1 would pass the tests.

    Some calls to secp256k1_scalar_check_overflow in the tests were removed in #1484 because I deemed them redundant. But that’s not entirely true. Their primary purpose was to check for overflows in other test code, and this is indeed redundant. But a secondary effect of these calls was to test secp256k1_scalar_check_overflow itself.

    We could revert this, but I think it’s better to have a bunch of dedicated tests:

    • Check a handful of static inputs including the edge cases.
    • Check some random inputs. Uniformly random inputs should not overflow. But if we tweak in the right way (e.g., setting top bits), they should overflow.
  2. real-or-random added the label assurance on Jan 28, 2026
  3. real-or-random added the label tweak/refactor on Jan 28, 2026
  4. real-or-random added the label good first issue on Jan 28, 2026
  5. therohityadav referenced this in commit a27e7512a7 on Feb 4, 2026
  6. real-or-random closed this on Feb 4, 2026

  7. pull[bot] referenced this in commit 1d146ac3ed on Feb 4, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-02-15 13:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me