In witness v0 nothing is deleted
ProvedBitcoinScriptV2.fadAll_witnessbitcoinbitcoin-mainnetcheckmultisigcodeseparatorconsensusfindanddeleteformal-verificationinterpreterscriptsighash
fadAll .witnessV0 sc sigs = sc.
Preamble
import Definitions.Def_BitcoinScriptV2 import Definitions.Def_BitcoinScript open BitcoinScriptV2 BitcoinScript BitcoinSig BitcoinVerify
Formal statement
theorem BitcoinScriptV2.fadAll_witness (sc : BitcoinScript.Bytes) (sigs : List BitcoinScript.Bytes) :
BitcoinScriptV2.fadAll .witnessV0 sc sigs = sc := by sorrySource
Bitcoin Core a773e1e33b349dc819b5a0edc1c7a4839dc73b48: EvalScript (pbegincodehash, OP_CODESEPARATOR at interpreter.cpp:1058-1066, OP_CHECKSIG's scriptCode and FindAndDelete at :339-343 / the CHECKSIG case, OP_CHECKMULTISIG's deletion of every signature at :1152-1159), SignatureHash (SigVersion::BASE), VerifyScript (src/script/interpreter.cpp: https://github.com/bitcoin/bitcoin/blob/a773e1e33b349dc819b5a0edc1c7a4839dc73b48/src/script/interpreter.cpp); Core's script_tests.json, tx_valid.json, tx_invalid.json at the same revision
Read-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: BitcoinScriptV2.fadAll_witness
Statement. For every byte string and every list of byte strings,
for signature version , folding the per-signature deletion over any list of signatures leaves the script code unchanged. No hypotheses.
Unfolded definitions used above
Basic objects and notation
- A byte is an 8-bit word, identified with its value in and written in hexadecimal (e.g. ). is the set of finite byte strings (lists of bytes); is the length, concatenation, the empty string.
- is the first entries of a list ; is what is left after removing the first entries, which is the empty list when .
- For a 0-based index , the statement "" means: and the entry of at index is . Indexing out of range yields no value, so such an equation can only hold with .
- A partial result is either or . Applying a function "under " () sends and .
- An instruction is either , carrying a data string , or , carrying an opcode byte . A script (parsed) is a finite list of instructions.
- Opcode bytes named below: , , , , , , , .
- A signature version is one of exactly two values: (legacy) or .
Reading one instruction from bytes:
returns either or with an instruction and the remaining bytes:
- : .
- Otherwise let be the first byte and the rest.
- If (a push opcode), a data length and a position are determined: if , and the data starts right after ; if , is the next byte ( if there is none); if , is the little-endian value of the next 2 bytes ( if fewer than 2 remain); if , is the little-endian value of the next 4 bytes ( if fewer than 4 remain). Then, if fewer than bytes remain, ; otherwise . (So gives .)
- If : .
On success the remainder is a suffix of that is at least one byte shorter than . never returns with .
Signature-push deletion: , , ,
- , the canonical push of : if it is the byte followed by ; else if it is , the byte , then ; else if it is , as 2 little-endian bytes, then ; otherwise , as 4 little-endian bytes, then . It is never empty ().
- returns a pair (resulting string, count); only the first component (written ) is used here. If the result is . Otherwise is scanned from the start: at the current instruction boundary, copies of are removed as long as the remaining string begins with (each removal counted); then one instruction is read with : if that fails, the whole remaining string is kept verbatim and the scan stops; if it succeeds, that instruction's bytes are kept and the scan continues right after it. The result is the concatenation of the kept bytes. (The recursion carries fuel , and when fuel is exhausted the remaining bytes are kept verbatim; every iteration of the scan consumes at least one byte.)
- :
- is the left fold of over the list, in list order:
and .
Human review
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.