Now that you know about the hash function, you can better understand what happens to all the information that goes through it to produce the hash, or the output that represents the next block on the blockchain. The technology of blockchain, however, isn’t simply to take all the information from the transactions and run it through the encryption. There’s a bit more to it.
First, there’s more information included in the block than simply all the transactions over the last ten minutes. There are actually six separate pieces of information included in the block.
- Version of software the miner is using.
- Time stamp, or when the block is added to the chain.
- Previous block’s hash
- Merkel Root
- Difficulty Target
- Nonce
We’ll cover the difficulty target and the nonce in the following articles, and the first three should be self-explanatory. That leaves us with the Merkel Root. On the surface, the Merkel Root is simply the information from all the transactions going into the block. The problem is that this is too much information to input in order to have a 256-bit output. That’s where the process of the Merkel Tree becomes so important.
Think of each individual transaction as a leaf. The information from each transaction is run through the hash function to create an encrypted output. Transaction 1 becomes leaf A and transaction 2 becomes leaf B. The leaves are then paired and hashed again, creating a branch. Leaves A and B become branch AB. If there’s an odd number of leaves or branches, the last one is doubled. In a block with only three transactions, transaction 3 becomes leaf C, and since there is no leaf D, then leaf C is doubled, creating branch CC. Finally, branches AB and CC are hashed creating root ABCC. In a three-transaction block, ABCC would then be the Merkel Root.
Using the process of the Merkel Tree, large amounts of information can be hashed together to create one output. After finding the Merkel Root, the only thing left to do is hash it with the other five parts and you have the block ready to be validated by the network.
Now that you understand how the Merkel Tree works, you’re almost done. You’re now ready to move on to the next part of the block, the difficulty target.