With CLTV active, the operand check is the transaction's CheckLockTime
ProvedBitcoinHtlc.cltv_concreteFor f.cltv = true and : CltvPasses f (legacyOracle sf tx nIn amount v sc) expiry ↔ checkLockTime tx nIn expiry = true.
import Definitions.Def_BitcoinHtlc import Definitions.Def_BitcoinSig import Definitions.Def_BitcoinSer open BitcoinToLocal BitcoinSig BitcoinVerify open BitcoinScript
theorem BitcoinHtlc.cltv_concrete (f : Flags) (sf : BitcoinSig.SigFlags) (tx : BitcoinSer.Tx) (nIn : Nat) (amount : Int)
(v : BitcoinSig.SigVersion) (sc : Bytes) (expiry : Int) (hcltv : f.cltv = true) (h0 : 0 ≤ expiry) :
BitcoinHtlc.CltvPasses f (BitcoinSig.legacyOracle sf tx nIn amount v sc) expiry ↔
BitcoinSig.checkLockTime tx nIn expiry = 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.cltv_concrete
Statement. Let be any interpreter flag set, any signature-layer flag set, any transaction, any natural number (input index), any integer (amount), either of the two signature versions or , any byte string (script code), and any integer, under the two hypotheses and . The theorem asserts
where is the concrete "legacy oracle" built from these parameters and is the transcribed CheckLockTime, both unfolded below. Since the oracle's lock-time component is by definition , the left-hand side unfolds literally to . The parameters enter only through the oracle's signature component, which the statement does not consult.
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 lock-time predicate. , for a flag set , an oracle and an integer , is the proposition
so it holds unconditionally when the cltv flag is off, and otherwise requires non-negative and the oracle's lock-time check to accept .
The concrete oracle ("legacy oracle") for signature-layer flags , a transaction , an input index , an amount , a signature version and a script-code byte string is the oracle whose five hash functions are the concrete transcriptions of SHA-1, SHA-256, RIPEMD-160, and ; whose is and the analogous transcription of CheckSequence; and whose is the pre-tapscript check: for the script code is used as is (for every push of is first deleted from it); it is if the signature-encoding check or the public-key-encoding check under fails, and otherwise of the ECDSA verdict. The signature-layer flags are four Booleans ; the signature-encoding check accepts an empty signature, otherwise rejects a non-strict-DER encoding when any of is set, rejects a high-S signature when is set, and rejects an undefined hash-type byte when is set; the public-key-encoding check rejects a key that is neither compressed nor uncompressed when is set and a non-compressed key under when is set. The ECDSA verdict is false when the key's header byte does not announce its length ( for 33 bytes, for 65 bytes, anything else invalid), when the signature is empty, or when and ; otherwise the last byte of the signature is the hash type, the signature hash is the BIP143 digest (for , over , input , the script code, the amount and the hash type) or the legacy digest (for ), and the verdict is secp256k1 ECDSA verification of the remaining signature bytes (lax DER parsing, S normalised to the low half, the digest reduced modulo the group order) against the parsed key. , for , is: false unless either both and , or both and ; then false if ; then false if the nSequence of input of equals , where, if is not a valid input index, a default input with nSequence is used; and true otherwise. When the oracle comes from a consensus flag set (Booleans ), the interpreter flags are and the signature-layer flags are , so under the public-key-encoding check always passes and the signature-encoding check only rejects non-empty, non-strict-DER signatures when is set.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.