The legacy sighash ignores scriptSigs and witnesses
ProvedBitcoinSig.sigHashLegacy_skeletonFor every script code, index and hash type, two transactions with the same version, outputs, lock time, and the same prevouts and sequence numbers in order have the same legacy signature hash. Signatures therefore never sign other signatures.
import Definitions.Def_BitcoinSig open BitcoinSig BitcoinSer
theorem BitcoinSig.sigHashLegacy_skeleton (scriptCode : Bytes) (tx tx' : Tx) (nIn hashType : Nat)
(h : BitcoinSig.sameSkeleton tx tx') :
BitcoinSig.sigHashLegacy scriptCode tx' nIn hashType = BitcoinSig.sigHashLegacy scriptCode tx nIn hashType := 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: BitcoinSig.sigHashLegacy_skeleton
Binders and hypothesis. Universally quantified over a byte string , two transactions and , and natural numbers and (unbounded). One hypothesis : sameSkeleton , which unfolds to the conjunction
the last conjunct being equality of the two lists obtained by replacing each input by the pair (prevout, sequence number). It therefore forces and position-wise agreement of prevouts and sequences, while allowing every input's scriptSig and witness to differ arbitrarily.
Conclusion.
Unfolding. sigHashLegacy returns uint256One (byte 1 then 31 zero bytes) when and — a condition that depends only on the output list, equated by — and otherwise the double SHA-256 of serSigTx followed by the 4-byte little-endian . serSigTx reads: (4 bytes); the input count, which is if the ANYONECANPAY bit () of is set, else ; for each serialized input index (overridden to under ANYONECANPAY): the prevout of input (or of the default input if out of range), then serScriptCode if else the single byte 0x00, then the 4-byte sequence of input — replaced by 4 zero bytes if and the low five bits of are (NONE) or (SINGLE); the output count ( for NONE, for SINGLE, else ) and the corresponding serTxOut records (value as 8-byte two's complement, then the script with compact-size prefix; for non- outputs in SINGLE mode and for out-of-range indices); and (4 bytes). The scriptSig and witness fields of inputs are never read. Since equates every field that is read, position by position, the two byte strings and hence the two hashes agree.
What is not said. The statement does not say the converse (equal hashes do not imply sameSkeleton). It does not say the hash is independent of , or — these are held fixed. It does not say that scriptSigs or witnesses are the only fields that may differ; it says that if everything in the skeleton agrees then the hashes agree. It does not bound or . It does not address the uint256One special case specially: both sides merely agree on whether they hit it. It does not say anything about the BIP143 hash, nor about signature verification.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.