Steeemit Crypto Academy || Season 3, Week 4 || Root Hash and Merkle Tree || Home Work Task Submitted to @pelon53
Greetings to everyone here and welcome to week 4 of the Steemit Crypto Academy. Thank you @pelon53.
Introduction
Cryptocurrency can never be possible without the blockchain. The blockchain technology is being utilized in various ways and adoption is still ongoing. As per study the blockchain cannot be hacked as it is decentralized and no controlled by anybody but by several computers, that makes it very secured, thanks to its cryptographic technology. The blockchain comprises of series of block held together by a chain. When one block is filled another block is started and it continues to go on in that manner, it is there that the harsh comes to play.
![1626841945731.jpg](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmXVEAptSuUq1d2CqfjVWAGnLr7rZQcb2C3e6ZfiNx7jby/1626841945731.jpg)
What is a Hash
A hash can be described as a function which convert an input data of great length into an encrypted format with same meaning and usage. The file size and every other thing remains the same, nothing really changes. This is a very vital function in managing data in the blockchain. The blockchain receives millions of data per second and might delay verification process but the hash function help breaks down this data into hashes with the first data forming the root harsh. The same hash data will always produce the same harsh value no matter what. This is virtually the backbone of the blockchain.
Hashing on the other hand, involves a process whereby blockchain transactions are taken through a mathematical functions which then results in an output with a fixed length. The transactions submitted comes at variable lengths which will make it difficult for the blockchain to process and store this data, the hash process this data and present something even and alike to the blockchain for storage. In cryptocurrency such as bitcoin, has their transactions runs through a hashing alogaritm SHA-256 which produces an output of a fixed length.
Cryptocurrency mining
We cannot completely talk about hash with diving little into the aspects of mining. Mining is action in the blockchain whereby cryptocurrency transactions are verified, or cryptocurrency mathematical equations are solved and in the process, transactions are verified, new blocks are created which are first hashed and new tokens are been released. Since the blockchain is decentralized, not controlled or hacked by anyone but rather by series of computers.
The Merkle tree
As we have earlier established, there are Alot of transactions coming into the blockchain per seconds and it will be very unprofessional to store all the datas in one block, this could result in lots of time wasting and malfunctioning of the system, it is on this note that the Merkle tree is introduced. The Merkle tree helps breaks down this transactions and arrange them in such a way that will be easier to process, this will reduce the time spent on verifying each transaction thereby increasing the efficiency of the system.
It comprises of three nodes namely: The Leaf, Child and Root nodes respectively. The Child node are those nodes in the lowest bottom of the tree, whilst the child node are those next to it, followed the root node which is just a single node or TOP hash as it can be called.
Hash rate
Having described what a hash, hash rate is simply the rates or speed at which hashing operations are taking place during transactions verification. When the hash rate is high it means there are so many computers taking part in the mining process. This will help ensure that the system is workly perfectly. When the hash rate is too fast, it entails or means that mathematical difficulty is low but when it's high, it means the mathematical difficulty level is reduced.
Some have described hashrate to be the overall processing power utilized to mine and process transaction on a Proof of Work blockchain (an example is Bitcoin).
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmSXFsgZNWKT48x2kucnT7HEDsbj9thdrUsa7uLpfhJgXQ/image.png)
source
As earlier stated a hash is able to present blockchain data which are of varying length to a fixed length that can be easily processed and understood by the system. They are stored as codes on the system which always diffficult to guess. Mining equations are difficult, an example is Bitcoin, as more bitcoin is mined the equations gets tougher and more time consuming. Miners will therefore use their machines to guess a number and produce a hash that is quite similar with the target hash by changing a single value referred to as Nonce, the first miner to do that gets the rewards. A new hash is formed anytime the Nonce is changed. As transactions are verified new blocks are then introduced while the other transaction in the other blocks are reconfirmed making it impossible to change or alter.
Importance of Hashrate
A centralized system will always be prone to attack, this is the sole purpose of the blockchain, thanks to is decentralization technology. The blockchain is not monitored by any body, verifications are conducted not by a single computer but by series and numerous number of computers the more the number of processing computer, the more the blockchain becomes difficult to attack.
The hashrate is a very important indicator to measure the strength and in a long run the security of the blockchain. More machines invested in means increased hashrate and high security, a fall in hashrate could make the system very vulnerable to attack.
How is hash rate calculated?
Research has it that hashrates cannot be calculated but can be estimated, though there are some devices that have been developed to measure hashrate, but this is the case. The real deal is that is still tricky to measure even the bitcoin hashrates since mining machines do not need to identify themselves in other to contribute their share of the total computational power.
According to a global business director, it’s hard to accurately measure the hashrate of all machines in the network. Hashrate charts are reverse engineered by comparing block frequency and network difficulty.The oscillations exist because difficulty is constant in two weeks but block frequency varies greatly. At F2Pool, we find that estimated Network Hashrate is best represented as a moving average.source
So we therefore move by speculations and predictions using daily estimations of hashrates by comparing number of block mined within a 24 hour (1 day) period with the expected number of blocks if the speed is constant at one block every 10 minutes.
It's still really difficult considering all the parameters involved in this computation such as mining difficulties, number of hashes, even though a formula has been introduced;
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmeERk1XmtrrrsPsJbg94MNVyvPLY2N8JMtuAuNCrNkeJT/image.png)
source
Here’s a list of the standard units for hashrate:
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmWanKT6GtD8hPqiCyyynkbmN43uPguxv1HwnRFRCY6RfV/image.png)
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQma3ptetFRrnfUid65YfvMTCZ1fimXjnpaNpWp3qGW6NRF/image.png)
Task 2
Using the Merkle Tree we have:
Root hash: steem1steem2steem3steem4steem5steem6steem7steem8
Branch 1: steem1steem2steem3steem4
Branch 2: steem5steem6steem7steem8 respectively.
![IMG_20210720_223122_223.jpg](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmbVYCwU9qLC4t28JdmnuJfHVrnUzLFBjCbu5romZawLAW/IMG_20210720_223122_223.jpg)
Steps to verify Steem 6 on the Merkle Tree
The Merkle tress allows us to verify a certain transaction without really downloading the whole blockchain. Assuming we want to confirm if steem 6 is included in the block, having the root hash in place we query the system about Steem 6. With 3 hashes the missing hash can be found. So if we request to know if steem 6 is part of the blockchain and upon querying the root hash which is Steem12345678 we get back Steem 1234, Steem 5, Steem 7 and Steem 8, Steem 1 and Steem 2, Steem 3 and Steem 4 respectively.
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQma3ptetFRrnfUid65YfvMTCZ1fimXjnpaNpWp3qGW6NRF/image.png)
Task 3
Using the SHA256 we have the following presentations:
Root hash are used to form other hashes ranging from the bottom to top.
T1 = SCA1; T2 = SCA2; T3 = SCA3; T4 = SCA4; T5 = SCA5; T6 = SCA6; T7 = SCA7; T8 = SCA8.
Construting the merkle tree begins from by first placing the transactions from the bottom(sheets),
Then 4 transactions in the next line
Also 2 transactions that will form the branches
Followed by the top line whch is refered to as root hash.
Root hash: SCA1SCA2SCA3SCA4SCA5SCA6SCA7SCA8
Next 4 transactions;
SCA1SCA2 ; SCA3SCA4 ; SCA5SCA6 ; SCA7SCA8.
Branch 1 = SCA1SCA2SCA2SCA3SCA4, Branch 2 = SCA5SCA6SCA7SCA8 respectively.
Root hash according to SHA256:
![Screenshot_20210720-234850.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmdfNQtubwghMLECr8UcBuh4Lu7vsKWgfVNJDtMD6tZWVg/Screenshot_20210720-234850.png)
![Screenshot_20210720-235253.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmQjATKQLgouDEjyRYGK1VU52eDvnrr7Wc3hWBHMbKF2PL/Screenshot_20210720-235253.png)
![IMG_20210720_230048_979.jpg](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmWKmWerMFNaiWoc6WrK3qYYUnLt2H4nKV8P9cnXbvgLbG/IMG_20210720_230048_979.jpg)
![IMG_20210720_230436_031.jpg](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmNkr9j2rEubjL2kWoHVZp1jmBVgVBQLBtNsTutfpcmKHf/IMG_20210720_230436_031.jpg)
Merkle trees operates on a binary function. If there are any odd number at any level of the Merkle tree, the last node will duplicate and hashed with itself to produce an even number. An example is shown in the diagram below:
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmTBcpEyk27geuC7ztLuQyeQkDWV5ihtHpXDVJyRt7M4MR/image.png)
source
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQma3ptetFRrnfUid65YfvMTCZ1fimXjnpaNpWp3qGW6NRF/image.png)
Conclusion
We can all agree from the lectures that the Merkle tree, hash rate , mining and many other components not mentioned are combined in making the blockchain a viable technology.
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQma3ptetFRrnfUid65YfvMTCZ1fimXjnpaNpWp3qGW6NRF/image.png)
THANK YOU