Merge pull request #754 from Foundation-Devices/sft-8681-passport-core-sign-taproot-messages-with
What changed, and why it matters
This commit changes how the Passport hardware wallet signs Bitcoin Taproot text messages. Previously it used SIGHASH_DEFAULT (the Taproot default), but now it uses SIGHASH_ALL. The change is for compatibility: the commit message says Sparrow wallet only accepts SIGHASH_ALL for these signatures. This is a standards-compliance and interoperability fix, not a security vulnerability fix. The included tests were updated to expect the new signature format.
No security action required. Treat as a normal interoperability/standards-compliance change. Reviewers may want to confirm the SIGHASH_ALL test vector matches an independent BIP-322 implementation and that Sparrow compatibility is restored.
Security signals we found
Change in cryptographic signature hash type (SIGHASH_DEFAULT -> SIGHASH_ALL)
Comment explicitly references verifier compatibility and Sparrow wallet acceptance
Unit test asserts new signature encoding and verifies against an external test vector
No bounds, memory, or input validation changes observed
Evidence from the diff
The patch modifies sign_taproot_simple() in ports/stm32/boards/Passport/modules/bip322.py to pass SIGHASH_ALL to taproot_signature_hash() and taproot_sign_key() instead of SIGHASH_DEFAULT. BIP-322 permits SIGHASH_DEFAULT for P2TR key-path simple signatures, but the comment notes that every verifier must accept SIGHASH_ALL and that Sparrow only accepts SIGHASH_ALL. Unit tests were updated: the encoded witness length changed from 66 to 67 bytes, the compact-size prefix from 0x40 to 0x41, and the final byte is now checked to equal SIGHASH_ALL. A new SIGHASH_ALL digest test vector was added and the PSBT signing path comment was clarified to note that PSBT requests without an explicit sighash still use SIGHASH_DEFAULT.
Changed components
ports/stm32/boards/Passport/modules/bip322.pyports/stm32/boards/Passport/modules/tests/unit/bip322.pyInspect captured patch +22 / −17
### ports/stm32/boards/Passport/modules/bip322.py
@@ -79,8 +79,10 @@ def taproot_signature_hash(message, message_challenge, hash_type=SIGHASH_DEFAULT
def sign_taproot_simple(message, internal_pubkey, internal_seckey):
"""Create a textual BIP-322 simple signature for a P2TR key-path spend."""
message_challenge = output_script(internal_pubkey, None)
- sighash = taproot_signature_hash(message, message_challenge)
- signature = taproot_sign_key(None, internal_seckey, SIGHASH_DEFAULT, sighash)
+ # BIP-322 lets P2TR use SIGHASH_DEFAULT, but every verifier has to accept SIGHASH_ALL, and Sparrow only
+ # accepts SIGHASH_ALL.
+ sighash = taproot_signature_hash(message, message_challenge, SIGHASH_ALL)
+ signature = taproot_sign_key(None, internal_seckey, SIGHASH_ALL, sighash)
witness = ser_string_vector([signature])
encoded_witness = b2a_base64(witness).decode('ascii').strip()
### ports/stm32/boards/Passport/modules/tests/unit/bip322.py
@@ -129,27 +129,35 @@ def bip340_verify(pubkey, signature, digest):
signature = sign_taproot_simple(message, internal_pubkey, private_key)
assert signature.startswith('smp')
+# Text signatures are SIGHASH_ALL, which every verifier must accept and the only type Sparrow accepts.
witness = a2b_base64(signature[3:])
-assert len(witness) == 66
-assert witness[:2] == b'\x01\x40'
+assert len(witness) == 67
+assert witness[:2] == b'\x01\x41'
+assert witness[66] == SIGHASH_ALL
-# The encoding checks above pass for any 64-byte signature, so verify the
+# SIGHASH_ALL changes the digest. The value comes from an implementation outside the firmware, checked against
+# the BIP-322 SIGHASH_DEFAULT vector above.
+sighash = taproot_signature_hash(message, message_challenge)
+sighash_all = taproot_signature_hash(message, message_challenge, SIGHASH_ALL)
+assert sighash_all == a2b_hex('f4ee2b0fa213cd562b51dcaa94cae4d16d39256ee52a754779222eaddf4184f3')
+
+# The encoding checks above pass for any 65-byte signature, so verify the
# signature cryptographically as well.
-schnorr_signature = witness[2:]
+schnorr_signature = witness[2:66]
output_pubkey = message_challenge[2:]
-sighash = taproot_signature_hash(message, message_challenge)
-assert bip340_verify(output_pubkey, schnorr_signature, sighash)
+assert bip340_verify(output_pubkey, schnorr_signature, sighash_all)
+assert not bip340_verify(output_pubkey, schnorr_signature, sighash)
# It must bind to the message.
-tampered_sighash = taproot_signature_hash(b'Tampered message', message_challenge)
-assert tampered_sighash != sighash
+tampered_sighash = taproot_signature_hash(b'Tampered message', message_challenge, SIGHASH_ALL)
+assert tampered_sighash != sighash_all
assert not bip340_verify(output_pubkey, schnorr_signature, tampered_sighash)
# And it must be made with the tweaked output key, not the internal key. Both
# are valid x-only keys, so only verification distinguishes them.
assert internal_pubkey != output_pubkey
-assert not bip340_verify(internal_pubkey, schnorr_signature, sighash)
+assert not bip340_verify(internal_pubkey, schnorr_signature, sighash_all)
# BIP-322 requests sent as a PSBT, built the way Sparrow builds them: the to_sign transaction as a PSBTv0,
@@ -221,11 +229,6 @@ def rejected(psbt, error):
assert request.path == PATH
assert request.hash_type == SIGHASH_ALL
-# SIGHASH_ALL changes the digest. The value comes from an implementation outside the firmware, checked against
-# the BIP-322 SIGHASH_DEFAULT vector above.
-sighash_all = taproot_signature_hash(message, message_challenge, SIGHASH_ALL)
-assert sighash_all == a2b_hex('f4ee2b0fa213cd562b51dcaa94cae4d16d39256ee52a754779222eaddf4184f3')
-
# Signing adds the key-path signature to the input and changes nothing else.
signed = read_maps(sign_taproot_request(request, internal_pubkey, private_key))
assert signed[0] == maps[0]
@@ -239,7 +242,7 @@ def rejected(psbt, error):
assert not bip340_verify(output_pubkey, tap_key_sig[:64], sighash)
rejected(serialize(signed), 'This message request is already signed.')
-# Without a sighash type, the signature is SIGHASH_DEFAULT, like a signature made from a text message.
+# Without a sighash type, a request is signed with SIGHASH_DEFAULT, the Taproot default for PSBTs.
global_map, input_map, output_map = request_maps(message, message_challenge)
del input_map[1]
request = read_signing_request(serialize((global_map, input_map, output_map)))Why this scored 22/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.