blockchain-logo

What is Blockchain?

A blockchain is a continuously growing list of records called blocks, which are linked and secured using cryptography.

blockchain

What do you mean by a block?

A block is an individual record of some data which you want to store securely. Along with the data we have few additional fields i.e. “Index”, “Hash” and the “Previous Hash”. The first is also called as Genesis block.
A Block consists of a collection of few items. The items being,
1. Index of the block
2. Data of the block
3. Previous Hash
4. Hash (Fingerprint)

Index:

The index is a numerical representation of a block's position in the blockchain.

Hash:

The hash is like a fingerprint of the block. Everyone has unique fingerprints, so do a block have. This hash is an output of the SHA256 encryption function(explained below). We pass data, previous hash, and the index of the current block to this function and we get our hash in return.

Previous Hash:

The previous hash of any block is the hash of the block which comes prior to that block in the chain. The hash of block 1 is the previous hash of block 2, the hash of block 2 is the previous hash of block 3, and so on. The linking of the blocks is done by the previous hash parameter.

What is the benefit of such a structure?

You might have been thinking that it is somewhat similar to a linked list(P.S. If you know about linked lists). The major benefit of using blockchain is, let’s say if someone tampers block 1 then its fingerprint(hash) will change and the next block will then be storing a wrong hash in the previous hash field. This applies to all other blocks. In this way, we can say that the blockchain is no longer valid and we can detect malicious activity.

blockchain-tampered

SHA256 Encryption Function

What is encryption?

Suppose a person wants to send some confidential information over the internet to another person. Although, there has been a rise in the number of cyber attackers as well. To ensure confidentiality, we need to convert the data into an encrypted format such that even if the attacker access that data in between, he/she wouldn’t be able to recognize it. Once it is reached to the correct person, he/she can then decrypt it to read the data. To use encryption in blockchain, the process should be one way, i.e. we should be only able to encrypt and not decrypt.

encrypt-decrypt

SHA256

SHA stands for Secure Hash Algorithm. There are many SHA cryptographic encryption functions, SHA256 is one of them. SHA256 takes the string data and outputs a 256-bit sequence of characters which is practically in an unreadable format. This hash is 64 characters long and contains hexadecimal digits.

sha256-hashing-algorithm

Key characteristics of SHA256:

1. It is virtually impossible to decrypt the 256-bit hash back to its original form.
2. The algorithm is deterministic. It generates the same hash for the same input every time.
3. The computation is very fast.
4. Even if the input data is changed slightly, the output hash varies drastically. This is called the Avalanche Effect.
5. In the pigeon hole principle, multiple pigeons can stay in a single slot when a collision occurs. Similarly, attackers can induce artificial collision by stating that two different data sets(pirates) are having the same hash. Although, the SHA256 function can withstand a collision.

We use this function to generate our hash with an input string as a combination of the data, previous hash, and index values.

If you found this blog informativeand useful, kindly leave your reviews in the contacts section.