This commit is contained in:
scgbckbone 2026-02-25 02:00:54 +01:00 committed by doc-hex
parent ef2f35b1fb
commit 1176c83e34
3 changed files with 53 additions and 1 deletions

View File

@ -25,6 +25,10 @@ COLDCARD accepts specially crafted PSBT to sign BIP-322 Proof of Reserves
### POR Signing UX
After Coldcard recognizes BIP-322 POR PSBT it asks user to import human-readable message that was used to build
`to_spend` scriptSig. This message must hash exactly to message_hash, otherwise signing is not offered.
Read more [here](https://gist.github.com/orangesurf/0c1d0a31d3ebe7e48335a34d56788d4c)
```text
Proof of Reserves

View File

@ -302,7 +302,7 @@ class ApproveTransaction(UserAuthorizedAction):
if ch == KEY_CANCEL:
return
elif ch == "0":
msg = await ux_input_text("")
msg = await ux_input_text("", confirm_exit=False)
elif ch == KEY_NFC:
msg = await NFC.read_bip322_msg()
elif ch == KEY_QR:

View File

@ -523,4 +523,52 @@ def test_bip322_msg_import(msg, ins, way, bip322_txn, start_sign, end_sign, cap_
assert title == "OK TO SIGN?"
assert "Proof of Reserves" in story
def test_bip322_msg_import_fail(bip322_txn, start_sign, end_sign, cap_story, need_keypress,
press_select, OK, press_cancel, cap_menu, microsd_path, enter_complex):
msg = b"it's me!"
psbt, msg_challenge = bip322_txn([["p2wpkh", None, None]], msg=msg)
start_sign(psbt, finalize=True)
time.sleep(.1)
title, story = cap_story()
assert title == "BIP-322 MSG"
need_keypress("1") # SD
time.sleep(.1)
title, story = cap_story()
assert f"Press {OK} to approve message" in story
press_cancel() # refuse
time.sleep(.1)
assert "Ready To Sign" in cap_menu()
start_sign(psbt, finalize=True)
time.sleep(.1)
title, story = cap_story()
assert title == "BIP-322 MSG"
need_keypress("0") # manual input
# leave empty
press_cancel()
time.sleep(.1)
title, story = cap_story()
assert title == "Failure"
assert "need msg" in story
assert "Msg verification failed" in story
press_cancel()
start_sign(psbt, finalize=True)
time.sleep(.1)
title, story = cap_story()
assert title == "BIP-322 MSG"
need_keypress("0") # manual input
enter_complex("AAA", apply=False, b39pass=False) # msg wrong
time.sleep(.1)
title, story = cap_story()
assert title == "Failure"
assert "Msg verification failed" in story
assert "hash verification failed" in story
press_cancel()
# EOF