1. What is the hash value?

Hash value is the process of converting an input string of any length into a password and outputting it in a fixed way. Hash value is not a “password”, we can’t retrieve the original data by decrypting hash, it is a one-way encryption function.

Did you know that we can save all the data on the Internet with a fixed string length with the help of hash algorithm. We use a mathematical algorithm called SHA-256 (secure hash algorithm-256 bits). Sha 256 is the successor of SHA-1, which has 160 bits.

2. How to use hash value in blockchain?

In the blockchain, each block has the hash value of the previous block, and the previous block is called the parent block of the current block. If the parent block has a current block, it is considered. It will have the hash value of the previous block, the parent block.

In a blockchain, each block has a hash value of the previous block. When we change any data in the current block, the hash value of the block is changed, which affects the previous block because it has the address of the previous block. For example, if we have only two blocks, one is the current block and the other is the parent block. The current block will have the address of the parent block. If you need to change the data in the current block, you also need to change the parent block. When there are only two data blocks, it’s easy to change the data. But now, when we implement it in the blockchain, 614272 blocks have been mined at 12:32 on January 24, 2020, and the hash value of 614272 (th) block is 1000000000000000007 a6be31011560f1e3abe8f125e356a31db6051753334e. If we want to change the data in the current block 614272 (th), the hash address of block 614271 must be changed, but the hash of block 614271 cannot be changed, so the blockchain is called immutable and the data is trustworthy. The first block of the blockchain is called the origin block. You can see from this origin block how many blocks have been mined up to now.

I’ve created a visualization of this process.

What does hash value in blockchain do

If we make a small change to any part of the input, the output will have a big change. Please see the following example for more understanding.

Hash value is the core foundation and the most important aspect of the immutable and determined potential of blockchain technology. It preserves the authenticity of the data recorded and viewed, as well as the integrity of the blockchain as a whole. This is a more technical aspect, however, understanding how blockchain works and its immeasurable potential and value is a more solid step.

3. How does Merkle tree work?

When there is a large amount of data, it will be difficult to verify it and need a lot of memory to store and protect it, but with the help of Merkle tree, we can easily overcome all these problems.

Merkle tree is the basic part of blockchain technology, we can easily find any changes in a large number of data, and can effectively verify the data. Bitcoin and Ethereum are doing the same.

What does hash value in blockchain do

As we can see in the figure above, all bases are at the bottom, and the single hash at the top is called the root hash or Merkle root.

For example, there are four transactions a, B, C and D. Now the A and B hashes will be merged into one hash, while the C and D hashes will be merged into another hash, and the AB and CD hashes will now be merged into a single hash, called root hash or Merkle root ABCD.

The root hash value will contain all information for all transactions. The Merkle tree iterates the hash values until only one hash value is left, which is called the root hash pair node. Merkle tree is a binary tree, so it needs even leaf nodes. If the transaction number is odd, the last hash value will be repeated to create even leaf nodes.

What does hash value in blockchain do

In the figure above, we can see the repeated transaction hash value when the number of transactions is odd. This is how Merkle tree copies odd leaves.

The data of all transactions are summarized into a single root hash value and stored in the block. Because our current data is constantly changing, we will change the whole hash function. If the hash value changes, then the Merkle root will also change. Merkle tree helps us maintain the integrity of data.

Another advantage of Merkle tree is that if you want to know the status of a specific transaction, we don’t need to download the whole blockchain, we just need to require vertical proof, prove a branch of the tree, and verify a specific transaction branch.

4. How to use hash value to protect data?

Hash value greatly improves the security of data. As I’ve already mentioned, it’s a one-way encryption function. An encrypted hash function needs the following key features to be considered useful:

1. Each hash value is different.

2. The same hash value is always generated for the same message.

3. It is impossible to determine the input based on the hash value.

4. Even if you make a small change to the whole hash value, it will be changed.

Hashes help us see if the data has been tampered with.

For example, you have downloaded an important piece of information. To check whether the data has changed, you can run the data through the hash algorithm and compare the hash value of the data with the hash value of the received data.

If the two hash values are the same, the data is not changed. If the hash values do not match, the data is changed before the data is received.

Editor in charge: CT

Leave a Reply

Your email address will not be published. Required fields are marked *