SHA-256 outputs 32 bytes
ProvedBitcoinSer.sha256_lengthFor every message: .
import Definitions.Def_BitcoinSer
theorem BitcoinSer.sha256_length (m : Bytes) : (BitcoinSer.sha256 m).length = 32 := by sorry
Read-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: BitcoinSer.sha256_length
Binders and hypothesis. A single byte string (a finite list of 8-bit values), universally quantified with no restriction: may be empty, may have any length including lengths that are not multiples of 64, and may be arbitrarily long. There are no hypotheses.
Conclusion. The output of the file's own SHA-256 function on has exactly 32 bytes:
Unfolding. is defined as follows. First the message is padded by : append the byte , then zero bytes, then the 8 big-endian bytes of (mod ). The padded string is cut into 64-byte chunks by (any trailing partial chunk would be discarded, though the padding always produces a multiple of 64). Starting from the 8-word initial state , each chunk is processed by : the chunk's 16 big-endian 32-bit words are expanded to 64 by the schedule , each schedule word is added to the matching entry of the 64-entry constant table, 64 rounds are folded over the state, and the result is added word-wise to the chunk's input state. Finally the eight 32-bit state words are each written as 4 big-endian bytes and concatenated.
The theorem is therefore equivalent to: eight applications of (each of which is , the reversal of , hence of length 4) concatenated give bytes. The number of chunks, the content of the state, and the message itself do not affect the length; even for the empty message (one padded chunk) the output has 32 bytes.
Because , and , , are of various serializations, the statement entails that all of those also have 32 bytes; but the theorem does not state these consequences.
What is not said. Nothing is claimed about the values of the bytes: not that the function agrees with any standard SHA-256, not any test vector, not collision resistance or injectivity, not that different messages hash differently. It does not say that , , have length 32 by name. It says nothing about or or (the latter is the separate hash160_length). It does not state that the padded length is a multiple of 64 or that the number of chunks is . It is purely the length of the final byte string, for every .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.