Along a post-BIP34 chain the coinbase scriptSigs are pairwise distinct
ProvedBitcoinUniqueness.chain_coinbases_distinctFor a reachable state at next height and a chain bs connected to it (connectChain) staying below height : the list of coinbase scriptSigs of the blocks of bs has no duplicates. Hence no two post-BIP34 blocks of one chain have the same coinbase transaction — the structural half of the argument that lets ConnectBlock skip the BIP30 scan. What this does not establish, and the model cannot: that two different transactions never share a txid (collision resistance of SHA-256d), and that no pre-BIP34 coinbase scriptSig happens to start with a height push of a height below 1,983,702 (a fact about the historical chain's data, which is why Core re-enables the scan from that height).
import Definitions.Def_BitcoinUniqueness import Definitions.Def_BitcoinHeader import Definitions.Def_BitcoinSer import Definitions.Def_BitcoinReorg open BitcoinUniqueness BitcoinSer BitcoinBlockV2
theorem BitcoinUniqueness.chain_coinbases_distinct (S : ChainState) (hR : BitcoinBlockV2.Reachable S)
(h34 : BitcoinHeader.BIP34Height ≤ S.nextHeight) (bs : List (BitcoinSer.Block × Int)) (T : ChainState)
(undos : List BlockUndo) (hc : BitcoinReorg.connectChain S bs = some (T, undos))
(hlt : S.nextHeight + bs.length < 2 ^ 31) :
(bs.map fun p => BitcoinUniqueness.coinbaseScriptSig p.1).Nodup := by sorryRead-back
What the Lean code literally says, in plain math · claude-fable-5-1 (independent sub-agent, blind: Lean code + auditor instructions only)
Read-back: BitcoinUniqueness.chain_coinbases_distinct
Statement. For every chain state , every finite list of pairs (block, integer clock reading), every chain state , and every list of undo lists, if
- ,
- ,
- , and
- ,
then the list has no duplicates: for all positions , .
Formally, with and :
What connectChain says
is defined by recursion on the list: ; and is if and , and if either is not an acceptance or the recursive call is . So the hypothesis says: there are states and undo lists with for each and . Each block is validated with its own clock reading . Since each acceptance appends one header, .
What coinbaseScriptSig says
is the scriptSig (a byte string) of the first input of the first transaction of , with two fallbacks: if is empty, the fixed genesis coinbase transaction stands in for the first transaction (its scriptSig is a fixed 77-byte string); if that transaction has no inputs, a default input with empty scriptSig stands in, giving the empty string.
What the acceptance hypothesis says
asserts that the four stages below all succeed and that and are exactly the state and undo list they produce. Write , (the next height), for the last element of (the fixed genesis header if the list is empty), (truncated subtraction, so when ), and for the first transaction of (the fixed genesis coinbase transaction if is empty). A transaction "is a coinbase" iff it has exactly one input and that input's previous outpoint is .
-
Header stage. passes the proof-of-work test of the imported proof-of-work development (its double-SHA-256 hash, read as a little-endian 256-bit number, against the 32-bit field ); equals the header hash of (otherwise the outcome is "missing previous", not accept); the 32-bit value of equals the required work computed from by the imported difficulty rule; the median time past of at is strictly less than ; (otherwise the outcome is "future time", not accept); and it is not the case that ( and ), nor ( and ), nor ( and ).
-
Context-free block stage. The proof-of-work test again; the Merkle root computed from the txids of equals and the Merkle computation reports no mutation; is non-empty; and ; is a coinbase and no other transaction of is; every transaction has non-empty inputs and outputs, witness-stripped size times 4 at most , every output value in with running totals in that range, pairwise distinct previous outpoints, and (for a coinbase) a first-input scriptSig of length between and inclusive, or (for a non-coinbase) no null previous outpoint; and of the legacy signature-operation counts is at most .
-
Contextual stage. Every transaction of is final at height against a cutoff (the median time past of if , else ); if then is a prefix of the scriptSig of the first input of (the first input being the default input with empty scriptSig if has no inputs) — this byte string is literally the same expression as ; the witness-malleation check passes with the expectation flag set iff ; and the block weight ( stripped size full size) is at most .
-
Connect stage. Let . If equals the fixed genesis block hash (32 bytes beginning ), the stage succeeds immediately with ledger and empty undo list, performing no further check. Otherwise: if (see the ScanRuns unfolding) and it is not the case that for every and every the ledger has no entry keyed , the stage fails; otherwise the transactions are processed in order through the imported per-transaction loop (input lookup and maturity, fee range, sequence locks, sigop budget, full script verification, ledger update), which must succeed, and finally the output value of must be at most the accumulated fees plus the subsidy at height .
On success, where is the ledger produced by stage 4, and is the undo list produced by stage 4. In particular .
What reachability says
is the least predicate such that (i) the initial state (one header, empty ledger) is reachable, and (ii) whenever is reachable and for some block , integer and undo list , then is reachable. So means arises from the initial state by a finite sequence of accepted validations, each with its own arbitrary clock reading.
Edge cases and scope
- : empty, , , and the conclusion ( of the empty list) holds trivially.
- : the conclusion ( of a one-element list) holds trivially.
- The conclusion concerns only the blocks in ; it says nothing about the coinbase scriptSigs of blocks already in (those at heights below ), nor about any comparison between a block of and a block of .
- is pairwise inequality of the byte strings at distinct positions; it does not say anything about txids or about the coinbase transactions as a whole.
- and appear only in the connection hypothesis; the clock readings are arbitrary and independent.
- The bound constrains the height of every block in the sequence to be below ; the lower bound applies to the first block's height, and hence (by the header-append structure) to all of them.
- The fallbacks of (empty transaction list, inputless first transaction) are not exercised under the stage-2 requirements of each acceptance; the conclusion itself does not say so.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.