sign_psbt: pass elements flag to signature hash generation for liquid
What changed, and why it matters
This commit fixes how Blockstream Jade signs Liquid (Elements) Taproot transactions. Previously, the device used Bitcoin-style signature hashing for all networks, which is incorrect for Liquid Taproot. The fix passes a special 'Elements' flag when signing on Liquid so the signature hash matches Liquid's rules. Without this, signatures produced for Liquid Taproot transactions would be invalid or could potentially be produced using the wrong cryptographic formula, which in hardware wallets can sometimes lead to security issues like key leakage or signature-forgery attacks.
Treat as a correctness fix with possible security implications for Liquid Taproot users. Users signing Liquid Taproot transactions with affected firmware should upgrade. A security review should verify whether the prior behavior could lead to nonce reuse, weak signatures, or key leakage; if so, the project should issue a security advisory and coordinate CVE assignment.
Security signals we found
Cryptographic signing parameter changed for a specific network
Taproot/Elements-specific hashing and tweaking path activated
Commit message explicitly frames change as required for correctness
No explicit CVE, advisory, or researcher attribution in commit or supplied references
Patch is minimal (+2/-1) and targeted
Evidence from the diff
The change modifies main/process/sign_psbt.c in the sign_psbt function. It replaces the hardcoded EC_FLAG_GRIND_R flag passed to wally_psbt_sign_input_bip32 with a computed sign_flags that ORs EC_FLAG_GRIND_R with EC_FLAG_ELEMENTS when for_liquid is true. libwally-core uses EC_FLAG_ELEMENTS to select Elements/Liquid-specific signature hash generation and tweaking logic, which differs from Bitcoin for Taproot inputs. The commit message states this is required for Liquid Taproot correctness.
Changed components
main/process/sign_psbt.cwally_psbt_sign_input_bip32 call pathLiquid/Elements Taproot PSBT signingInspect captured patch +2 / −1
diff --git a/main/process/sign_psbt.c b/main/process/sign_psbt.c
index 140a709..6b938e4 100644
--- a/main/process/sign_psbt.c
+++ b/main/process/sign_psbt.c
@@ -988,8 +988,9 @@ int sign_psbt(jade_process_t* process, CborValue* params, const network_t networ
key_iter_input_begin(psbt, index, &iter);
while (iter.is_valid) {
// Sign the input with this key
+ const uint32_t sign_flags = EC_FLAG_GRIND_R | (for_liquid ? EC_FLAG_ELEMENTS : 0);
if (wally_psbt_sign_input_bip32(
- psbt, index, iter.key_index, txhash, sizeof(txhash), &iter.hdkey, EC_FLAG_GRIND_R)
+ psbt, index, iter.key_index, txhash, sizeof(txhash), &iter.hdkey, sign_flags)
!= WALLY_OK) {
*errmsg = "Failed to generate signature";
retval = CBOR_RPC_INTERNAL_ERROR;
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.