Blockchain and Cryptocurrency Basic - Blockchain Distributed ledger and How Blocks Hashes Work in Blockchain

shubham-dhage-IlUq1ruyv0Q-unsplash (1).jpg
Source

Blockchain Distributed ledger

A blockchain distributed ledger is basically a database of records, distributed and syncs across a network of nodes. This allows multiple people to have access to the records. A distributed ledger ensures that any member can have access to the stored records or data on the network without the control of any central entity. This is done locally by each node or computer on the network. This allows the distributed ledger technology to function as decentralized peer-to-peer network.

In blockchain distributed ledger, transactions have public witnesses who are the members that run the nodes or computers that power the network. Each member that run a node on the network can own an identical copy of the ledger that is distributed across the multiple nodes in the network and any changes that is made to the ledger would reflect on all the copies in each of the network of nodes. With the peer-to-peer nature of the distributed ledger technology, blockchain technology also make use of this technology as a way of securing any record or information stored on the blockchain. This makes it difficult for hackers to hack or for the blockchain to be shut down because there isn’t a central point.

How Blocks Hashes Work

Block hash is one of the key aspects of blockchain. Hash is basically a string of encrypted alphanumeric value that are of a fixed length. This fixed length of alphanumeric value that stores information and data on the blockchain. The hash is the output of alphanumeric value generated from an input which is the raw information or data. When a block hash is produced, it becomes irreversible, which is why it is used as a security measure in blockchain. Block hashes output value would always have the same fixed length no matter the length of the input data.

To demonstrate how block hashes work, let’s look at a tool andersbrownworth which is https://andersbrownworth.com/blockchain/hash

Screenshot (3770).png

Inputting the data: Blockchain is amazing
The generated hash output is: 22ce6b60547d06c5cffc6b41266f0f4a7737b2c7959a584d72108482ce824d5f

Screenshot (3781).png

I will be inputting another data with a longer input,
Inputting the data: Cryptocurrency has a lot of benefits compared to the centralized conventional financial system
The generated hash output is: 526f9d8cff4c639b526959207d86860b0006a094a793e014062f973843718b28

Screenshot (3772).png

We can see that both hashes have the same fixed length of alphanumeric value containing the input data. This shows that block hashes outputs would always have the same fixed length no matter the length of the input data.

Visiting the block section of the website here

From the screenshot, we can see that the first block hash begins with 4 zeros which is known as the difficulty level.

Screenshot (3778).png

I will be inputting the data; this is great. We can see that the hash output value is showing as invalid and cannot be added to the chain.

Screenshot (3779).png

I clicked on mine and the hash output value becomes valid and the block is valid.

Screenshot (3780).png

What happens when any middle of the block gets changed

To demonstrate what happens when the middle of the block gets changed, I will be visiting the blockchain section of the website here

In blockchain, blocks are arranged in chronological order which means that it is arranged one after the other in time. The new references the previous block. block 2 is created, Block 2 comes after block 1, block 3 comes after block 2 and so on. With this, all the blocks that are created are chronological tied to each other, which means that once any block is changed, it would become invalid and every block created after would be invalid as well since the new block references the previous block.

When the data in the middle block is changed, for instance, we have 3 blocks, block 1, block 2 and block 3…
From the screenshot, we have mined different data for block 1, block 2 and block 3.

Screenshot (3787).png

Block 1

Data: I like to read books
Nonce: 29794
Hash: 000070218b66c36527c133ed91a7ca00456e4a832a1968c977709c6ab69f789c

Block 2

Data: The day is bright
Nonce: 124613
Hash: 0000c1ed289665240ffa079ff6dc26f2f6da58c36cc5eb6bacdd890578415cd0

Block 3

Data: It is good to work hard
Nonce: 59305
Hash: 0000f6cd1e306712fbddd4b411ff7131276e254e8f79edfef8a90bbd8e0c41f6

We can see above that I have mined 3 valid blocks with different data in each of the blocks. Each blocks have its own unique data and is valid. Block 1 is not referencing any previous block that is why it showing 0000… in the prev. Block 2 is referencing block 1 as we can see that the prev hash in block 2 matches the output hash in block 1. Block 3 references block 2 as the prev hash in block 3 matches the output hash in block 2.

Screenshot (3788).png

When i change the data in block 2, there will be a new hash and the block will be invalid. After changing the block 2 data to “Super amazing”, we can see on the screenshot that all the blocks created after block 2 is now invalid as well since block 3 references block 2. Block 3 is tied chronologically to block 2 and referencing it, it means that block 3 has become invalid.

Screenshot (3789).png

Sort:  

Congratulations @chimzycash! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

<table><tr><td><img src="https://images.hive.blog/60x60/http://hivebuzz.me/badges/postallweek.png" /><td>You have been a buzzy bee and published a post every day of the week. <p dir="auto"><sub><em>You can view your badges on <a href="https://hivebuzz.me/@chimzycash" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">your board and compare yourself to others in the <a href="https://hivebuzz.me/ranking" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Ranking<br /> <sub><em>If you no longer want to receive notifications, reply to this comment with the word <code>STOP <p dir="auto"><strong>Check out our last posts: <table><tr><td><a href="/hive-122221/@hivebuzz/pum-202304-delegations"><img src="https://images.hive.blog/64x128/https://i.imgur.com/fg8QnBc.png" /><td><a href="/hive-122221/@hivebuzz/pum-202304-delegations">Our Hive Power Delegations to the April PUM Winners<tr><td><a href="/hive-122221/@hivebuzz/pud-202305-feedback"><img src="https://images.hive.blog/64x128/https://i.imgur.com/zHjYI1k.jpg" /><td><a href="/hive-122221/@hivebuzz/pud-202305-feedback">Feedback from the May Hive Power Up Day<tr><td><a href="/hive-139531/@hivebuzz/proposal-2324"><img src="https://images.hive.blog/64x128/https://i.imgur.com/RNIZ1N6.png" /><td><a href="/hive-139531/@hivebuzz/proposal-2324">The Hive Gamification Proposal <h6>Support the HiveBuzz project. <a href="https://hivesigner.com/sign/update_proposal_votes?proposal_ids=%5B%22248%22%5D&approve=true" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Vote for <a href="https://peakd.com/me/proposals/248" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">our proposal!