In this article, we examine how Merkle Trees are used to verify authenticity of the blockchain public ledger used in Bitcoin, allowing the network to agree on transaction records.
In blockchain networks, each node verifies the authenticity of each block in the chain. To ensure that public records of transactions stored within the blocks are recognised as valid, blockchain technology makes use of the Merkle Tree. Each block in the chain contains its own Merkle Root.
This data structure makes use of the SHA-256 cryptographic hash function to create a Merkle Root from the records of all transactions recorded in the block.
Business Intelligence Solutions
Each transaction in the block is hashed using SHA-256, and the result of each hash is paired and concatenated with the result of another hashed transactions in the block. The results of these hashes are paired and hashed again until we eventually reach the root.
Make a Hash of the Leaves to Reach the Root
Consider a block in which three transactions are recorded, a, b and c.
As the Merkle Tree is binary, when the number of transactions in a block is odd, one of the transactions if repeated to facilitate pairing. In the example below, transaction c is double hashed twice. These are represented in the “leaves” in the bottom row of the below diagram.
D5 and D6 are hashes of concatenated pairs of double hashed transactions, and the double hash of this pair becomes our block’s Merkle Root.
Merkle Paths to Blockchain Verification
In developed blockchain networks including Bitcoin, there could be thousands of transactions per block. No matter how many transactions, each block will have only one root. This root is a 32-byte hash, and is a summary of all transactions in each block.
In order to verify that a transaction has been recorded in a block, a Merkle Path authenticates that the transaction is connected to the root. The path to the record of a single transaction is traced through a binary logarithm, allowing nodes to identify paths to verify a transaction which are a mere fraction of the size of a whole block.
Identification of a transaction is still possible when a node downloads only the block headers, rather than the entire blockchain. As it can take days to download the blockchains of many popular cryptocurrencies, this is a significant plus. This method is used widely by Simplified Payment Verification (SPV) client nodes.
One drawback to using SPV to verify a transaction is that an SPV client can be misled by dishonest nodes on the network which omit transactions from the blockchain. Connecting the SPV to multiple nodes does not remove this risk.
A second risk stems from inability to mask public addresses of users of the SPV client. If the client aims to reduce bandwidth by not downloading all blocks, requesting details of specific transactions from other nodes grants those nodes a view of all public addresses associated with the user. Bloom filters address this issue by requesting only matching transactions and partial Merkle Trees from other nodes.
See the Wood for the Trees
For blockchain technology to take hold globally, it needs to be able to operate efficiently in low bandwidth environments. Using Merkle Trees can be an effective way to facilitate this. The clear benefits of streamlining the verification process by reducing bandwidth should be kept in mind.
Interested in blockchain technology? For a free consultation, get in touch for a free consultation by contacting us using the form below:
Alternatively, drop us an email at:
info@csmall.co.uk
0 Comments