In this track: Trees, roots and proofs
advanced · 4 MIN READ

Leaf encoding ambiguity

A secure digest cannot fix an ambiguous original encoding.

LET’S PICTURE IT

Two different filled forms should not collapse into one identical byte string.

SEE IT FOR YOURSELF
Build a root and follow one membership proofStep 1 / 4
Build a root and follow one membership proofA0x03783f…b760B0x1f675b…9111C0x017e66…8f72D0x6c3fd3…79f2A0x03783f…b760B0x1f675b…9111C0x017e66…8f72D0x6c3fd3…79f2hash(A,B)0x69de75…24a0hash(C,D)0xe62e1d…b5a4A0x03783f…b760B0x1f675b…9111C0x017e66…8f72D0x6c3fd3…79f2hash(A,B)0x69de75…24a0hash(C,D)0xe62e1d…b5a4ROOT0x4e2b32…5956A0x03783f…b760B0x1f675b…9111C0x017e66…8f72D0x6c3fd3…79f2hash(A,B)0x69de75…24a0hash(C,D)0xe62e1d…b5a4ROOT0x4e2b32…5956

This example hashes UTF-8 A, B, C and D. The displayed hashes are abbreviated, and the tree uses the playground’s sorted-pair convention.

Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.

Define the ambiguity

Packed concatenation of a and bc gives the same bytes as ab and c when both fields are variable strings and no boundaries are included.

Hashing preserves identical input

If two logical records already encode to identical bytes, their digests match without breaking the hash function. This is an encoding design problem.

Use a structured convention

Typed standard encoding, explicit lengths or another reviewed unambiguous format can preserve boundaries. The leaf builder and verifier must use the same convention.

Separate leaves from inner nodes

A scheme can also need domain separation between original leaf material and internal node concatenation. Review both record encoding and tree-node encoding.

Follow the proof model

packed("a", "bc") = bytes "abc"
packed("ab", "c") = bytes "abc"

Different records, identical encoded input.

Binary examples use the stated local playground convention. They are not Ethereum account or storage trie proofs.

TURN UNDERSTANDING INTO PRACTICEOpen the Merkle trees →
QUICK CHECK · NO PRESSURE

Does equal packed input require finding a cryptographic hash collision?

Your progress stays in this browser.
Keep exploring the original referenceethereum.org ↗

Original explanations by EtherTools. Examples are educational and source-linked; this site is independent of the Ethereum Foundation. Our approach.