Block serialization is injective
ProvedBitcoinSer.serBlock_injectiveFor well-formed blocks : . Consequently distinct well-formed blocks have distinct byte strings, and a hash of the serialization identifies the block up to hash collisions.
import Definitions.Def_BitcoinSer
theorem BitcoinSer.serBlock_injective (b₁ b₂ : Block) (h₁ : b₁.wf) (h₂ : b₂.wf)
(h : BitcoinSer.serBlock true b₁ = BitcoinSer.serBlock true b₂) : b₁ = b₂ := 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: BitcoinSer.serBlock_injective
Binders and hypothesis. Two block records (each a header plus a list of transactions) and three hypotheses:
- and . For a block , unfolds to: the header is well-formed (, both hash fields of length exactly 32, time/bits/nonce ); ; and for every transaction in , both (version and lock time , input and output counts , every input with a 32-byte outpoint hash, index and sequence , script and witness-count and each witness item of length ; every output with value in and script of length ) and ( or ). Since a non-empty witness requires an input, the parenthesised condition is equivalent to " has at least one input".
- : the witness-mode serializations are the same byte string.
Conclusion. — equality of records, hence equality of headers field by field and equality of the transaction lists element by element, including every input's witness list, every output's integer value, and so on.
Unfolding. . The header part is the 80-byte string (signed 4-byte version, 32 + 32 raw hash bytes, three 4-byte fields). Each includes the marker and the witness stacks exactly when has a non-empty witness, and omits both otherwise. The statement asserts that, within the class of well-formed blocks, this encoding is injective: no two distinct well-formed blocks share a witness-mode serialization. The conditions are what make the fixed-width and raw-hash fields unambiguous (no truncation, hash fields of known length), the counts canonical and within range, and the signed values recoverable; the "at least one input" condition is what distinguishes the marker (an empty input count followed by flags) from a genuine transaction with zero inputs, so that the witness-mode encoding can be decoded unambiguously. Note that the mode is fixed to true on both sides; witness data is therefore part of the compared bytes, and distinct witnesses yield distinct serializations.
What is not said. Nothing about , which discards witnesses and is not injective on blocks that differ only in witnesses — no claim is made either way. Nothing about blocks that are not well-formed: two non-well-formed blocks (e.g. with a 31-byte and a 33-byte previous-hash field arranged to produce the same bytes, or values differing by a multiple of ) could serialize identically, and the theorem is silent. The theorem is not a round-trip statement: it does not say recovers (that is block_roundtrip), nor does it mention hashes, weights, or lengths. It does not say the map is surjective onto any set of byte strings. It is a single implication: equal witness-mode serializations of two well-formed blocks force equal blocks.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.