DEFINITION of Merkle Root (Cryptocurrency)
A Merkle root is the hash of all the hashes of all the transactions that are part of a block in a blockchain network.
BREAKING DOWN Merkle Root (Cryptocurrency)
A blockchain is comprised of various blocks that are linked with one another (hence the name blockchain). A hash tree, or the Merkle tree, encodes the blockchain data in an efficient and secure manner. It enables the quick verification of blockchain data, as well quick movement of large amounts of data from one computer node to the other on the peer-to-peer blockchain network.
Every transaction occurring on the blockchain network has a hash associated with it. However, these hashes are not stored in a sequential order on the block, rather in the form of a tree-like structure such that each hash is linked to its parent following a parent-child tree-like relation.
Since there are numerous transactions stored on a particular block, all the transactions hashes in the block are also hashed, which results in a Merkle root.
For example, consider a 7-transactions block. At the lowest level (called the leaf-level), there will be 4 transaction hashes. At the level one above the leaf-level, there will be 2 transaction hashes, each of which will connect to 2 hashes that are below them at the leaf level. At the top (level two), there will be the last transaction hash called the root, and it will connect to the two hashes below it (at level one).
Effectively, you get an upside down binary tree, with each node of the tree connecting to only two nodes below it (hence the name binary tree). It has one root hash at the top, which connects to two hashes at level one, each of which again connects to the two hashes at level three (leaf-level), and the structure continues depending upon the number of transaction hashes.
(Source: Kiran Vaidya/Medium)
The hashing starts at the lowest level (leaf-level) nodes, and all the 4 hashes are included in the hash of nodes that are linked to it at level one. Similarly, hashing continues at level one, which leads to hashes of hashes reaching to higher levels, until it reaches the single top root hash.
This root hash is called the Merkle root, and due to the tree-like linkage of hashes, it contains all the information about every single transaction hash that exists on the block. It offers a single-point hash value that enables validating everything ever present on that block.
For example, if one has to verify a transaction that claims to have come from block #137, he/she only needs to check the block’s Merkle tree, without worrying about verifying anything on any other blocks on the blockchain, like block #136 or block #138.
Enter Merkle root, which further speeds up verification. Since it carries all the information about the entire tree, one only needs to verify that transaction hash, its sibling-node (if it exists), and then proceed upward until it reaches the top.
Essentially, the Merkle tree and Merkle root mechanism significantly reduces the levels of hashing to be performed, enabling faster verification and transactions. (For more, see Merkle Tree Definition.)