Merkle Trees: Understanding Blockchain's Organizational System

A Merkle tree, or hash tree, is another concept that investors are starting to hear about when discussing their digital currency holdings, checking the news, and researching the latest blockchain-based opportunity.Like the hash, being familiar with the concept and how Merkle trees help to secure and enable a blockchain can help to assess investments and make wise choices.

Secure verification of large data structures

A Merkle tree is a tree, branch, and leaf network of hashes representing data on a blockchain. Its linked structure of nodes form a tree-like structure. Merkle trees enable the verification of data and increase both the speed and usability of large data structures, like blockchains.

[maxbutton id="1" ]

With millions of Bitcoins in circulation, and hundreds of thousands of Bitcoin transactions per day, the Bitcoin blockchain is much larger than it was at the beginning, so Merkle trees may offer a way to help Bitcoin scale.

A summary of all the transactions in a block on a Merkle Tree

A Merkle tree is used to summarize the transaction data in each block of a blockchain. Its a tree of cryptographic hashes, but with a root at the top and leaves further down.The transaction data within a Merkle tree is hashed together to create a single hash, which serves as a verifiable digital signature.A Merkle tree can look something like this one taken from a Mastering Bitcoin course by Andreas M. Antonopoulos[caption id="attachment_5288" align="aligncenter" width="1024"]

merkle tree

A Merkle tree diagram. Source: Mastering Bitcoin course by Andreas Antonopoulos[/caption]The first four elements at the bottom form the leaves of the Merkle Tree and represent transactions contained within a block on a blockchain. Bitcoin blocks contain thousands of transactions so a Bitcoin Merkle tree would have thousands of leaves. Transactions themselves are not stored in a Merkle tree but the resulting hash of each piece of transaction data is.The Merkle root, at the top, is created by hashing each leaf (or transaction), and its this root hash that goes into a block header and is subsequently mined and verified by digital currency miners.Following the diagram:Each transaction in a block (e.g. Tx A) has an algorithmic hash function applied creating a transaction ID or transaction hash (e.g. H A).Then, the hashes of each transaction in a block are paired and hashed together to form new leaves, or nodes, but half as many of them. These are parent nodes. For instance, hash A and hash B, containing transactions A and B are paired and hashed together to form a new leaf hash AB (H AB). This is also happens to transaction C and D which are also now hashed to created hash C and hash D and then hash CD (H CD).On the next layer, hash AB (H AB) is paired with hash CD (H CD) and hashed together again to create hash ABCD (H ABCD on the diagram), and in this case the Merkle root.The Merkle root H ABCD is a hashed version of transactions A, B, C and D.Therefore, a Merkle root is a hash of all the transactions contained within that block.

Creating a secure blockchain with Merkle Trees

Applying algorithmic hash functions to transaction data using this type of Merkle tree construction serves to secure each transaction, turning into an immutable, timestamped, record which can easily be verified by comparison.Its the verification that makes a blockchain secure. If transaction data somewhere at the base of a Merkle tree is tampered with, the change will alter the mathematical calculation of algorithmic hashing. Thus, it will change each hash in the branch of the tree and ultimately change the root. By comparing the expected Merkle root with the actual Merkle root a problem can be identified. Digital currency miners will verify the Merkle root is correct and has not been tampered with as part of the mining process.The Merkle root, a hash of all the transactions within a block, goes into a blocks header. If the Merkle root does not identify, or verify, as it should neither will the block header and an issue of tampering, or hacking, can be identified.As a Merkle root is a hash of all the leaves and transactions, only the top root has to be compared or verified by a miner validating a transaction. The entire Merkle tree does not have to be compared or indeed transported to the next part of the blockchain. Thus, a Merkle tree provides a blockchain with some of its speed and scalability.A blocks header is what digital currency miners mine by applying more hash functions to verify and process blockchain data and thus earn their reward in digital currency.Image Credit: freestockphotos.biz

Buy Bitcoin, Ethereum, XRP, and other cryptocurrencies on Coinsquare, Canadas premier trading platform.

[maxbutton id="2"]