Blocks: All you need to know (3)

Prince
4 min readAug 27, 2020

--

We shall continue from where we stopped in the previous article. This is the third in this series. Please, do well to read the previous two articles to ensure total understanding of the topic. Below are links to the previous articles:

“Blocks: All you need to know (1)” by Omusuwe Prince Chioma https://link.medium.com/JIcYaSSIe9

“Blocks: All you need to know (2)” by Omusuwe Prince Chioma https://link.medium.com/eXPVrbHb78

Merkle tree

Social studies was one subject which always interested me in my primary school days. In Particular, I loved the topic, "family." At some point in the class, we were asked to draw our family tree. We were to trace our family lineage. The family tree is even more useful during claims to royalty and inheritance. The family tree can be used to trace a person’s lineage up to the first generation. It can, therefore, be used to test the authenticity of a person’s claim.

The Merkle tree is a fundamental part of blockchain technology. A merkle tree is a structure that allows for efficient and secure verification of content in a large body of data. This structure helps verify the consistency and content of the data.

A Merkle tree summarises all the transactions in a block by producing a digital fingerprint of the entire set of transactions, thereby enabling a user to verify whether or not a transaction is included in a block. A Merkle tree is created by continually hashing pairs of nodes until there is only one hash left at the top. This hash which is left at the top is called the Root Hash or Merkle Root (this shall be explained later in this article). A Merkle tree is constructed from the bottom up, from hashes of individual transactions, known as transaction IDs. A Merkle tree is binary and, therefore, requires an equal number of leaf nodes. If there is an odd number of transactions, the last hash is duplicated once to create an even number of leaf nodes.

Looking at the above diagram, there are four transactions- A, B, C and D- in a block. Each of these transactions is hashed and this also creates four hashes, Hash A, B, C and D. Consecutive pairs of nodes are then summarised in a parent node by hashing Hash A and Hash B to create Hash AB, while Hash C and Hash D create Hash CD. The two hashes, Hash AB and Hash CD, are then hashed again to produce the Root Hash or Merkle Root.

The Merkle Root summarizes all of the data in the related transactions, and is stored in the block header. It maintains the integrity of the data. If a single detail in any of the transactions or the order of the transactions changes, so does the Merkle Root. Using a Merkle tree allows for a quick and simple test of whether a specific transaction is included in the set or not.

Merkle trees have three major advantages:

  1. They provide a means to prove the integrity and validity of data.
  2. They require little memory or disk space as the proofs are computationally easy and fast.
  3. Their proofs and management only require tiny amounts of information to be transmitted across networks.

The ability to prove that a log is complete and consistent is essential to blockchain technology and the general ledger concept. Merkle trees help verify that later versions of a log include everything from an earlier version and that all data is recorded and presented in chronological order. Proving that a log is consistent requires showing that no previous records have been added, altered or tampered with, and that the log has never been branched or forked. A user can verify parts of blocks individually and can check individual transactions using hashes of other branches of the tree.

Merkle Root

A Merkle root is the hash of all the hashes of all the transactions that are part of a block in a Blockchain network. Merkle roots are used in cryptocurrency to make sure data blocks passed between peers on a peer-to-peer network are whole, undamaged and unaltered.

It contains all the information about every single transaction hash that exists on the block because of the tree-like linkage of hashes. It offers a single-point hash value that enables validating everything present on that block. In other words, to validate a block, all you need to do is to enter the Merkle Root, since it carries all the information about the entire tree.

--

--

Prince

Blockchain and crypto enthusiast, writer, footballer and linguist...