Pay-to-public-key is correct
ProvedBitcoinScript.p2pk_correctFor every flag setting and oracle, signature and key of at most bytes,
import Definitions.Def_BitcoinScript
theorem BitcoinScript.p2pk_correct (f : Flags) (o : Oracle) (sig pubkey : Bytes)
(hsig : sig.length ≤ BitcoinScript.MAX_SCRIPT_ELEMENT_SIZE)
(hpk : pubkey.length ≤ BitcoinScript.MAX_SCRIPT_ELEMENT_SIZE) :
BitcoinScript.verifyScriptPlain f o [.push sig] (BitcoinScript.p2pkScript pubkey) = true ↔
o.checkSig sig pubkey = 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: BitcoinScript.p2pk_correct
Binders and hypothesis. Universally quantified: , a flags record (cltv, csv, nulldummy, all arbitrary); , an oracle (five arbitrary hash functions, a checkSig function from (signature, public key) byte lists to an optional Boolean, and two integer predicates); and , byte lists. Two hypotheses:
- : ;
- : .
Neither hypothesis says anything else about the contents of or ; both may be empty.
Conclusion. A biconditional:
Unfolding the scripts. with . The first script (the "scriptSig") is the single push of .
Unfolding verifyScriptPlain. First, is computed: from the empty stack with empty condition stack, the push step checks (excluded by ), pushes, and checks the stack size (); the result is . If this had been none, the verification result would be false. Second, is computed from the fresh state :
- : size check passes by ; stack becomes (public key on top); size .
- : it is counted (), is false, count becomes ; it is not disabled; the branch is executing ();
execOp's CHECKSIG branch matches the stack and evaluates . If that is none, the step fails and verification is false. If it is , the stack becomes , i.e. when is true and when false; the size check passes. - End of script: the condition stack is empty, so the run succeeds with stack .
Finally
verifyScriptPlainreturns of the top element: and .
The claim, in words. Under the two length hypotheses, the plain verification of "push " against "push ; CHECKSIG" is true exactly when the oracle's signature check on returns . Both directions: if the oracle answers the verification is true; if the oracle answers or none, the verification is false. The flags never enter the computation; all three flag settings give the same answer.
What is not said. The theorem does not interpret checkSig: it does not say the oracle performs ECDSA verification, hashes any transaction, or depends on a script code; whatever function the oracle holds, the statement relates verification to that function's output on exactly the pair in that order. It says nothing when or (no claim that verification is then false). It does not consider any other scriptSig (e.g. two pushes, or a push followed by opcodes), nor any other scriptPubKey form (P2PKH, multisig, P2SH, witness). It does not say what the final stack is, only the Boolean result. It does not involve the nulldummy, cltv or csv flags, the hash oracle functions, or opCount beyond the implicit fact that one counted opcode does not exceed the limit. It does not assert uniqueness of the satisfying signature or anything about the relationship between and .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.