Hash commitments and authenticated state
On this page
- Hash registry
- Branch MAST: unordered membership
- Indexed binary Merkle tree: transaction inputs, outputs, and coins (IndexedTreeRoot)
- Block transaction commitment: prefix-sharded Merklix Subtree A and top-level CoinbaseLeaf
- UTXO map: prefix-compressed binary tree
- Full state root and canonical MonetaryState (56B at Genesis, 88B at $h \ge 1$)
- Header History Merkle Tree (HeaderHistoryFrontier and history_root)
- Genesis and monetary indexing
- Coinbase and root dependency order
- Acceptance obligations
- References
Decision packet P02. Recommended candidate, not frozen or implemented. Refines D02/D13 and the commitment part of D14. Defines separate branch, ordered-vector and keyed-map commitments rather than one ambiguous “Merklix” API.
Hash registry
B3 is unkeyed BLAKE3 with exactly 32 output bytes. H_name(x)=B3(ASCII(tag) || 00 || x). All tags are case-sensitive ASCII strings below. Prefix bytes such as 00 in node encodings are bytes, not characters. Integer encodings are P01 little-endian; where two hashes are ordered they are read as unsigned little-endian integers. No hash function accepts arbitrary C++ struct memory.
| name | Exact tag |
|---|---|
| branch | Lotus/v2/branch |
| txid | Lotus/v2/txid |
| txhash | Lotus/v2/txhash |
| sighash | Lotus/v2/sighash |
| inputcore | Lotus/v2/inputcore |
| inputfull | Lotus/v2/inputfull |
| coinentry | Lotus/v2/coinentry |
| owninput | Lotus/v2/owninput |
| output | Lotus/v2/output |
| txroot | Lotus/v2/txroot |
| utxo | Lotus/v2/utxo |
| state | Lotus/v2/state |
| contractstate | Lotus/v2/contractstate |
| headerbody | Lotus/v2/header/body |
| headerwork | Lotus/v2/header/work |
| header/history | Lotus/v2/header/history |
| blockid | Lotus/v2/blockid |
| merkleidx | Lotus/v2/merkleidx |
The BLAKE3 primitive follows its specification; application tags and tree rules are Lotus choices. Because H_name(x) is ordinary unkeyed BLAKE3 over the ASCII prefix tag || 0x00 || x (C08), any script can compute and verify any domain-tagged hash (H_txid, H_inputcore, H_output, H_coinentry, H_merkleidx, etc.) in three instructions (<"Lotus/v2/...\x00"> SWAP CAT BLAKE3) without needing a dedicated opcode per domain tag. P04 specifies a recursive BlockID/PoW candidate and its additional headerbody/headerwork domains; final choice remains D12. Hash collision resistance is an assumption, not a theorem about these tags.
Branch MAST: unordered membership
Leaf(script) = H_branch(00 || Bytes(script))
BranchNode(a,b) = H_branch(01 || min(a,b) || max(a,b))
LegacyBridgeLeaf(coin_script, witness_script)
= H_branch(03 || Bytes(coin_script) || Bytes(witness_script))
LegacyBridgeLeaf is never a member of a branch tree. It is only the selector leaf of an input spending a legacy coin (P01 "Spending a legacy coin"), and its prefix 03 keeps it distinct from every leaf and node preimage.
min and max compare the two 32-byte hashes as unsigned little-endian 256-bit integers: the last byte is the most significant. This is the same reading of a hash that P04 uses to compare a BlockID with its target, and the byte order of every integer in the transaction format and the VM.
Spend and mint invocations use the same leaf function. Consensus therefore does not distinguish a mint script from a spend script: any leaf of a tree can be proven in either kind of invocation. A design that needs both must keep them in separate trees. A token's mint scripts form the tree whose root is the token ID; rules that must run on every spend form a second tree that appears on outputs as a branch, and the mint scripts name that second root as a constant. A mint script placed in a tree that outputs use as a required branch could be offered to satisfy that branch. Consume siblings bottom-up, hashing once per sibling. Empty sibling vector means root=Leaf(script). A proof only asserts membership; it has no direction bits, method index, hidden leaf-count claim or hidden uniqueness claim. Consensus limits proof depth; no unverified tree metadata enlarges that bound.
For reproducible wallet construction, recommend: sort distinct leaf hashes as unsigned little-endian integers, ascending; split a list of n>1 at the greatest power of two less than n; recursively build and sort each child pair at hashing. This construction is a wallet convention, not a property enforceable from a single proof. An owner may commit another finite binary tree. Duplicated leaves or alternative shapes provide no independent authorization and receive no accounting discount.
Storing data and Merkle roots in branches: three patterns
Apart from the optional 32-byte state_root of a HAS_STATE output (C05), contracts and protocols commit data or Merkle roots in branches and verify Merkle proofs against them (MERKLEROOT_SORTED, MERKLEROOT_INDEXED, LEAFHASH, NODEHASH) in three complementary ways:
- On a pruneable burn /
OP_RETURNoutput (flags = 0x02native or0x03token,paths = []): - Setting bit 1 (
0x02IS_BURN) requirespath_count == 0(paths = []) and1 <= branch_count <= 16pairwise distinct 32-byte entries inbranches(up to 512 bytes of commitment hashes, Merkle roots, or topic/data words). - 100% of
valueon anIS_BURNoutput is permanently burned (included inO_a, never claimable by miners as fees;value = 0is also valid), and validators never insertIS_BURNoutputs intoUtxoRoot(C17), so they consume zero UTXO memory forever. - Scripts in the creating transaction can inspect an
IS_BURNoutputjviaOUTPUTFLAGS(j),OUTPUTVALUE(j),OUTPUTTOKENID(j),OUTPUTBRANCHCOUNT(j), andOUTPUTBRANCH(j, k)—and can verify Merkle proofs againstOUTPUTBRANCH(j, k)usingMERKLEROOT_SORTEDorMERKLEROOT_INDEXED—makingIS_BURNoutputs ideal for Frank/Stamp topic broadcasts, burn-weighted votes, and verified on-chain data commitments. - As a dedicated unexecuted data branch on a spendable coin (
branches = [CodeRoot, StateMerkleRoot],paths = [[0]]): - Because
paths = [[0]]requires onlybranch[0](CodeRoot),branch[1](StateMerkleRoot) is never executed as a script—it acts as a direct 32-byte state or Merkle-root register on the coin (or up to 15 registersbranch[1..15]). - Methods in
CodeRootread the current root in $O(1)$ viaINPUTINDEX <1> UTXOBRANCH, verify or update leaves usingMERKLEROOT_INDEXEDorMERKLEROOT_SORTED, and require the successor outputjto carry the updated root atOUTPUTBRANCH(j, 1)whilebranch[0](CodeRoot) never changes. - Inside the executing branch tree itself (
BranchNode(DataLeaf, M), the data-leaf convention): - For the most compact 1-branch coin (45 bytes native / 77 bytes token,
branches = [root],paths = [[0]]), a contract places its state as one leaf beside the subtreeMof its methods: ``text DataLeaf(values) = Leaf(data_script(values)) # pushes of the values, then RETURN root = BranchNode(DataLeaf(values), M) # M = root of the methods subtree`` Mnever changes;rootchanges whenevervaluesdo. The data script ends inRETURNso that it can never be run as a method. The spender supplies the currentvaluesandMas witness arguments, and the method checksBranchNode(Leaf(data_script(values)), M) == BRANCHROOTusingLEAFHASHandNODEHASH, then requiresBranchNode(Leaf(data_script(new_values)), M)on the successor output withOUTPUTCONTINUESBRANCHorOUTPUTEXCLUSIVEBRANCH. The cost is two leaf hashes and two node hashes per spend, whatever the number of methods, and a method's membership proof is one sibling longer than it would be without state.
Patterns 2 and 3 are compiler/application conventions recorded in the contract's ABI; pattern 1 (IS_BURN (0x02/0x03)) has consensus-enforced path_count == 0 and UTXO pruning (C05, C09, C17).
Indexed binary Merkle tree: transaction inputs, outputs, and coins (IndexedTreeRoot)
Following Lotus v1's Malfix design (101-implement-malfix.patch), transaction inputs, outputs, and resolved coins are committed via a canonical bottom-up indexed binary Merkle tree (IndexedTreeRoot) so that smart contracts can prove any individual input or output of a parent/injected transaction (OUTPOINTTXID(i)) in $O(\log N)$ space using MERKLEROOT_INDEXED (0xc1, hash_alg = 0) without pushing the entire parent transaction onto the stack.
For a vector of $n \ge 0$ 32-byte leaf hashes L[0 .. n - 1]:
EmptyIndexedRoot = H_merkleidx(02)
IndexedNode(s, l, r) = H_merkleidx(01 || u16(s) || l || r)
Zero32 = 00^32
- Empty vector ($n == 0$):
IndexedTreeRoot([]) = EmptyIndexedRoot. - Single-element vector ($n == 1$):
IndexedTreeRoot([L[0]]) = L[0]directly (depth $k = 0$, zero siblings; a 1-input or 1-output vector performs zero interior tree node hashes beyond the leaf hash itself). - Multi-element vector ($n > 1$): Build bottom-up by layer $s = 0, 1, \dots, \lceil \log_2(n) \rceil - 1$, starting from
cur = L[0 .. n - 1]: - At layer $s$, let $m = \text{len}(\text{cur})$. If $m$ is odd, append
Zero32 = 0x00^32as the right sibling of the last element (cur[m] = Zero32, matching Lotus v1's CVE-2012-2459 mitigation rather than Bitcoin's vulnerable self-duplication). - Set
next[j] = IndexedNode(s, cur[2j], cur[2j + 1])for $0 \le j < \lceil m / 2 \rceil$, and advancecur = next. - After $k = \lceil \log_2(n) \rceil$ layers, return the single remaining 32-byte root
cur[0].
Because layer index $s$ runs bottom-up from $0$ (leaves) to $k - 1$ (root), for any leaf index idx in 0 .. n - 1, at step $s = 0 \dots k - 1$, bit $s$ of idx ((idx >> s) & 1) is 0 when the node is the left child (cur[2j]) and 1 when the node is the right child (cur[2j + 1]). Consequently, MERKLEROOT_INDEXED (0xc1, hash_alg = 0) verifies any leaf L[idx] against IndexedTreeRoot(L) in a single instruction (<L[idx]> <u16(idx)> <proof_bytes> <0> MERKLEROOT_INDEXED), while the outer transaction header in TxID (input_count:u16 and output_count:u16 in P01) binds the exact vector lengths.
Block transaction commitment: prefix-sharded Merklix Subtree A and top-level CoinbaseLeaf
Following the sharding architecture of Sharding Bitcoin Cash (September 6, 2018), scaling block construction, mempool acceptance, and transaction commitment across horizontal CPU cores and processes requires consistent key-prefix range partitioning rather than positional array-index splitting.
Let transaction $i$ ($0 \le i < n$) have identity pair (TxID_i, TxHash_i), with vtx[0] as the block's coinbase transaction and vtx[1 .. n - 1] as the block's non-coinbase transactions. All TxID_i in a block (or commitment vector) MUST be pairwise distinct. Define:
TxLeaf(TxID, TxHash) = H_txroot(00 || TxID || TxHash)
TxNode(d, l, r) = H_txroot(01 || u16(d) || l || r) # d=0..255
EmptyTxRoot = H_txroot(02)
Key bit d of TxID is bit(TxID, d) = (TxID[d//8] >> (d%8)) & 1 (the exact same 256-bit little-endian bit order as UtxoRoot). For a set of distinct (TxID, TxHash) non-coinbase entries inside the subtree at depth d (0 <= d <= 256), the single-leaf-collapsed Merklix subtree root tx_smt(entries, d) is:
- Empty subtree (
|entries| == 0):EmptyTxRoot. - Single-leaf subtree (
|entries| == 1):TxLeaf(TxID, TxHash)directly, regardless of depthd(all single-child levels fromdto256are collapsed). - Multi-entry subtree (
|entries| >= 2,0 <= d < 256): Partitionentriesbybit(TxID, d)intoleft(bit0) andright(bit1), and returnTxNode(d, tx_smt(left, d + 1), tx_smt(right, d + 1)).
The top-level block transaction commitment TxRoot(xs) is:
- Empty vector ($n == 0$, tool primitive only):
TxRoot([]) = EmptyTxRoot(a block with no coinbase is invalid). - Non-empty vector ($n \ge 1$): Let
CoinbaseLeaf = TxLeaf(TxID_0, TxHash_0)andSubtreeA = tx_smt(xs[1 .. n - 1], 0). Then: ``text TxRoot(xs) = H_txroot(03 || CoinbaseLeaf || SubtreeA)``text [ header.tx_root ] / \ [ CoinbaseLeaf ] [ Subtree A ] <-- 256-bit Merklix tree of vtx[1..n-1] keyed by TxID / \ [ Subtree B ] [ Subtree C ] (prefix 0...) (prefix 1...)``
Each leaf commits to both identities of its transaction (TxID first, then TxHash). TxHash fixes the complete witness bytes as the leaf value at key TxID, while TxID alone defines the 256-bit prefix path through Subtree A. Because Subtree A partitions strictly by the bits of TxID, any $2^k$ mempool/validation shards (where Shard $s \in [0, 2^k - 1]$ owns the $k$-bit TxID prefix $s$) can maintain their mempool subtrees and pre-compute (TxSubtreeRoot[s], fee_sum[s], cost_sum[s]) 100% independently with zero cross-shard count synchronization, and Subtree A is naturally ordered by ascending TxID (matching Canonical Transaction Ordering, CTOR, in block wire format vtx[1 .. n - 1] with two-phase outputs-then-inputs intra-block UTXO resolution per C12). On getblocktemplate, the coordinator aggregates the $2^k$ shard roots into Subtree A (32 bytes), constructs vtx[0], and combines CoinbaseLeaf with Subtree A in one single top-level hash ($O(1)$) without re-entering any shard.
Canonical transaction membership and absence proof
A transaction proof against TxRoot begins with a 1-byte selector is_coinbase:u8:
is_coinbase = 1(coinbase proof):01 || TxID_0:h32 || TxHash_0:h32 || SubtreeA:h32(97 bytes). The verifier computesCoinbaseLeaf = TxLeaf(TxID_0, TxHash_0)and checksH_txroot(03 || CoinbaseLeaf || SubtreeA) == TxRoot.is_coinbase = 0(non-coinbase Merklix proof inSubtree Aforquery_txid:h32): ``text 00 || CoinbaseLeaf:h32 || presence:u8 || [TxID:h32 || TxHash:h32 if presence in (1, 2)] || bitmap:32bytes || siblings`wherepresence(0= empty branch absence,1= membership withTxID == query_txid,2= prefix-collision absence with a single leafTxID != query_txidagreeing on bits0 .. k - 1),bitmap(32 bytes), andsiblings(popcount(bitmap)32-byte hashes ordered from depthk - 1down to0, none equal toEmptyTxRoot) reconstructSubtreeA. The terminal depth isk = max_set_bit(bitmap) + 1, ork = 0for an all-zero bitmap; trailing or truncated bytes reject.kis recoverable from the bitmap because the deepestTxNodeon the walk, at depthk - 1, has at least two entries below it, while the walk's side holds at most one (a single leaf or nothing), so its sibling at depthk - 1is neverEmptyTxRootand bitk - 1is always set. Reconstruction usesTxLeaf,TxNode, andEmptyTxRoot: for each depthd = k - 1down to0,sib = EmptyTxRootif bitdofbitmapis0or the next hash fromsiblingsif it is1, andacc = TxNode(d, acc, sib)whenbit(query_txid, d) == 0orTxNode(d, sib, acc)when it is1, starting fromacc = EmptyTxRoot(presence = 0) or the proved leaf (presence in (1, 2)).Subtree Ais not prefix-compressed: it keeps aTxNodeat every depth from the root down to each leaf's deepest split, withEmptyTxRootsiblings at depths where only one side is populated. Honest transaction IDs are uniformly random, so those runs are short (about $\log_2 n$ levels for $n$ transactions). A party can grind transaction IDs to sharekleading bits with another, at about $2^k$ hash attempts per transaction; this lengthens only the paths of the transactions involved, and never beyond 256 levels. The verifier then checksH_txroot(03 || CoinbaseLeaf || SubtreeA) == TxRoot`.
UTXO map: prefix-compressed binary tree
Use a 256-bit keyed binary tree with shared-prefix compression as the normative UtxoRoot algorithm: an interior node exists only where two non-empty subtrees split, a subtree of one entry is its leaf hash, and a node with one non-empty child is never formed. Updating or proving a key therefore hashes its leaf and one node per actual split on its path, about $\log_2 n + 1.3$ hashes for $n$ coins with random transaction IDs (about 23 at $3 \times 10^6$ coins, 28 at $10^8$, 31 at $10^9$), however long the prefix a key shares with its neighbours. This commitment is strictly for block headers, RPC queries, snapshot verification, and optional transport-layer ProvenTx relay packages—never a VM opcode (OP_UTXOPROOFVERIFY is rejected; see rationale).
Outpoint = txid:h32 || output_index:u32
OutpointKey(txid, output_index) = txid[0..28] || u32_le(u32_le(txid[28..32]) ^ output_index)
key = OutpointKey(txid, output_index)
Coin = Outpoint || Bytes(Output) || creation_height:u64
|| creation_parent_mtp:u64 || coinbase:u8
|| encoding_version:u8 || fee_per_output:u64 || expiration_height:u64
UtxoLeaf(key,coin) = H_utxo(00 || key || Bytes(Coin))
UtxoNode(d,P,l,r) = H_utxo(03 || u16(d) || P || l || r) # d=0..255
EmptyRoot = H_utxo(02)
Bytes(x) is the shortest CompactSize of len(x) followed by x, so the leaf hashes the Coin record's own length prefix, and the record holds its Output's. There is one Coin encoding, and every field is always present: encoding_version is 2; fee_per_output is the creating transaction's native fee (native inputs less native outputs, burns included) divided by its number of spendable outputs, rounded down, and 0 for a coinbase coin; expiration_height is creation_height + lifespan, saturating at $2^{64} - 1$, where lifespan is UTXO_MAX_LIFESPAN_BLOCKS = 21,024,000 for a coinbase coin and otherwise min(21,024,000, UTXO_MIN_LIFESPAN_BLOCKS + fee_per_output / UTXO_RENT_ATOMS_PER_BLOCK) with UTXO_MIN_LIFESPAN_BLOCKS = 131,400 and UTXO_RENT_ATOMS_PER_BLOCK = 1. Block connection computes fee_per_output and expiration_height when it creates the coin, and they never change. A record is canonical only if it decodes completely, coinbase is 0 or 1, encoding_version is 2, expiration_height is nonzero, and it re-encodes to the same bytes. A decoder does not recompute expiration_height (the minimum lifespan is a network parameter); a record received with a proof is authenticated by its leaf. This is the encoding EncodeCoin produces and DecodeCoinBytes accepts (src/lotus_v2/sparse_state.cpp), and the reference model's coin.py. The shared vector in both test suites is the 116-byte Coin for outpoint 00..1f:5, value 1000 on one branch of 11 bytes, height 7, parent MTP 1234, not a coinbase, fee_per_output = 250,000 (so expiration_height = 381,407):
000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f 05000000
2d 00e803000000000000 01 1111111111111111111111111111111111111111111111111111111111111111 01 01 00
0700000000000000 d204000000000000 00 02 90d0030000000000 dfd1050000000000
UtxoLeaf = 2fd68aeaeea74d4a0be91d2efc702dcf69e0a008e358c04a635ca19115f144b3
Preserving the first 28 bytes (224 bits) of txid and XORing the trailing 32-bit little-endian word txid[28..32] with output_index keeps all outputs of a single transaction co-located under the same 224-bit prefix in UtxoRoot, on the same horizontal shard as txid in Subtree A, and adjacent in B+Tree storage (dbi_coins and dbi_smt_nodes), while guaranteeing distinct 256-bit keys for distinct output_index values of the same txid. Under prefix compression this co-location costs nothing: the outputs of one transaction share their 224-bit prefix without a hashed node at each of its levels.
Key bit d is bit(key, d) = (key[d//8] >> (d%8)) & 1: bit d of the key read as an unsigned little-endian 256-bit integer, least significant bit first, in keeping with the byte-order convention used everywhere else. prefix(key, d) is the 32-byte value whose bits 0 .. d - 1 are those of key and whose bits d .. 255 are zero. For a set of distinct (key, coin) entries, the subtree root smt(entries) is:
- Empty set (
|entries| == 0):EmptyRoot. - Single entry (
|entries| == 1):UtxoLeaf(key, coin). - Two or more entries: Let
dbe the lowest bit index at which the entries' keys are not all equal (0 <= d < 256), andP = prefix(key, d)for any of their keys (all agree on bits0 .. d - 1). Partitionentriesbybit(key, d)intoleft(bit0) andright(bit1), both non-empty, and returnUtxoNode(d, P, smt(left), smt(right)).
UtxoRoot is smt(all_entries). Its top node's d is greater than 0 when every key shares bit 0. Domain byte 01 is not used by UtxoRoot. Only spendable outputs ((flags & 0x02) == 0) are inserted into UtxoRoot; burn/commitment outputs ((flags & 0x02) != 0, which have path_count == 0) are pruned at transaction application and never enter UtxoRoot (C17). Coin's outpoint must derive its key, coinbase must be 0 or 1, flags must not include IS_BURN (so 0x00, 0x01, 0x04 or 0x05), and its output must satisfy spendable output well-formedness (including MAX_OUTPUT_BRANCHES = 16 and MAX_OUTPUT_PATHS = 16, which bounds every native Coin record to $\le 885\text{ bytes}$, or 917 with HAS_STATE). A coin carried over from a legacy output instead holds Bytes(LegacyCoinOutput) with LegacyCoinOutput = 80 || value:u64 || Bytes(scriptPubKey) and a script of at most 10,000 bytes: 1 + 8 + 3 + 10,000 = 10,012 output bytes, so 36 + 3 + 10,012 + 34 = 10,085 bytes, which is MAX_COIN_BYTES. A record is told apart by the first byte of its output: 80 is a LegacyCoinOutput, any other byte a V2 Output. P01 "Spending a legacy coin" gives that encoding's canonical form, its role in CoinEntry and OwnInputHash, and the only scripts and witnesses that spend it. Height/time and coinbase flag are consensus metadata, not database hints. Inserting a different outpoint at an occupied key rejects; never overwrite or merge such entries.
The map root is independent of insertion order. Deleting an entry removes its leaf; a node left with one non-empty child is removed, and that child (a leaf, or a node with its own d and P) takes its place unchanged. Duplicate-key snapshot entries reject even when identical. Pre/post roots alone do not establish that the intervening transaction set was valid.
Canonical membership and absence proof
For a queried Outpoint = txid:h32 || output_index:u32 with query_key = OutpointKey(txid, output_index), encode:
presence:u8 || [Bytes(Coin) if presence in (1, 2)]
|| [u16(d_t) || P_t:32bytes || l_t:h32 || r_t:h32 if presence == 3]
|| bitmap:32bytes || siblings
Following query_key from the root visits nodes at strictly increasing split depths, taking the child selected by bit(query_key, d) at each, until it reaches a leaf, or a node whose prefix disagrees with query_key below its split depth, or (only for an empty map) EmptyRoot. Therefore:
- Bit
dofbitmap(0 <= d <= 255, indexed least-significant-bit first within byted//8) is1iff the walk passed through a node with split depthdand continued into one of its children. Only the nodes above the terminal are in the bitmap: the terminal leaf, or the terminal node ofpresence = 3, never sets a bit, so its depthd_tis notk - 1. Every node passed through has two non-empty children, so each contributes one sibling, neverEmptyRoot. k = 0ifbitmapis all zeros, andk = max_set_bit(bitmap) + 1otherwise.siblingscontains exactlypopcount(bitmap)32-byte hashes, ordered from the highest set bit down to the lowest (bottom-up from the terminal to the root). An explicitly suppliedEmptyRootinsiblings, or any trailing/truncated bytes, is noncanonical and rejects.
presence is 0, 1, 2, or 3, determining the terminal hash acc:
presence = 1(membership):Coin.OutpointMUST equal the queriedOutpoint, andacc = UtxoLeaf(query_key, Coin).presence = 0(empty map):bitmapMUST be all zeros, noCoinis serialized, andacc = EmptyRoot. A non-empty map has no empty subtree on any walk, so absence there is shown bypresence = 2or3.presence = 2(absence by another single leaf):Coin.OutpointMUST differ from the queriedOutpoint,other_key = OutpointKey(Coin.txid, Coin.output_index)MUST agree withquery_keyon all bits0 .. k - 1, andacc = UtxoLeaf(other_key, Coin).presence = 3(absence by a diverging node): The terminal node is given as(d_t, P_t, l_t, r_t). It MUST satisfyk <= d_t < 256,P_thas every bit at or aboved_tzero,P_tagrees withquery_keyon all bits0 .. k - 1and differs from it at some bit ink .. d_t - 1, and neitherl_tnorr_tisEmptyRoot. Thenacc = UtxoNode(d_t, P_t, l_t, r_t).
For each set bit d of bitmap, from the highest down to the lowest, consume the next hash sib from siblings and set acc = UtxoNode(d, prefix(query_key, d), acc, sib) when bit(query_key, d) == 0, or UtxoNode(d, prefix(query_key, d), sib, acc) when bit(query_key, d) == 1. Unset bits contribute no hash. Finally require acc == UtxoRoot. Every hash field (P_t, l_t, r_t, each sibling, and the expected root) is exactly 32 bytes; the node preimage is a fixed-width concatenation, so this is what prevents re-partitioning bytes between neighbouring fields.
Two of these rules carry soundness. That a presence = 3 node's prefix P_t differs from query_key somewhere in k .. d_t - 1 is what makes it an absence proof: without it, a member's proof cut short after any split, ending at the real node below with its true (d_t, P_t, l_t, r_t), folds to the true root and would show the member absent. That the Coin.Outpoint equals (presence = 1) or differs from (presence = 2) the queried outpoint is the other. The remaining rules enforce canonical form only: a proof that breaks them folds to a root of no well-formed tree, so the hash binding already rejects it against a real root, and the rule makes every accepted proof the unique canonical one. These are: no EmptyRoot sibling or terminal child; an all-zero bitmap for presence = 0; a terminal leaf or P_t agreeing with query_key below k; P_t having no bit at or above d_t; and k <= d_t, which the divergence rule already implies.
Verification performs one node hash per set bit of bitmap, plus one leaf hash (presence in (1, 2)) or node hash (presence = 3). For random transaction IDs that averages about $\log_2 n + 1.3$: about 28 hashes at $10^8$ coins. A proof is then about 1 to 1.8 KB: 27 siblings (864 bytes), the bitmap (32 bytes), and the Coin (up to 885 bytes). Shape can raise it. The outputs a transaction keeps unspent split from one another below their shared 224-bit prefix, so clustered indices (for example a transaction's surviving outputs 0, 1, 2, 4, ..., 128) add up to about $\log_2(\text{outputs})$ splits to each of their paths, and transaction IDs ground to share leading bits add one split per shared bit. The bound is 256 splits on any path, so 257 hashes and 256 siblings. Fee and resource calibration must use the worst permitted shapes, not the average.
Absence (presence = 0, 2 or 3) proves that the queried outpoint has no coin at UtxoRoot, under the hash assumptions. It does not show that query_key is unused: another outpoint can have the same key, because (T', i'), with T' being T with its last 32-bit word XORed with w and i' = i ^ w, has the key of (T, i). Such a proof ends at that coin's leaf with presence = 2 and k up to 256. It also does not prove that an outpoint was never created, or spent, at another root. Multiproofs and snapshot range proofs may be designed later as transport/RPC encodings reproducing the same root.
Candidate input-proof relay package (not consensus)
A wallet may relay a transaction together with its coins and their membership proofs, so that a node holding recent headers and recent block deltas can validate it without a database lookup. The package is transport only: none of it enters TxID, TxHash, the signature message or a block, so it can change without a consensus change.
ProvenTx = Tx || anchor:h32 || UtxoRoot:h32 || Bytes(MonetaryState)
|| Vec(CoinProof)
CoinProof = Bytes(Coin) || bitmap:32bytes || siblings
CoinProof is the membership proof above with presence fixed at 1 and its byte omitted. There is exactly one per spend input, in input order; mint and coinbase inputs have none. anchor is a BlockID. The envelope fields are those of the full state root below, with height taken from the anchor header.
A node accepts the package only if: the anchor is on its best chain and at most PROOF_WINDOW blocks behind the tip (a node policy value, not chosen here); the envelope reproduces the anchor header's state_root; each Coin's Outpoint equals its input's outpoint and its proof reconstructs UtxoRoot; and no proved outpoint is spent by a block after the anchor or by a conflicting mempool transaction. The node must therefore retain, in memory, the outpoints spent and coins created by the last PROOF_WINDOW blocks. An input whose coin was created after the anchor, or by an unconfirmed transaction, is resolved from that retained data and its CoinProof slot is replaced by a zero-length marker to be specified with the encoding. Ordinary validation then runs on the supplied coins; creation_height, creation_parent_mtp and coinbase come from the proved Coin.
A TxID-based proof is not a substitute: a TxID with its transaction-tree path and output-tree path shows only that an output was created in some block, not that it remains unspent at the current tip.
Limits of this candidate. Proof size is about one sibling per doubling of the coin set (about 27 siblings at 10^8 coins, 1 to 1.8 KB per input with the Coin). A proof expires when its anchor leaves the window; any state-holding node can reissue it and need not be trusted. Checking a block's new state_root without state additionally needs the paths of every key the block inserts; these are absence proofs (presence 2 or 3) for each inserted key against the parent root, from which the verifier rebuilds the new root. All outputs of a transaction share a 224-bit txid prefix and are co-located on the shard owning that prefix; the levels of that prefix where no other coin's key splits off contain no node, so a transaction's outputs add hashed nodes only where they split from one another or from other coins. Block producers need the coin set or a complete set of proofs.
Full state root and canonical MonetaryState (56B at Genesis, 88B at $h \ge 1$)
A UTXO root alone omits the protocol's stateful issuance, dynamic fee-burn recurrences, and historical header accumulator (P05, P06, Header History Tree). Commit a versioned state envelope:
CoreMonetaryState = bootstrap_reserve:u64 # R_n (remaining unissued bootstrap atoms, P06)
|| tail_subsidy:u64 # T_n (current adaptive tail subsidy atoms, P06)
|| prev_work:u256 # W_{n-1} (32-byte little-endian unsigned per-block work, P04/P06)
|| ema_block_cost:u64 # E_n (rolling integer EMA of block cost units, P05)
MonetaryState(h) = CoreMonetaryState (56 bytes at Genesis h = 0, where history_root == 0x00^32)
| CoreMonetaryState || history_root:h32 (88 bytes at every post-genesis height h >= 1)
StateRoot = H_state(00 || ChainID || height:u64
|| UtxoRoot:h32 || Bytes(MonetaryState(h)))
CoreMonetaryState is a canonical fixed-width 56-byte record (8 + 8 + 32 + 8 = 56 bytes). At Genesis ($h = 0$, count == 0, history_root == 0x00^32), MonetaryState is 56 bytes (Bytes(MonetaryState) = 0x38 || CoreMonetaryState, making the StateRoot preimage 130 bytes after the domain tag). At every post-genesis block ($h \ge 1$, count = h >= 1), the non-zero 32-byte history_root (HeaderHistoryRoot over blocks $0 \dots h - 1$) is appended, making MonetaryState 88 bytes (Bytes(MonetaryState) = 0x58 || CoreMonetaryState || history_root, and the StateRoot preimage 162 bytes after the domain tag). It retains bootstrap/EMA continuation state, checked tail/work redundancy, and the authenticated header history root (D11 uses Avalanche coordination policy, so no faucet or treasury state exists):
bootstrap_reserve:u64($R_n$): remaining unissued bootstrap reserve in native atoms; issuance step $n$ emits $B_n = \max(1, R_n \gg k_{\text{boot}})$ when $R_n > 0$ (or $0$ when $R_n = 0$) and updates $R_{n+1} = R_n - B_n$ (P06).tail_subsidy:u64($T_n$), checked cache ofF(authenticated_parent_work): issuance step $n$'s adaptive tail subsidy in native atoms (total issuance step $n$ subsidy entitlement is $S_n = B_n + T_n$); after accepting issuance step $n$ with per-block work $W_n$, updates to $T_{n+1} = \text{isqrt}(\lfloor T_g^2 W_n / W_g \rfloor)$, with no floor or ceiling (P06; a tail that does not fitu64is an open item there).prev_work:u256($W_{n-1}$), checked against the authenticated parent target: 32-byte unsigned little-endian per-block chainwork of the parent block (initialized at genesis to $W_{-1} > 0$ from the genesis target, updated to $W'_n = W_n$ after issuance step $n$).ema_block_cost:u64($E_n$): rolling integer exponential moving average of whole-block frozen accounting cost units $C_{\text{block}}$, updated after issuance step $n$ via $E_{n+1} = E_n - (E_n \gg w) + (C_{\text{block}} \gg w)$ and used to enforce issuance step $n$'s required fee-burn floor (P05).
The header's former hashUtxoMerklixRoot is therefore renamed state_root. RPCs must expose both the 56-byte MonetaryState envelope and UTXO proofs so clients can connect a coin proof to the header's state_root. height must match the validated block context.
Header ancestry supplies validated time/target context; a standalone UTXO snapshot does not. Snapshot admission must check the envelope, unique entries, canonical Coin encodings, root reconstruction, the MonetaryState record and selected chain context, and clearly state which historical transitions were actually verified. Retained undo data must restore every field of the prior MonetaryState envelope on disconnect.
Header History Merkle Tree (HeaderHistoryFrontier and history_root)
So that light clients, bridges, and FastSync / Snapshot verifiers can authenticate any historical block header at height $h < H$ against the current block header at height $H$ in $O(\log H)$ space and time, every post-genesis block ($H \ge 1$) commits to history_root inside MonetaryState: the root of an append-only binary Merkle mountain / carry-chain frontier over all prior canonical block hashes $(0, \text{BlockID}_0), (1, \text{BlockID}_1), \dots, (H-1, \text{BlockID}_{H-1})$.
The header history tree specification defines the leaf, internal-node and count-binding hashes, the frontier and its append, the root fold and the inclusion-proof check (its §3). It is the only definition; this section does not restate it. In particular, history_root = HeaderCountBinding(ChainID, count, tree_root) binds the leaf count, and genesis (count == 0) has the null root, which MonetaryStateHash omits.
Genesis and monetary indexing
Monetary equations use issuance-step index n >= 0, not header height: step n is block height n + 1. Genesis (height 0) initializes and commits (R_0, T_0, W_-1, E_0) unchanged. Here W_-1 is genesis target work. Genesis does not run bootstrap decay, tail adjustment, EMA update or recurring fee deduction. Its coinbase has zero total native value; no genesis endowment or treasury allocation exists. Its exact output/commitment bytes remain a genesis-manifest input. Ordinary C17 output insertion/pruning still applies, including for zero-valued outputs.
Height 1 executes step 0 using the genesis state: B_0 = max(1, R_0 >> k_boot) when R_0 > 0, S_0 = B_0 + T_0, then commits (R_1, T_1, W_0, E_1) with height 1 in StateRoot. Height 2 executes step 1. In general the header at height h commits (R_h, T_h, W_(h-1), E_h) after initialization/transition. Thus the bootstrap conservation identity sums over steps n >= 0 (heights 1 onward), and the recommended initial 150,378 XPI (P06) is height 1's gross entitlement, before coinbase resource deductions. Disconnecting height 1 restores the exact genesis state. All target/lock/header-height rules continue to use actual height; this notation changes none of those fields.
Coinbase and root dependency order
For non-genesis blocks ($h \ge 1$): insert parent block $h - 1$'s spendable coinbase outputs into the UTXO tree and apply block $h$'s non-coinbase transactions vtx[1 .. n - 1] in two-phase outputs-then-inputs CTOR order (C12, C17) → calculate resource charges and reduce the coinbase claim under P05 (C16, C25) → construct coinbase vtx[0] using parent ID/height and the parent's MonetaryState ($S_n = B_n + T_n$) → derive TxID/TxHash → evaluate transitions, total block cost $C_{\text{block}} = C_{\text{envelope}} + C(vtx[1..n-1]) + C(vtx[0])$, mandatory fee-burn floor against $E_n$, and the post-block 88-byte MonetaryState ($R_{n+1}, T_{n+1}, W_n, E_{n+1}, \text{HistoryRoot}_h$) → compute transaction/state roots → construct header → compute BlockID/PoW. Because block $h$'s own spendable coinbase outputs are inserted into UtxoRoot at height $h + 1$ (C17, delayed 1-block pipelining), UtxoRoot at height $h \ge 1$ is 100% invariant to block $h$'s coinbase transaction (enabling Snowstorm's $O(1)$ SnapBlock fast path), while the containing header hash is never embedded in its own coin records. Genesis (height = 0) has no prior block ($h - 1$) to pipeline from, so it uses zero parent (parent_id = 00^32), an explicitly initialized 56-byte MonetaryState ($R_0, T_0, W_{-1}, E_0$ with history_root == 00^32 omitted), and inserts every spendable output ((flags & 0x02) == 0) of Block 0's coinbase directly into the Genesis UtxoRoot (with creation_height = 0, creation_parent_mtp = 0, coinbase = 1, spendable after coinbase maturity C13), while any unspendable Genesis timestamp/headline message uses an IS_BURN (flags = 0x02, paths = []) output that is excluded from UtxoRoot.
Acceptance obligations
Pin test vectors for empty/one/two/odd transaction trees, every proof direction, empty/single-leaf/multi-leaf/deleted prefix-compressed state maps (including a top node with d > 0, outputs of one transaction splitting at depth 224 or deeper, and deletion leaving a node to replace its parent), all four proof presence modes (0, 1, 2, 3) and their rejections (presence 0 with a non-zero bitmap, presence 3 with d_t < k, a non-zero P_t bit at or above d_t, a P_t agreeing with query_key through d_t - 1, or an EmptyRoot child), same map built in different orders, coin metadata changes, 56-byte MonetaryState transitions and StateRoot envelope restoration. Check both scalar and incremental implementations against the same vectors. Initial genesis parameter values ($R_0, T_0, W_{-1}, E_0$) remain to be confirmed by simulation before genesis freeze.
The absolute tail preserves these 56 serialized bytes and the 134-byte header. Immutable genesis tail/work anchors and formula version 1 belong to the consensus profile identity; a snapshot cannot supply or reset them. Validate both cached fields against authenticated header work and the profile formula before accepting continuation state. See P06 for exact rounding and migration.
References
- [Merkle 1987] Ralph C. Merkle, "A Digital Signature Based on a Conventional Encryption Function", in Advances in Cryptology — CRYPTO '87, Lecture Notes in Computer Science, vol. 293, pp. 369–378, Springer, 1988.
- [Vermorel, Séchet, Chancellor, & van der Wansem 2018] Joannes Vermorel, Amaury Séchet, Shammah Chancellor, and Tomas van der Wansem, "Canonical Transaction Ordering for Bitcoin", June 12, 2018.
- [Vermorel, Séchet, Chancellor, & Cox 2018] Joannes Vermorel, Amaury Séchet, Shammah Chancellor, and Jason Cox, "Merklix Tree for Bitcoin", July 2018.
- [Dahlberg, Pulls, & Peeters 2016] Rasmus Dahlberg, Tobias Pulls, and Roel Peeters, "Efficient Sparse Merkle Trees: Caching Strategies and Secure (Non-)Membership Proofs", in Proceedings of the 21st Nordic Conference on Secure IT Systems (NordSec 2016), LNCS vol. 10014, pp. 199–215, 2016 (
IACR ePrint 2016/683). - [Crosby & Wallach 2009] Scott A. Crosby and Dan S. Wallach, "Efficient Data Structures for Tamper-Evident Logging", in Proceedings of the 18th USENIX Security Symposium, pp. 317–334, August 2009.
- [Todd 2012/2016] Peter Todd, "Merkle Mountain Ranges", OpenTimestamps / Bitcoin Core developer notes, 2012–2016.
- [O'Connor, Aumasson, Neves, & Wilcox-O'Hearn 2020] Jack O'Connor, Jean-Philippe Aumasson, Samuel Neves, and Zooko Wilcox-O'Hearn, "BLAKE3: One Function, Fast Everywhere", January 2020 (
https://github.com/BLAKE3-team/BLAKE3-specs). - [Nakamoto 2008] Satoshi Nakamoto, "Bitcoin: A Peer-to-Peer Electronic Cash System", October 2008 (
https://bitcoin.org/bitcoin.pdf).