With DERSIG a non-DER signature is a script error
ProvedBitcoinSig.checkSig_dersigIf the DERSIG flag is set, a non-empty signature failing IsValidSignatureEncoding makes checkSigPreTapscript return none (the script fails), for every transaction, key and script code.
import Definitions.Def_BitcoinSig open BitcoinSig BitcoinSer
theorem BitcoinSig.checkSig_dersig (f : SigFlags) (tx : Tx) (nIn : Nat) (amount : Int) (v : SigVersion)
(scriptCode sig pk : Bytes) (hf : f.dersig = true) (hne : sig ≠ [])
(hder : BitcoinSig.isValidSignatureEncoding sig = false) :
BitcoinSig.checkSigPreTapscript f tx nIn amount v scriptCode sig pk = none := 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: BitcoinSig.checkSig_dersig
Binders and hypothesis. Universally quantified: a flag record (Booleans dersig, lowS, strictenc, witnessPubkeyType); a transaction ; a natural number ; an integer ; a signature version (either base or witnessV0); and byte strings , , . Three hypotheses:
- : the
dersigflag of is true; - : is not the empty byte string;
- :
isValidSignatureEncoding= false. Unfolded, this means at least one of the following holds for (with out-of-range bytes read as ): ; ; byte 0 is not0x30; byte 1 is not ; with = byte 3, ; with = byte , ; byte 2 is not0x02; ; byte 4 is0x80; and byte 4 is and byte 5 is0x80; byte is not0x02; ; byte is0x80; or and byte is and byte is0x80.
Conclusion.
That is, the pre-tapscript signature check reports a script error (the "none" outcome), as opposed to a verdict "some true" or "some false".
Unfolding. checkSigPreTapscript first computes a script code (for base, with the push of deleted; for witnessV0, itself) — this is irrelevant to the conclusion. It then returns "none" if checkSignatureEncoding is false or checkPubKeyEncoding is false. checkSignatureEncoding is: true if is empty (excluded by ); otherwise false if (.dersig .lowS .strictenc) and not isValidSignatureEncoding . With the disjunction is true and with the encoding check is false, so this branch fires and the whole result is "none" regardless of , , , , , , and regardless of the other three flags.
What is not said. The statement does not say that the dersig flag is necessary for this outcome: the same "none" would follow from lowS or strictenc alone, but the theorem only covers the case .dersig = true. It does not say anything when is empty (where checkSignatureEncoding is unconditionally true and the result would be "some false" or "none" depending on the key encoding). It does not say anything about valid encodings. It does not say the public key is examined at all — it is not: the key-encoding check is short-circuited by the signature-encoding failure in the sense that the disjunction is already satisfied. It does not say anything about checkECDSASignature, the signature hash, or the elliptic-curve verification, none of which are reached. It does not characterize which structural defect has.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.