Merkle tree

Overview
Databases and ledgers are large and are constantly being edited as new entries are added and data is modified or deleted. If one wanted to have a hash value for the database, one would have to constantly hash it, and maintain a way of ensuring they have the right hash value to align with the current state of the system in order to judge its integrity. Additionally, the larger the database becomes, the more computationally intensive hashing it becomes. A Merkle tree is a cryptographic concept introduced by Ralph Merkle in 1980 as a way around this problem.2

In a Merkle tree, data is segmented apart from a single whole data file. There is a root block of data with a hash value, then subsequent blocks of data (sometimes referred to as child, branch, or leaf blocks) that have their own hash value. Each subsequent block of data takes the hash value of their previous block (sometimes referred to as a parent block) as an input in the creation of the hash value of the new block. This creates a chain or tree of hash values, cryptographically tying new blocks of data to previous ones in a way that prohibits altering previous data. If data in a previous block were to be added, modified, or deleted, the hash value of the subsequent blocks of data would not compute to what they would need to be, alerting users that a change was made. This also allows hash values to be created for smaller, more discrete blocks of data. Hashing these smaller blocks is computationally less resource intensive than rehashing an entire set of data each time an edit is made.

Blockchains borrow the concept of Merkle trees to make hash chains. In a blockchain, a first block is created and a hash value is computed for it. This is the root block. Subsequent blocks then use the hash value of the previous block in the chain as one of the inputs to create that next block. This chaining of hash values creates a strong relationship between blocks on the chain, and an auditable and immutable record of the transactions on the blockchain.