Seed - Dev. Discussion - Merkle Tree's

in #bitcoin7 years ago (edited)

DevDiscussionMerkleTree's.png

Merkle Tree’s are a very popular concept in cryptocurrencies with a few very important uses. My blockchain research project will require the use of Merkle Tree's in a few areas, as well as potentially using an alternative Merkle DAG for our tangle-like transaction mesh. First I’m going to go over what a Merkle Tree is, explain it, and explain what it does for us.


What is a Merkle Tree?

MerkleTreeExample.png

A Merkle Tree is a tree where the leaf nodes are each unique sets of data, and each node above the leafs are simply the hashed value of the aggregated children’s hashes. As we go up to the top, each parent being the hashes of its children's, we eventually find the root node known as the Merkle Root. The Merkle root is dependent on every leaf node. If one leaf node had any difference in data, it would generate a different hash, making its parents generate a different hash, affecting all parents in the branch, including the Merkle root.


What are its benefits?

A Merkle tree gives two very large benefits. First, the tree makes the data tamper-proof. If we take a bunch of data that we know are the leafs of a tree, we can hash the data, reconstruct the tree, and compare Merkle roots. If the Merkle root received with the data is different from the one we just generated, we know the data was tampered with. Otherwise, we know we agreed upon the exact data we’re dealing with.

The second large benefit we gain from Merkle trees is the ability to share branches of a tree with each other to in order to generate the data and compare against the Merkle root, rather than transact all the data. Imagine if we had 1000 pieces of data to store, for example, transactions. If we needed to share transaction 23 while also proving that we’re reading it off the same grouping of data. If we stored this in a list, we would have to send all 1000 transactions in order to allow the other person to hash them all to agree on our parent hash. In a Merkle tree, we can achieve this same functionality while only needing to send the nodes on the branch connecting transaction 23 to the Merkle root. In this example, that would require roughly 20 transactions to be sent. This severely reduces the amount of data requiring to be transferred between users sharing their view of the world.


How is it used?

Merkle Tree’s have a few uses in cryptocurrencies. Their first and primary use in the Bitcoin protocol in order to ensure a block is tamper-proof in regards to the transactions it represents. All the transactions in a block are hashed and built into a Merkle Tree upon a miner initially creating a block. The miner then takes the Merkle root and stores it in the header of a block. This acts as the signature of a block. If anyone tries to modify any transaction in a block, that grouping of transactions would no longer generate the same Merkle Tree as listed in the block header, allowing us to prove that a transaction was tampered with.


Alternatives?

Alternatives to Merkle Tree's do exist that use similar structures. For example, Githubs file structure under the hood used to track changes isn't actually a true tree, it's a variation of a Merkle direction acyclic graph (DAG). This DAG equivalent allows for the sharing of only important files that are required to determine the end state, rather than requiring all files or all changes ever to do things like merging branches.


Thanks for reading! If you liked this discussion on Merkle Tree's, upvotes or follows are always welcome! Next we are going to be examining blockchains and the tether, so stay tuned!

Sort:  

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by carsonroscoe from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.

Coin Marketplace

STEEM 0.17
TRX 0.13
JST 0.027
BTC 59026.89
ETH 2655.48
USDT 1.00
SBD 2.50