Bitcoin Serialization and Hashing: CompactSize, Transactions, Blocks, SHA-256d, and the Genesis BlockTextbook
Every commitment in Bitcoin — a transaction id, a merkle root, a block hash, the proof-of-work target test — is a hash of a byte string, and the byte string is produced by a serializer that every node must implement identically. A node that encoded a CompactSize one byte longer, or read a witness flag differently, would compute different ids for the same…