sign_psbt: assert script taprootyness matches our deduced signature type
What changed, and why it matters
This commit adds a safety check in the code that signs Bitcoin transactions. It ensures that when the wallet decides to produce a Taproot-style signature, the script being spent actually looks like a Taproot script, and vice versa. Without this check, a mismatch between the script type and signature type could potentially lead to incorrect signatures or unexpected behavior when signing transactions.
Treat as a hardening patch. Review whether the mismatch condition was reachable before the patch and whether any prior firmware version could produce an invalid or unsafe signature. If a security-reachable condition existed, consider a security advisory and firmware update.
Security signals we found
Defensive assertion added to enforce type consistency between script flavour and signature type
Taproot (P2TR) signing path involved
No accompanying test, regression case, or advisory text in commit
No CVE or vendor security disclosure referenced
Evidence from the diff
In main/process/sign_psbt.c, a JADE_ASSERT was added to enforce that the detected Taproot flag from get_script_flavour() matches the signature type (WALLY_SIGTYPE_SW_V1) selected for signing. This is a defensive consistency check during PSBT signing. The patch is one line and does not include a test, changelog, or explanation of what bug or attack scenario it prevents.
Changed components
main/process/sign_psbt.cPSBT signing flowTaproot / SegWit v1 signature generationInspect captured patch +1 / −0
diff --git a/main/process/sign_psbt.c b/main/process/sign_psbt.c
index 4cae064..88d1b22 100644
--- a/main/process/sign_psbt.c
+++ b/main/process/sign_psbt.c
@@ -753,6 +753,7 @@ int sign_psbt(const network_t network_id, struct wally_psbt* psbt, const char**
if (utxo->script && utxo->script_len) {
bool is_p2tr = false;
const script_flavour_t script_flavour = get_script_flavour(utxo->script, utxo->script_len, &is_p2tr);
+ JADE_ASSERT(is_p2tr == (sig_type == WALLY_SIGTYPE_SW_V1));
update_aggregate_scripts_flavour(script_flavour, &aggregate_inputs_scripts_flavour);
}
Why this scored 57/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.