Working of Block Hashes in Blockchain
It is a concept for storing data digitally. It will be available to everyone (publicly). Whoever wants to see it will be able to see it. It is always presented in the same sequence. The data are always in blocks. The data is made immutable by connecting the blocks (Chaining the blocks). When a block of data is chained or connected to other blocks, the miner can't change its data again. No one can change the info once added to the Blockchain.
In the recent article, we have learnt how we can build a block and cryptographic hashing connects into the whole process. Now we will see how the Blockchain uses all the concepts or topics together to retain the integrity of the Blockchain.
A bundle of blocks of transaction data are shown in the below images -
You can see the blocks arranged in chronological manner in the above images. Block no.1 is followed by Block no.2, then Block no.3, then Block no.4, and it continues as long as the user/miner wants. In this, you will find that there are 5 fields: data filed, hash value field, previous field, nonce field, and block number field. Hash field always get pointed by the previous field.
We know that each & every block in the Blockchain is cryptographically connected to the next corresponding block. In the above, e.g., If the hash value is zero or if the hash value is not present, block one will also be zero. But there is a hash value present in the previous field of block no. 2, it refers to the previous block’s hash value which is present. It continues till it reaches the last block.
Let us assume that the data is altered in any block, then for our assumption, let us take block no. 2 is altered, the data block 2 is now completely different from the previous one & mining that block also gets a new sign. The sign that references the new set or block of data is no longer chained or connected to other sets of blocks. It breaks or disconnects block no. 2 & the reason for this is the hash is not valid now, and it also indicates or shows every single block that comes after it & till the end of the chain. & it informs other users that there is some alteration in block no. 2 that has been recently altered. & as we know, Blockchain is immutable, and they always reject the changes by changing back to the previous record in the Blockchain, where all the present blocks are still chained or connected. & this is the main advantage of Blockchain.
If anyone wants to fix this, it can be done only by figuring out the nonce present or explained in the earlier lessons. So to try that, take one block and try not to take too many blocks as it might get difficult in the starting. If it doesn't produce a valid hash, start trying with 2, 3, and 4, and if nothing works, the only way is to mine it. When you start mining a block, the system automatically finds out if there is a hash and if yes, then it has got four leading zeroes or not. But in our case - hashing block no. 2, there is no valid hash (it doesn't have four leading zeroes in it). And that's the reason it remains an invalid block. & because of this, you have to mine this block also. To fix the problem, you have to mine every block, and it needs to be done until the front of the chain.
Importance of 4 leading zero’s in the hash -
Now let us understand the importance of the leading 4 zero's. Difficulty level - these 4 zero's are tied up, called difficulty level. The difficulty level is a thing that is built and tied up into the Blockchain network, which determines or tells how difficult it is to get the equal or same hash for a particular block. The difficulty level tells us to have a smaller hash than our target.
We need to target those 4 leading zero's for a specific thing. For example- consider 0000b1a2d3d4f5g6 is the target, any hashes done which are equal to or less than this no. It is a valid block. & many hashes will be able to satisfy this requirement or condition, and any one of those is considered valid. But it is a difficult task to find such type of hash. & it becomes more difficult to find a valid hash when the hash target is less.