Verify Schnorr signatures before returning them
What changed, and why it matters
This commit adds a safety check to the Ledger Bitcoin app: after creating a Schnorr signature, the app now immediately verifies that signature using the public key. If verification fails, the app aborts and returns an error instead of handing out a potentially malformed signature. This is a defense-in-depth measure against rare hardware or computation faults during signing, not a fix for a known exploitable bug.
No immediate user action required. This is a hardening improvement. Ensure firmware updates include this change, and monitor for any future reports of signature verification failures in the field.
Security signals we found
Adds post-signing verification of Schnorr signatures
References BIP-340 recommended defense-in-depth practice
Aborts with SW_BAD_STATE on verification failure
Prevents release of invalid signatures due to computational integrity failures
Evidence from the diff
In sign_sighash_schnorr_and_yield(), after cx_ecschnorr_sign() produces a BIP-340 Schnorr signature, the code now calls cx_ecschnorr_verify() with the tweaked public key, BIP-0340 scheme, SHA-256, the 32-byte sighash, and the produced signature. If verification fails, it sends SW_BAD_STATE and returns false. This implements the optional BIP-340 recommendation to verify signatures before release, catching incorrect/faulty computations.
Changed components
src/handler/sign_psbt/sign_input.cSchnorr signature generation path in PSBT signingInspect captured patch +13 / −0
### src/handler/sign_psbt/sign_input.c
@@ -208,6 +208,19 @@ bool __attribute__((noinline)) sign_sighash_schnorr_and_yield(dispatcher_context
return false;
}
+ // As recommended in BIP-340, verify the signature before releasing it, refusing to produce
+ // an invalid signature that is the result of an incorrect/faulty computation
+ if (!cx_ecschnorr_verify(&pubkey_tweaked,
+ CX_ECSCHNORR_BIP0340,
+ CX_SHA256,
+ sighash,
+ 32,
+ sig,
+ sig_len)) {
+ SEND_SW(dc, SW_BAD_STATE);
+ return false;
+ }
+
// only append the sighash type byte if it is non-zero
if (sighash_byte != 0x00) {
// only add the sighash byte if not 0Why this scored 47/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.