To combine two hashes into their parent you hash the pair, with an internal-node prefix 0x01 so a parent can never be mistaken for a leaf. Today you serialize a hash to bytes and build HashNode.
Combine a left and right hash into a parent hash using the 0x01 internal prefix.
An internal node is the hash of its two children. To hash two 32-bit hashes together
you first turn each into bytes - four bytes each, big-endian, so the byte order
is fixed and identical in every language - then hash the 0x01 marker followed by
the left bytes and the right bytes. That is nine bytes in, one hash out.
Two things matter here. First, the 0x01 prefix is the other half of the domain
separation you started with leaves: a leaf hashes 0x00 plus data, a node hashes
0x01 plus two hashes, so the two can never collide by construction (you will pin
that defense directly in the proofs chapter). Second, order is significant - HashNode(l, r)
is not the same as HashNode(r, l), which is why proofs later have to remember
whether a sibling was on the left or the right.
const nodePrefix = 0x01func be4(h Hash) []byte { // 4 bytes, big-endianreturn []byte{byte(h >> 24), byte(h >> 16), byte(h >> 8), byte(h)}}func HashNode(l, r Hash) Hash {buf := append([]byte{nodePrefix}, be4(l)...)buf = append(buf, be4(r)...)return hashBytes(buf)}