Merge bitcoin-core/secp256k1#1986: examples: exit with failure if signature verification fails
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.
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
Incorrect return status masked verification failures in example/test programs
Automated tests would pass despite cryptographic verification failing
Fix aligns ECDSA and Schnorr examples with existing MuSig example behavior
No change to library cryptographic code, only example driver code
Evidence from the diff
The commit modifies examples/ecdsa.c and examples/schnorr.c to return EXIT_FAILURE when the boolean is_signature_valid is false, instead of unconditionally returning EXIT_SUCCESS. The examples are executed as tests by both build systems (CMake/ctest and Autotools), so a verification failure was previously masked as a passing test. The musig example already behaved this way. The fix ensures CI will catch regressions in signing/verification behavior in the example programs.
Changed components
examples/ecdsa.cexamples/schnorr.cInspect captured patch +2 / −2
### examples/ecdsa.c
@@ -134,5 +134,5 @@ int main(void) {
* will remove any writes that aren't used. */
secure_erase(seckey, sizeof(seckey));
- return EXIT_SUCCESS;
+ return is_signature_valid ? EXIT_SUCCESS : EXIT_FAILURE;
}
### examples/schnorr.c
@@ -150,5 +150,5 @@ int main(void) {
* Here we are preventing these writes from being optimized out, as any good compiler
* will remove any writes that aren't used. */
secure_erase(seckey, sizeof(seckey));
- return EXIT_SUCCESS;
+ return is_signature_valid ? EXIT_SUCCESS : EXIT_FAILURE;
}Why this scored 23/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.