AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 23 Bitcoin

Merge bitcoin-core/secp256k1#1986: examples: exit with failure if signature verification fails

Public commit record

What the developer wrote

Authored by merge-script

96/100 · Strong
Merge bitcoin-core/secp256k1#1986: examples: exit with failure if signature verification fails

900613a742f8b08fe8ce2511488e777c235214c1 examples: exit with failure if signature verification fails (Amartya Singh)

Pull request description:

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.

ACKs for top commit:
real-or-random:
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

Tree-SHA512: 2c053adcde327cd20bd9447794ad0e8042618dd489b8640361ea5cfc6cf9760719e92bdd5700c7d3c280646b599ae7b1b8773dc45bbdc65a0da9c424703c1f84
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This change fixes two example programs so they return a failure code when a signature check fails. Previously, the examples always reported success even if verification failed, which meant automated tests would pass even when the underlying cryptographic code was broken. This is a test-quality and example-correctness fix, not a vulnerability in the library itself.

Recommended action

No urgent action required. The change is a quality improvement for examples and CI tests. Users relying on the examples as correctness checks should update to include this fix. Library consumers should verify their own verification-result handling is correct.

Security signals we found

01

Incorrect return status masked verification failures in example/test programs

02

Automated tests would pass despite cryptographic verification failing

03

Fix aligns ECDSA and Schnorr examples with existing MuSig example behavior

04

No change to library cryptographic code, only example driver code

Risk score

Why this scored 23/100

Our methodology →
Potential impact 4/30
Exploitability 0/25
Stealth signal 2/15
Affected reach 3/15
Confidence 9/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.