Crypto Academy / Season 3 - week 4 / Homework Submission Post for Professor @pelon53 :Root Hash and Merkel Tree BY @verdad

in SteemitCryptoAcademy3 years ago (edited)

I welcome you all to a new week of learning, professor @pelon53 really gave us an excellent conference where he explains a very important blockchain topic: Root Hash and the Merkle Tree. Below is my submission on all the questions he posted after the lecture.

HASH RATE

The hash rate (hash power) in blockchain and cryptocurrency transactions is defined as the number of hash operations performed by a miner in a period of time. Hash speed is an important factor in the logistics of cryptocurrency and blockchain mining operations and is often valued and discussed in the cryptocurrency community.

one of the ordinary measurements of hash rate is called "hash rate per second" and it represents the number of Security Hash Algorithm (SHA-256) algorithms that are performed per second. SHA-256 is a hashing algorithm that converts blocks of information into hashes in systems comparable to different types of compression systems. You can think of it this way – when miners are mining a block, they are generating text strings used by the SHA-256 algorithm and converting them to hashes. This compresses the information represented by the block. Then by counting the number of Security Hash Algorithm -256 hashes of the data string, the hash rate is obtained.

Hash rate is used to evaluate the strength of the blockchain, thus; the security of the blockchain network involved. The more computer systems dedicated by miners to find the next block, the higher the hash power on the blockchain, and the more difficult it is for hackers to disrupt or regulate network activities.

Below are hash rate numbers you will see or hear being talked about in the cryptocurrency mining context. It should also be noted that hash rates (hash power) differ depending on the crypto asset and the types of equipment/machines used to mine it.
one kilo hash (1 kH/s) is one thousand (1,000) hashes per second
one million (1,000,000) hashes per second= 1 MH/s
1 GH/s is one billion (1,000,000,000) hashes per second.
1 TH/s is one trillion (1,000,000,000,000) hashes per second.
1 PH/s is one quadrillion (1,000,000,000,000,000) hashes per second.
1 EH/s is one quintillion (1,000,000,000,000,000,000) hashes per second.
1 ZH/s is one sextillion (1,000,000,000,000,000,000,000) hashes per second
1 YH/s is one septillion (1,000,000,000,000,000,000,000,000) hashes per second

MERKLE TREE

Merkle tree is a hash-based data structure, which is a generalization of the hash list. The concept of the Merkle tree is named after Ralph C Merkle (a computer scientist), who patented the idea in 1979. It is a tree structure in which each leaf node is a hash of a data block, and each non-leaf node is a hash of its child nodes. The branching factor of the tree is 2, which means that each node has at most 2 child nodes. Below are some of the benefits of the Merkle tree;

  1. It provides a way to maintain data integrity and reliability.

  2. helps to save memory or hard disk space as a benchmark, and the calculation is simple and fast.

  3. It requires a small amount of information to be transmitted over the network in order to test and manage it.

Now let's make a Merkle tree given by @pelon53 since we now know what it actually is.

Make the following Merkle Tree: Transaction (tree leaves): Steem1; Steem2; Steem3; Steem4; Steem5; Steem6; Steem7; Steem8

STEP 1

Let's start by generating the Merkle Tree hash (from 1 to 8) using Security Hash Algorithm (SHA-256)
steem1
HASH= B97D34F73C7742D805111D1243BD5BF396BDB43122C3755081A3325D613B9803

Screenshot (174).png

steem2
HASH = B5F6EE9E3D63B48E00096DE32C8E1FF8EBB94D50337624A073534B995B2F6226

Screenshot (175).png

steem3
HASH= 419F6C383AC9F89E5653BA37FA88F2588E969A2886A0B84E51981159B59D82A0
Screenshot (176).png

steem4
HASH=A7354E9941C1A8E3448BD10AB4A39E9FADDFD4B78318152A4F17C62A459DB0CA

Screenshot (177).png

steem5
HASH = E6719173C1ED4B5E9D05D4B9DE35DB65F430B8C26F5624FB20F3676B8B3FA8BA

Screenshot (178).png

steem6
HASH= A4A6CB0CF4A9BFD7E81257330141A76010E7C086B9806F14885359486C511FAA

Screenshot (179).png

steem7
HASH= 2CB496A8DA690F22F15CB8EE8524202B289434C78575B6330929D3E50B4B2139

Screenshot (180).png

steem8
HASH=D546F02A9A03D4D2B01B1A1C935EEDF55128257891057331A8031831FD818121

Screenshot (181).png

STEP 2

It is now time to generate the branches.

steem1steem2
HASH=708FB642D5A44FF25F688BD78E4C23F0138475CAEB2BB47557ED92D6BFCAC01E

Screenshot (182).png

steem3steem4
HASH=03A1E3A34847732B726D23C096DF9740BEAB65E4D2A537F882994A8D19CC348E

Screenshot (183).png

stemm5steem6
HASH=1B88A7C0AFE9DDB1239B4289F3C05FF1886B30FE9ED74C96B58E997E206534E1

Screenshot (184).png

steem7steem8
HASH=A0C3C9F85E76DC3B95D8B43F74E1DA751406F6B690A39314996B85869100D5BA

Screenshot (185).png

next step,
We generate the higher branches

steem1steem2steem3steem4
HASH=BCADC68244A05276E6064D0FA0E95F7A88B06AAFC920BC5785EB0510096945CF

Screenshot (184).png

steem5steem6steem7steem8
HASH=4A879CC799A215375609C3A6F971427397F56FE3C68174B31AC12FEDF1E7A24C

Screenshot (185).png

The final step, that's the root generating step.

steem1steem2steem3steem4steem5steem6steem7steem8
HASH=4FD8BA07B307398CEE7A22B138A965B202067464B2F65257366C705A24E5220A

Screenshot (185).png

The picture below is the Merkle tree we just created.

hello - Copy (3).png

Steps to Verify if Steem6 is included in the root hash
Using the SHA-256; you must place each complete hash in the Merkle Tree.
Transaction (tree leaves): SCA1; SCA2; SCA3; SCA4; SCA5; SCA6; SCA7; SCA8. Explain each step, show screenshots.

Screenshot (178).png

Screenshot (184).png

Screenshot (185).png

Screenshot (185).png

  • Using the SHA-256; you must place each complete hash in the Merkle Tree.
    Transaction (tree leaves): SCA1; SCA2; SCA3; SCA4; SCA5; SCA6; SCA7; SCA8. Explain each step, show screenshots.

The screenshots below are just like the Merkle Tree we did above...so just kindly follow the steps

Screenshot (187).png

Screenshot (186).png

Screenshot (188).png

Screenshot (189).png

Screenshot (190).png

Screenshot (191).png

Screenshot (192).png

Screenshot (193).png

Next,

Screenshot (202).png

Screenshot (203).png

Screenshot (204).png

Screenshot (205).png

The next step is to generate the Higher branches

Screenshot (204).png

Screenshot (205).png

The screenshot below is the root hash of the Merkle Tree

Screenshot (203).png

The Merkle Tree has been created successfully as shown below

hello (2).png

What to do in case of an odd number of leaves

An even number of leaves and branches make up a complete Merkel Tree. Two leaves pair to generate a branch and two branches’ pair to produce a higher branch from which a root hash is generated.
In the case of an odd number of leaves, the last leaf is doubled and paired to generate a parent hash.
For instance, in the Merkel Tree above, the leaves were of an odd number and the lash leaf was SCA7. To construct a Merkel Tree, the last hash was doubled and I had two SCA7 which I later paired to produce SCA7SCA7 hash.

CONCLUSION

Hashing is a very vital part of blockchain technology. It guarantees not only security but reliability and integrity of data. In the first part of this post, I gave a brief explanation about the hash rate which is basically the measure of how fast hashes are solved in a second. Then I wrote about the Merkel tree and showed how they are constructed. Also, I wrote about steps on how to confirm if a leaf is included on the Merkel Tree. The last section of the post was about how to handle a situation in which the number of leaves on a Merkel Tree is odd. A situation like that is handled simply by duplicating the last leaf. I really learned a lot from this lecture and I hope my readers would enjoy it too. I really enjoyed your lecture @pelon53.

Sort:  
Loading...

Coin Marketplace

STEEM 0.17
TRX 0.13
JST 0.027
BTC 59189.63
ETH 2650.63
USDT 1.00
SBD 2.42