What is a Merkle Tree?

What is a Merkle Tree?

A Merkle Tree is a technique widely used to create the blocks in blockchains.

When records of numerous transactions are blended together into a block and sent to a blockchain to be deciphered and validated, Merkle Trees are generally the design with which they are put together. Ralph Merkle first designed this hashing method in 1979 but didn’t see it popularized for some time. They are sometimes called hash trees. In case you are unaware, the difference between hashes and encryptions is that hashes are not intended to be decryptable unless someone has the original content. Hashes are basically symbols of a certain length generated using the “seed” of the actual content that was fed into the hash function. If the same content is entered as the seed, it will produce the same hash, but any differences will yield a completely different result.

Hashes are basically one-way encryptions. Merkle trees are a way to bury the original content deep within a pile of other hashed data. A message is hashed into one leaf, which is hashed together with another leaf, and together again at the next level, and so on. Interestingly, if a Merkle tree has too many layers, the original content can be lost, so standard protocols used in blockchains and so forth will only use Merkle trees with a certain number of layers. At each stage, including the end, or “root hash,” the output hash is a line of code of a specific length; Merkle hashes can convert different amounts and sizes of data into one uniform size.

This is one of its advantageous properties. If the hashes all have a specific size, the number of bytes is known, it can fit into specific equations, it is unique but indistinguishable from other hashes, and the difficulty and time it takes to mine the hash root can be controlled and modulated to preserve uniformity and predictability in the system regarding the amount of time and energy it takes to mine blocks. There are different kinds of Merkle trees, some of which have different names, using different numbers of layers and different numbers of inputs for each leaf in the tree. Merkle trees are generally binary hash trees, meaning that two inputs are combined to create one new hash at the next layer of the tree.

Many peer-to-peer networks besides blockchains, such as torrent services, use versions of hash trees to organize and transmit content in a secure manner. In blockchains, the Merkle roots of previous blocks can be used to verify the history of the blockchain without actually downloading the entire blockchain, so it serves as a shorthand for security validation.