Blockchain 101

Merkle Trees

Merkle data trees are also known as hash trees or Merkle trees. This reference to “trees” comes from a type of data structure that is similar to a tree diagram, with root values and subtrees branching from parent nodes. Currently, hash trees are mainly used to ensure that blocks that are received from other peers are unaltered and that fake blocks are not sent. Hash trees are useful for verifying any kind of data that is stored, transferred, or handled between computers.

In blockchains, much of the data in a block is not humanly legible numbers or texts, but instead, hash outputs. Every item in a list, every transaction, or every chunk of data in a bitcoin block is made into a hash that identifies the block. Transactions in a bitcoin block are paired and hashed to become the input data for a single new hash. This process is repeated until one final hash of all of the hashed transaction data is created. This final hash is called the Merkle root, named after the mathematician Ralph Merkle who pioneered this way of multi-layered and secure way of storing data.

Hash trees are useful because they allow secure and efficient verification of large data structures and the contents within.

Child nodes point to parent nodes, so nodes further “up the tree” are hashes of their respective children. Most hash trees implementations are binary, with each node under two child nodes, although more than two child nodes can be used under each node.

At the very top of a hash tree is a root hash. When the received hash tree is checked against the master hash, it becomes obvious if the hash tree is damaged or fake. In this case, another hash tree from another source can be tried until one that matches the top hash is found.

Simply put, Merkle Trees provide the structure needed to quickly and efficiently reference data to check its validity. This technological structure is a key part of organizing hashes within a block.