Blockchain is a continuously growing chain of interlinked immutable blocks.
For understanding blockchain we first need to understand what is a block because blockchains are made up of blocks.
What is a Block?
A Block is a smallest unit of blockchain. A block contains data So, a block is like a page of a journal book.
A block contains data in following form:-
- “Normal Data” – “Tom has 20 altcoins”
- “Previous Hash” – “034DFA358”
- “Hash” – “4D56E1F06”
- “Nonce” – “1” (any number)
Genesis Block means 1st block of a chain.
How linking of blocks work?
Blocks are linked together by a hash.
Let’s take an example suppose there is a blockchain of two blocks, A and B, and block “A” is a genesis block and since it is a genesis block it’s previous hash must be something like “000000…” and it has a hash “034DFA358” then Block “B”‘s previous hash must be same as current hash of block “A” i.e. “034DFA358”.
So “A” and “B” are linked together by previous hash, and if anyone tries to change data in Block A it’s hash will change and so of block “B” causing blockchain to collapse.
Properties of Blockchain
- Connected by Hash Cryptography
- Distributed P2P Networks
- Consensus Protocol
- Immutable Ledger
- Mining of a New Block
What is SHA-256 Hash in Blockchain?
Hash is a digital fingerprint for documents.
SHA-256 Hash is of 256 bits so it has 256 in its name it is 64 characters long and used generally for linking blocks. Characters in a hash are hexadecimal, i.e. starting from 0 to 9 and further going till F i.e. 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F.
5 Requirements for a hashing algorithm
- One way – Hash should be one way i.e. we cannot convert hash back into text.
- Deterministic – Hash should be same for same text.
- Fast Computation – Generation time must be quick.
- The Avalanche Effect – Change of one letter in text should change the hash completely.
- Unique – No same hash can exist for different data.
Tool for converting your data into SHA-256 Hash.
Distributed Peer to Peer Network
Blockchain is on thousands of computers through peer to peer network.
So, If a hacker tries to break into one hash he must have to change the hash in more than 50 percent of computers in peer to peer network hence giving an extra layer of security to the blockchain.
It basically implies that longest chain is the king. Thus in Blockchain if your group of nodes have more than 50 percent of hashing power your group will win. i.e. 2 nodes have a “X” block and 4 nodes have a “Y” block now whichever group of node will a new block early they will win. Now, since 4 nodes group has more hashing power therefore chances of adding a new block is more in their case.
Blockchain is like a digital ledger in which when one block is tampered it’s hash will change, causing previous hash of subsequent blocks to change finally leading to collapse of blockchain thus hash of a block makes it immutable.
Mining of a New Block in a Blockchain
Blockchain gives a target for miners to get a hash below target, if a hash is below target blockchain will accept it and will add a transaction. Apart from normal data and hash every block contains a Nonce which stands for number used only once, miners play with different Nonce values to get a hash below target set by the blockchain. i.e. target can be to get hash with 4 leading zeros and miners need to try random value of Nonce to get a hash starting with 4 leading zeros. This, whole process of finding a hash below target is called cryptographic puzzle.
Applications of Blockchain
- Blockchain technology is used for making cryptocurrencies.
- With rise in use of social media Nft’s have become common they are based on this technology.
- Elections can be conducted using it.
- It is used in supply chain system.
- Provides a secure gateway of sending data as it cannot be tempered.