Blockchain is a continuous chain of Blocks, which holds some data, and each and every Block of the chain is secured and linked through cryptography. Also, you can add as many as Blocks in the chain, and the process of adding these Blocks to an existing chain is known as Mining. Blockchain is based on Distributed peer to peer networks that means there is no central authority, and each and every node has its importance in the network.
Now let’s discuss the internal structure of a Block. The main parameters of a Block are:
- Timestamp: It contains the exact time at which the Block was added to the chain.
- Data: Can be anything but particularly transactions, Bonds, treaties, etc. Block data capacity is also limited depending upon the network. (Bitcoin allows Block size of 1 Megabyte on its network.)
- HASH: It is a group of Hexadecimal characters(from 0 to 9, A- F) which is generated on applying the Hashing algorithm on a group of data. Furthermore, Hashes are irreversible i.e. we cannot get the data back from a Hash.
- Previous Hash: It is the Hash of the previous block. You can also say that it is a reference to the previous block.
There are more parameters inside a Block but the above ones are the main parameters.
In 1991, Stuart Haber and W.Scott Stornetta published a research paper on “How to Time-stamp a Digital Document”, so the idea behind the Blockchain came from that paper, and later in 2008 a group of people which goes by the name Satoshi Nakamoto coined the term Blockchain, and thus Blockchain came into existence.
Note: Hashing(Secure Hash algorithm) is applied on the whole block i.e. not only just on data but also on other parameters(previous hash, timestamp, nonce, etc) of the block.
Now If you have heard about a Data Structure known as Linked List, so Linked list is analogous to Blockchain, but they both are different things so only for the sake of understanding you can relate Blockchain to Linked List.
Why Do We Need A Blockchain?
To understand the usefulness of this technology let’s take up a situation in which, you are doing a transaction or sending some money to your friend and there is no third party such as Bank is involved wouldn’t that be a great thing, only the sender and receiver are involved and no one else. So that is one of the main reasons for which Blockchain was founded. Now the question arises if there is no bank involved, so who is going to secure my transaction details and payments, that is where Blockchain shows its Brilliance i.e. its impenetrable security. So let’s find out how.
- Cryptographic link
- Byzantine fault tolerance
A cryptographic link is basically a link that is maintained between each and every block of the entire chain. So how is this cryptographic link made between the blocks? Let’s suppose there are n blocks in a Blockchain. So each block contains some DATA and reference to the previous block, and that reference is known as HASH of the previous block. Now, this HASH value depends upon the DATA on which we are applying the Hashing Algorithm(SHA-256). So if the DATA inside a particular block has tampered the HASH of the block changes (no matter how small the change is performed on the DATA). Now suppose on the 3rd block, data is changed so the HASH value of that DATA also changes, and the cryptographic link breaks, because the HASH value stored on the Block 4 of Block 3 is different. Here is an illustration to understand this better.
Now if someone were to hack the chain and temper the data, he has to tamper with all the successive blocks and change HASHES at the same time which is pretty much impossible on a large scale. Let’s take up our previous example in which a hacker needs to change the DATA3 without being noticed, in order to do that he needs to change the HASH3 in block 4 to HASH3#, as soon as he changes the HASH3 in block 4 the HASH4 in block 4 also changes, so he again has to change HASH4 in block 5 to HASH4# and so on and so forth up till the last block of a chain.
Even if someone successfully changes all the blocks of the chain, there is another wall that needs to be cleared and that is Byzantine fault tolerance.
Byzantine Fault tolerance
Now Byzantine Fault tolerance is the technique or condition of a distributed network system. In this condition, every node on a distributed network comes to a common agreement and that agreement is decided by the majority of nodes. So how is this helpful in Blockchain? So the thing is every node on a particular distributed network has its own copy of Blockchain, so even if a particular chain is hacked the system verifies the chain(hacked) with chains on the other node, so if the chains do not match the chain on the hacked node, so the system overrides the chain on the faulty node to the chain which majority of the node is having. In a distributed network there is no central authority so the system believes whatever the majority of the nodes say is true. To understand this better, let’s take up an example, so we have a distributed network of about 1000 nodes, hacker decides to attack on node 6 and successfully changes all the cryptographic hashes on the chain.
Let X be all the chains on the network and Y be the modified chain on a node\ nodes.
- Initially, chain = X (node 6).
- After attack, chain = Y (node 6).
- So all the nodes except node 6 have, chain = X.
- And node 6 has, chain = Y.
- So there are 2 types of chain on the network X, Y.
- Now which one is correct, so the system decides whichever type of chain the majority of nodes are having will be considered true.
|Types of chain||No. Of Nodes|
- So the system considers X type of chain to be true.
- Now, chain = Y (Node 6) is discarded.
- chain = X (Node 6) is considered.
Let’s consider another complex example in which several hackers are attacking different nodes and more than just one node.
Now, there are 1000 nodes on a network and 2 big hacking organizations try to attack the network. So organization A attack nodes 2, 3, 4, 5, 6. Organization B attacks nodes 400, 401, 403 ……. up to 499.
- Let X be all the chains on the network, Y be the modified chain by Organization A and Z be the modified chain by Organization B.
- All the nodes are having, chain = X (initially)
- After attack,
- chain = X (All the nodes which are not under attack)
- chain = Y (2,3,4,5,6 Organization A)
- chain = Z (400, 401, 403 ……. up to 499 Organization B)
- So there are 3 types of chain on the network X, Y, Z
- Now again which one is true,
|Types of chain||No. Of Nodes|
|Z||100( 400, 401, 403 ……. up to 499)|
X, type of chain is the chain majority of nodes are having, so X type of chain is copied to all nodes having Y and Z type. In this way, our Blockchain is again restored to its initial state.
As explained above this Blockchain technology is indeed impenetrable. But wait, nothing is perfect even this technology has its own flaws. Blockchain is impenetrable only if no of nodes on a network is significantly high. Some attacks with which smaller Networks are susceptible to are.
- 51% Attack: In this type of Attack, the Attacker has almost 51% of the Nodes on the network under its control. In short, the attacker has the majority of the voting power, so he can make all the decisions on the Blockchain. But we all know that this is pretty much impossible on large scale networks.
- Eclipse Attack: This attack involves isolation of a node from the whole network of Blockchain, then the attacker can manipulate the node according to his will.
- DDoS(Direct Denial of Service) Attack: This attack aims to delay the services offered by the Network, by simply flooding the network with unnecessary information so the network gets busy processing the unnecessary information, while the processing of the genuine information gets delayed.
- Sybil Attack: In this type of Attack, the Attacker can fake himself as someone else on the majority of nodes and can exploit the mechanism behind the technology.
Note: To stop the DDoS Attack what we can do is, we can restrict the number of transactions processed per day by a node. Gmail utilizes this by limiting the no of emails sent and received by an individual per day up to 500. After 500 emails it does not allow the users to send or receive more emails.
But nevertheless, this technology is amazing and Cryptocurrencies such as Bitcoin and Ethereum which are based on Blockchain technology have never yet been Hacked or attacked.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Blockchain vs Bitcoin
- Create simple Blockchain using Python
- Implementation of Blockchain in Java
- Introduction to Blockchain technology | Set 1
- Introduction to Blockchain technology | Set 2
- How Does the Blockchain Work?
- Blockchain | Smart Contracts
- Blockchain Forks
- Important Blockchain terminologies
- Types of Blockchain and Chain Terminology
- Consensus Algorithms in Blockchain
- Blockchain to Secure IoT Data
- Difference between Blockchain and a Database
- What Are Cryptoasssets in Blockchain
- Blockchain in Brief
- Basics of the Blockchain and its various applications
- Proof of Stake (PoS) in Blockchain
- Features of Blockchain
- How does BlockChain support Crowdfunding ?
- Demur-rage currencies in Blockchain
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.