A 2-of-2 CHECKMULTISIG loop passes iff each signature matches its key in order
ProvedBitcoinHtlc.multisig_twomultisigLoop o [s₁, s₂] [k₁, k₂] = some true ↔ o.checkSig s₁ k₁ = some true ∧ o.checkSig s₂ k₂ = some true. With two signatures and two keys the interpreter's matching loop cannot skip a key.
import Definitions.Def_BitcoinHtlc import Definitions.Def_BitcoinScript open BitcoinToLocal BitcoinSig BitcoinVerify open BitcoinScript
theorem BitcoinHtlc.multisig_two (o : Oracle) (s1 s2 k1 k2 : Bytes) :
BitcoinScript.multisigLoop o [s1, s2] [k1, k2] = some true ↔
o.checkSig s1 k1 = some true ∧ o.checkSig s2 k2 = some true := 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: BitcoinHtlc.multisig_two
Statement. Let be any oracle and any four byte strings. The theorem asserts
where is the CHECKMULTISIG matching loop unfolded below, applied to the two-element signature list (top first) and the two-element key list . Nothing is assumed about the lengths or contents of the four byte strings or about the behaviour of .
Definitions unfolded
Basic notions used throughout. A byte is an 8-bit word and a byte string (written ) is a finite list of bytes; denotes the length of a byte string . The constant is the interpreter's maximum size of one stack element. A flag set consists of three Booleans , , . An oracle is an arbitrary structure supplying eight functions with no constraints whatsoever on their behaviour: (so in particular is any function from byte strings to byte strings, not necessarily RIPEMD160SHA256, not necessarily 20-byte-valued), (first argument the signature, second the public key; the value represents a script-aborting failure, a verdict ), and . Stacks are lists written top element first. is: false for the empty string; for a one-byte string , true iff and ; for with non-empty, true iff or (so a string of zero bytes whose last byte is is false). and (the empty string). The script-number encoding of an integer is: if ; otherwise the little-endian bytes of with no trailing zero byte, then, if the last of those bytes has its top bit () set, an extra byte (for ) or (for ) is appended, and otherwise, for , the top bit of the last byte is set. For example and . The decoding ("script number of at most bytes, non-minimal encodings allowed") is if , and otherwise of the little-endian value of with the top bit of the last byte read as a sign (the empty string decodes to ).
The multisignature matching loop. , for lists of signatures and keys (top first), is defined by recursion: it is when is empty; when is non-empty and is empty; and for , it evaluates : if that is the loop is ; if it is the loop is when and otherwise ; if it is the loop is when and otherwise . Unfolded on exactly two signatures and two keys, is: if ; if (since ; the second signature is then never checked); and if it is , or according as is , or .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.