CPubKey::IsValid characterized
ProvedBitcoinSig.pubkeyValid_iffA byte string is a valid CPubKey iff it has 33 bytes with header 02/03, or 65 bytes with header 04/06/07.
import Definitions.Def_BitcoinSig open BitcoinSig BitcoinSer
theorem BitcoinSig.pubkeyValid_iff (pk : Bytes) :
BitcoinSig.pubkeyValid pk = true ↔
(pk.length = 33 ∧ ((pk.getD 0 0).toNat = 2 ∨ (pk.getD 0 0).toNat = 3)) ∨
(pk.length = 65 ∧ ((pk.getD 0 0).toNat = 4 ∨ (pk.getD 0 0).toNat = 6 ∨ (pk.getD 0 0).toNat = 7)) := 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.pubkeyValid_iff
Binders and hypothesis. Universally quantified over a byte string . No hypotheses.
Conclusion. pubkeyValid = true if and only if
where denotes the numeric value of the first byte, taken to be if is empty (the "get with default " accessor). In the right side the length conjuncts make the empty case irrelevant: an empty string has length , so neither disjunct can hold.
Unfolding the left side. pubkeyValid is: false if is empty; otherwise, with the first byte, the Boolean decision of pubkeyLen , where pubkeyLen is if , if , and for every other header value. Since a non-empty string has positive length, the "" case can never equal , so validity amounts to: header or with length exactly , or header , or with length exactly . That is precisely the right side; the biconditional is a direct restatement of the definition with the default-accessor phrasing.
Edge cases. A 33-byte string starting with 0x04 is not valid; a 65-byte string starting with 0x02 is not valid; a string starting with any byte outside is never valid regardless of length; the hybrid headers 0x06/0x07 are accepted at length 65.
What is not said. The statement does not say anything about whether the remaining bytes encode a point on the curve, whether the abscissa is below the field prime, or whether the parity announced by the header is consistent with the ordinate — pubkeyValid is a header/length test only, and the biconditional faithfully says no more. It does not relate pubkeyValid to parsePubkey, to isCompressedOrUncompressedPubKey (which rejects headers 6 and 7), or to isCompressedPubKey. It does not say anything about the flags or the encoding checks. It does not say that the right side is decidable or exclusive (the two disjuncts are in fact mutually exclusive by length, but that is not asserted).
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.