examples: exit with failure if signature verification fails
What changed, and why it matters
This is a small hardening fix to two example programs. Previously, the example programs for ECDSA and Schnorr signatures would print whether a signature was valid but always report success to the operating system. Because the project's build systems run these examples as automated tests, a future bug that broke signature verification could have been hidden. Now the examples return a failure code when verification fails, so the test harness will notice.
No urgent action needed; this is a defensive test-quality improvement. Users should ensure they are on a version that includes this change if they rely on the examples as regression tests.
Security signals we found
Test/example code silently succeeded on verification failure
Regression-test gap for signature verification behavior
Fix hardens CI/test signal without changing cryptographic logic
Evidence from the diff
The commit changes the return value of main() in examples/ecdsa.c and examples/schnorr.c from unconditional EXIT_SUCCESS to EXIT_FAILURE when is_signature_valid is false. This aligns the two examples with examples/musig.c, which already failed on verification failure. The change only affects example/test code, not the library’s signature verification logic itself.
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 18/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.