Use BIP-340 synthetic nonces for Schnorr signatures
What changed, and why it matters
This commit changes how the Ledger Bitcoin app creates Schnorr (BIP-340) signatures. Previously it relied entirely on the device's hardware random number generator (TRNG) for the signing nonce. Now it feeds TRNG output as auxiliary randomness into BIP-340's synthetic nonce derivation. This is a defensive hardening measure: even if the TRNG were to fail or produce weak values, the nonce still depends uniquely on the private key and message, reducing the risk that two signatures leak the secret key.
No immediate action required. This is a security-hardening change. Users should ensure their device firmware/app is updated to a version containing this commit. Developers should verify that CX_RND_PROVIDED behavior matches BIP-340 specification on the target SDK/OS version and that cx_get_random_bytes failures are handled correctly (the added error check appears to do this).
Security signals we found
Change from TRNG-only nonce generation to BIP-340 synthetic nonce derivation
Use of CX_RND_PROVIDED with aux_rand supplied by cx_get_random_bytes
Defensive hardening against RNG failure or nonce reuse in Schnorr signatures
Nonce now deterministically bound to private key and message via BIP-340 hashing
Evidence from the diff
The patch modifies sign_sighash_schnorr_and_yield() in src/handler/sign_psbt/sign_input.c. It replaces CX_RND_TRNG with CX_RND_PROVIDED for cx_ecschnorr_sign_no_throw(). Before signing, 32 random bytes are obtained via cx_get_random_bytes() and placed in the first 32 bytes of the signature buffer (sig), which the SDK uses as aux_rand. With CX_RND_PROVIDED, the SDK computes the BIP-340 synthetic nonce k = hash_BIP0340/nonce((d XOR hash_BIP0340/aux(aux_rand)) || P || m) mod n. This follows BIP-340’s recommended default signing algorithm and mitigates nonce-reuse risks from TRNG weaknesses.
Changed components
src/handler/sign_psbt/sign_input.cSchnorr signature generation for Bitcoin Taproot / BIP-340 transactionsInspect captured patch +10 / −1
### src/handler/sign_psbt/sign_input.c
@@ -173,8 +173,17 @@ bool __attribute__((noinline)) sign_sighash_schnorr_and_yield(dispatcher_context
break;
}
+ // BIP-340 default signing: the first 32 bytes of sig are the auxiliary randomness, and
+ // with CX_RND_PROVIDED the SDK derives the synthetic nonce
+ // k = hash_BIP0340/nonce((d XOR hash_BIP0340/aux(aux_rand)) || P || m) mod n.
+ // This makes sure nonces are unique per message even in the event of RNG failure.
+ if (cx_get_random_bytes(sig, 32) != CX_OK) {
+ error = true;
+ break;
+ }
+
err = cx_ecschnorr_sign_no_throw(&private_key,
- CX_ECSCHNORR_BIP0340 | CX_RND_TRNG,
+ CX_ECSCHNORR_BIP0340 | CX_RND_PROVIDED,
CX_SHA256,
sighash,
32,Why this scored 63/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.