The hashing algorithms used in the blockchain were developed to encrypt data. The first digital currency Bitcoin uses the Secure Hash Algorithm-256 encryption algorithm.

The algorithm was created in 1994 and has been updated four times. SHA-1, SHA-2, SHA-3, SHA-256. The number 256 means that each hash has a 256 bit code.

What is a hash?

This is the encrypted value. Any word passed through the hash function becomes a set of letters and numbers of a certain length, which is called a “hash”.

The word “Hacknam” passed through the Sha 256 hash function looks like this:

e269cf574be41db5428803c5e879f2d996628a359d1129d159833e544b98c4d9

If we change the letter M in the word “Hacknem” to the letter T and pass the word “Hacknet” through the same hash function, the hash will change completely and will look like this:

176453e3134e2a7d06c97b1a77a725f36539f98f0b9219786ed2118a3f51b21e

A hash is also called a fingerprint or impression. But the size of the hash does not depend on the original information. If we pass a whole sentence through the hash function, then the length of the string will not change.

Let’s pass the sentence through the hash function:

“Hacknam is about life”

The hash function produces a code of the same length.

15ea57436f1f4198bf71b6c616f54f354103137f5d4a59934bd0d91add10e381

 

What is a hash function?

This is the name of the encryption process. An important property of hash functions is the uniqueness of the hash. The hash is always bound to the same value.

What is hashed on the Bitcoin blockchain?

  1. Information about the sender, recipient, the number of coins sent and the date of the transaction.
  2. Each block in the blockchain has a unique hash.

Thus, each block contains the following: information about the sender, recipient, the number of coins sent, the date of sending, its own unique hash and the hash of the previous block. The hash of the previous block in the new block allows you to create a chain between blocks. It is this property that gives the blockchain traceability, security and reliability.

If you change the information in one of the blocks in the blockchain, then the hash of this block will automatically change, the hash of the changed block will be included in the information of the next block, and so on along the chain.

How does the security system work in the Bitcoin blockchain?

 

When a new user node connects, information about all the blocks in the blockchain is copied to it. Before a new block is added, the blockchain is synchronized with all nodes to confirm that the hash in the blocks has not changed.

After this confirmation, a new block is attached. If you change the information in an existing block (correct the number of sent coins or the address of the recipient), then the blockchain will determine this change as a new block.

Next, verification will begin with copies of blocks in user nodes, followed by an error if the data does not match. In order for this block to be recorded in the blockchain, changes must be made in all user nodes.

Imagine that there is enough computing power to change the data in all user nodes. Since modern computers are capable of processing millions of hashes per second. In this case, the second protective function comes to the rescue – the Proof-of-Work protocol.

Proof-of-Work creates blocks every ten minutes. Thus, it will take years to create changes in a block and make changes in all nodes.