Image for post
Image for post

Blockchain Fundamentals #1: What is a Merkle Tree?

Andrew
Andrew
Feb 26, 2018 · 6 min read

Hashing

Hashing Example

cd ~ && mkdir merkletrees && cd merkletrees
touch a.txt
md5 a.txt
Image for post
Image for post
echo “hashing is awesome” >> a.txt && md5 a.txt

Growing The Tree

Image for post
Image for post
Diagram 1. Rough sketch of the structure of a Merkle Tree using our text files as example inputs

Adding Branches

rm a.txt
echo "Hello from a.txt" >> a.txt && md5 a.txt &&
echo "Hello from b.txt" >> b.txt && md5 b.txt &&
echo "Hello from c.txt" >> c.txt && md5 c.txt &&
echo "Hello from d.txt" >> d.txt && md5 d.txt
MD5 (a.txt) = c95c68d91441ba192ada81c9cfb2abe7
MD5 (b.txt) = 80262782d5961c452eae5de9991af0fd
MD5 (c.txt) = 0bfe75f719adf6450bb8be8e10126383
MD5 (d.txt) = 10fa7f973f6ec6682e1a6f4570a89861
Image for post
Image for post
md5 <<< "c95c68d91441ba192ada81c9cfb2abe780262782d5961c452eae5de9991af0fd"
a3d71b58e08759e6245667fb6f4770b6
Image for post
Image for post
Diagram 2. The parent hash of a.txt and b.txt combined
md5 <<< "0bfe75f719adf6450bb8be8e1012638310fa7f973f6ec6682e1a6f4570a89861"
078791272b0b48b7bb7004ebc1b22123
Image for post
Image for post
Diagram 3. The parent hash of c.txt and d.txt combined
md5 <<< "a3d71b58e08759e6245667fb6f4770b6078791272b0b48b7bb7004ebc1b22123"
eaad1d42b754612a4249bcbd95f0b734
Image for post
Image for post
Diagram 4. A completed Merkle Tree

Why Are Merkle Trees Important?

Byzantine

Blockchain development studio building decentralized…

Andrew

Written by

Andrew

Software Engineer currently studying Blockchain at Byzantine https://byzantine.studio

Byzantine

Byzantine

Blockchain development studio building decentralized applications for the new web3.

Andrew

Written by

Andrew

Software Engineer currently studying Blockchain at Byzantine https://byzantine.studio

Byzantine

Byzantine

Blockchain development studio building decentralized applications for the new web3.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store