From 17fc097cbd237ce774656bbdec343611aa3a4885 Mon Sep 17 00:00:00 2001 From: scgbckbone Date: Fri, 6 Mar 2026 20:52:25 +0100 Subject: [PATCH 1/2] bip322 doc mainnet --- docs/proof-of-reserves-bip-322.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/proof-of-reserves-bip-322.md b/docs/proof-of-reserves-bip-322.md index 94fe42a8..4e77b338 100644 --- a/docs/proof-of-reserves-bip-322.md +++ b/docs/proof-of-reserves-bip-322.md @@ -44,7 +44,7 @@ Example screen text: ```text Proof of Reserves - Amount 0.20000000 XTN + Amount 0.20000000 BTC Message Hash: 11b5fe357842f5c368d2e3884d6a5ba577e3bc7cde132004f39b8c2a43a9cdec @@ -55,7 +55,7 @@ Proof of Reserves 21 inputs 1 output - 0.00000000 XTN + 0.00000000 BTC - OP_RETURN - null-data From 1e9338c550cef4aa159187983f81bdfe8818143c Mon Sep 17 00:00:00 2001 From: scgbckbone Date: Fri, 6 Mar 2026 22:52:45 +0100 Subject: [PATCH 2/2] testing: add BIP-322 POR signed with WIF Store test --- testing/bip322.py | 23 ++++++++++++----- testing/test_bip322.py | 58 ++++++++++++++++++++++++++++++++++++++++-- testing/test_wif.py | 3 --- 3 files changed, 72 insertions(+), 12 deletions(-) diff --git a/testing/bip322.py b/testing/bip322.py index 3152a738..32ed2165 100644 --- a/testing/bip322.py +++ b/testing/bip322.py @@ -7,7 +7,7 @@ from ckcc_protocol.protocol import MAX_TXN_LEN from psbt import BasicPSBT, BasicPSBTInput, BasicPSBTOutput from io import BytesIO from helpers import hash160, taptweak, str_to_path -from bip32 import BIP32Node +from bip32 import BIP32Node, PublicKey from constants import simulator_fixed_tprv, AF_P2WSH, AF_P2WSH_P2SH, AF_P2SH from ctransaction import CTransaction, COutPoint, CTxIn, CTxOut, uint256_from_str @@ -59,6 +59,7 @@ def bip322_txn(dev, pytestconfig, create_msg_file): sp = f"0/{i}" af = addr_fmt ia = input_amount + pubkey = None # public key try: if inp[0] is not None: af = inp[0] @@ -66,12 +67,20 @@ def bip322_txn(dev, pytestconfig, create_msg_file): sp = inp[1] if inp[2] is not None: ia = inp[2] + if inp[3] is not None: + pubkey = inp[3] except: pass - int_path = str_to_path(sp) - subkey = mk.subkey_for_path(sp) - sec = subkey.sec() + if pubkey: + int_path = [0] + sec = pubkey + else: + int_path = str_to_path(sp) + sec = mk.subkey_for_path(sp).sec() + + subkey = PublicKey.parse(sec) + assert len(sec) == 33, "expect compressed" if af == "p2tr": @@ -82,7 +91,7 @@ def bip322_txn(dev, pytestconfig, create_msg_file): elif af in ("p2wpkh", "p2sh-p2wpkh", "p2wpkh-p2sh"): psbt.inputs[i].bip32_paths[sec] = mfp + struct.pack(f'<{"I" * len(int_path)}', *int_path) - scr = bytes([0x00, 0x14]) + subkey.hash160() + scr = bytes([0x00, 0x14]) + subkey.h160() if af != "p2wpkh": # use classic p2wpkh (from above) as redeem script @@ -90,8 +99,8 @@ def bip322_txn(dev, pytestconfig, create_msg_file): scr = bytes([0xa9, 0x14]) + hash160(scr) + bytes([0x87]) elif af == "p2pkh": - psbt.inputs[i].bip32_paths[sec] = mfp + struct.pack('