upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/scripts/verify-utxo-proof.py
diff options
context:
space:
mode:
authorNsable-sh <nsable-sh@noreply.git.bitflash.network>2026-08-11 14:47:35 -0300
committerNsable-sh <nsable-sh@noreply.git.bitflash.network>2026-08-11 14:47:35 -0300
commitcaa6a9668fc2b2ed1192f7ebdc0b78621f45898d (patch)
treece72921d72611dab1aafb78521b68da0fd11383d /scripts/verify-utxo-proof.py
parent1839347459759fb3b23cc747ec4368b724fee008 (diff)
tools: address audit follow-ups
Diffstat (limited to 'scripts/verify-utxo-proof.py')
-rw-r--r--scripts/verify-utxo-proof.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/scripts/verify-utxo-proof.py b/scripts/verify-utxo-proof.py
index c29caa9..50d9356 100644
--- a/scripts/verify-utxo-proof.py
+++ b/scripts/verify-utxo-proof.py
@@ -10,8 +10,6 @@ from pathlib import Path
10import bitflash_chain as chain 10import bitflash_chain as chain
11 11
12SCHEMA = "bitflash-utxo-inclusion-proof-1" 12SCHEMA = "bitflash-utxo-inclusion-proof-1"
13LEAF_DOMAIN = "BTFUTXO1"
14NODE_DOMAIN = b"BTFNODE1|"
15 13
16 14
17def canonical_bytes(obj): 15def canonical_bytes(obj):
@@ -32,9 +30,9 @@ def verify(proof, expected_root=None):
32 commitment = proof.get("commitment", {}) 30 commitment = proof.get("commitment", {})
33 if commitment.get("algorithm") != "sorted-outpoint-merkle-sha256": 31 if commitment.get("algorithm") != "sorted-outpoint-merkle-sha256":
34 failures.append("unexpected commitment algorithm") 32 failures.append("unexpected commitment algorithm")
35 if commitment.get("leaf_domain") != LEAF_DOMAIN: 33 if commitment.get("leaf_domain") != chain.UTXO_LEAF_DOMAIN:
36 failures.append("unexpected leaf domain") 34 failures.append("unexpected leaf domain")
37 if commitment.get("node_domain") != "BTFNODE1": 35 if commitment.get("node_domain") != chain.UTXO_NODE_DOMAIN_TAG:
38 failures.append("unexpected node domain") 36 failures.append("unexpected node domain")
39 37
40 target = proof.get("target", {}) 38 target = proof.get("target", {})
@@ -64,9 +62,9 @@ def verify(proof, expected_root=None):
64 failures.append("bad sibling hash length at proof level %d" % i) 62 failures.append("bad sibling hash length at proof level %d" % i)
65 side = step.get("side") 63 side = step.get("side")
66 if side == "right": 64 if side == "right":
67 current = chain.sha256(NODE_DOMAIN + current + sibling) 65 current = chain.sha256(chain.UTXO_NODE_DOMAIN + current + sibling)
68 elif side == "left": 66 elif side == "left":
69 current = chain.sha256(NODE_DOMAIN + sibling + current) 67 current = chain.sha256(chain.UTXO_NODE_DOMAIN + sibling + current)
70 else: 68 else:
71 failures.append("bad sibling side at proof level %d" % i) 69 failures.append("bad sibling side at proof level %d" % i)
72 70