examples: exit with failure if signature verification fails #1986

pull amartya1523 wants to merge 1 commits into bitcoin-core:master from amartya1523:schnorrsig-example-check changing 2 files +2 −2
  1. amartya1523 commented at 4:15 PM on November 3, 2026: contributor

    The ecdsa and schnorr examples print whether the signature verified, but return EXIT_SUCCESS either way. Both build systems run the examples as tests, so if verification broke, those test runs would still pass.

    I checked this by flipping a byte of the signature (schnorr) and of the message hash (ecdsa) right before verification: both examples printed "Is the signature valid? false" and ctest -R "example\.(schnorr|ecdsa)" still reported them as passed. With this change the same experiment makes both tests fail.

    This matches what the musig example already does when secp256k1_schnorrsig_verify fails. The return stays at the end of main, so the context destroy and secret key erasure still happen first.

  2. examples: exit with failure if signature verification fails
    The ecdsa and schnorr examples print whether the signature is valid
    but return EXIT_SUCCESS either way. Since the examples are run as tests
    by both build systems, a regression that broke verification would go
    unnoticed there. The musig example already fails in this case.
    900613a742
  3. amartya1523 closed this on Nov 3, 2026

  4. real-or-random commented at 8:10 AM on November 4, 2026: contributor

    Let me just reopen this and merge it, it's trivial.

  5. real-or-random reopened this on Nov 4, 2026

  6. real-or-random approved
  7. real-or-random commented at 8:10 AM on November 4, 2026: contributor

    utACK 900613a742f8b08fe8ce2511488e777c235214c1 It will ultimately depend on the application how to handle an invalid sig but a) it's good to keep this in sync with the musig example, and b) the examples are supposed to generate valid sigs, so returning EXIT_FAILURE is better for testing the examples in CI

  8. real-or-random merged this on Nov 4, 2026
  9. real-or-random closed this on Nov 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-11-12 08:15 UTC

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