The multisig signatures are read off the stack layout
ProvedBitcoinScriptV2.multisigSigs_eqFor a stack nk :: keys ++ ns :: sigs ++ rest with nk, ns decoding to the lengths of keys and sigs: multisigSigs … = sigs.
import Definitions.Def_BitcoinScriptV2 import Definitions.Def_BitcoinScript open BitcoinScriptV2 BitcoinScript BitcoinSig BitcoinVerify
theorem BitcoinScriptV2.multisigSigs_eq (nk ns : BitcoinScript.Bytes) (keys sigs rest : List BitcoinScript.Bytes)
(nKeys nSigs : Int) (hk : BitcoinScript.toNum false BitcoinScript.nDefaultMaxNumSize nk = some nKeys)
(hkl : keys.length = nKeys.toNat) (hn : BitcoinScript.toNum false BitcoinScript.nDefaultMaxNumSize ns = some nSigs)
(hsl : sigs.length = nSigs.toNat) :
BitcoinScriptV2.multisigSigs (nk :: (keys ++ ns :: (sigs ++ rest))) = sigs := 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: BitcoinScriptV2.multisigSigs_eq
Statement. Let be byte strings, , , lists of byte strings, and integers. Assume
- ;
- ;
- ;
- .
Then
where the stack is listed top first: on top, then the elements of , then , then the elements of , then those of .
Notes on the literal content: and are not required to be non-negative, at most , or to satisfy ; a negative count forces the corresponding list ( or ) to be empty. is arbitrary (it may be empty, i.e. no dummy element is required). Hypotheses 1 and 3 require and , with the values read as described below (no minimal-encoding requirement).
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 .
Script numbers and
-
(the call with "minimal encoding not required" and maximum size ): if ; otherwise with obtained by reading little-endian, the bit of the last byte being a sign bit: if it is set, is minus the little-endian value of with that bit cleared; else is the little-endian value of . . No minimality check is performed.
-
For an integer , (negative integers convert to the natural number ).
-
, for a stack listed top first, is a list of byte strings:
- empty: .
- : if , . If , let . If is empty, . If : if , ; if , the result is (all of if it has fewer than elements).
No range checks are made on , (e.g. , or negative counts, are accepted).
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.