How Blockchain Security Works
Tags: web3, blockchain, security, programming
Published: 2023-02-15 07:58:39

Security is one of the primary reasons why blockchain has been widely adopted in recent times. Blockchain networks rely mainly on two (2) security algorithms - Proof-of-work (PoW) and Proof-of-stake (PoS) - among many others.

> Check out [this introductory article](https://www.freecodecamp.org/news/introduction-to-blockchain/) if you are new to blockchain.

This article will explain these algorithms, their security drawback, and how to improve blockchain security.


## What Is Proof of Work?

This is a consensus mechanism or a way to reach an agreement between people on one blockchain. It requires that a member of the chain proves to others that an adequate amount of work was put into mining a given block. PoW involves generating the hash of a block by re-calculating it until a desired pattern is reached. 

For example, a chain might specify that each block’s hash begins with “00000”. The possibility of this pattern being achieved the first time is meager. So what happens is that the hash is continuously generated until the pattern is achieved. You can begin to imagine the computing power or how many loops are required to achieve the desired result. This work put in proves to others on the chain that the block being added can be trusted.


> You can get in-depth details on [PoW here](https://dev.to/ebereplenty/how-blockchain-generates-each-blocks-hash-e1l).

Blockchain network that uses this algorithm includes Bitcoin and Ethereum 1.0.

## What Is Proof of Stake?

This consensus mechanism involves not showing how much computational power is put into mining a block, but how many coins are at stake if anything goes wrong. 

In this case, members of the blockchain who wish to serve as verifiers will have to stake some amount of coins. The more coins a verifier stakes, the more trusted he is because if he does a bad job of verifying a new block, he gets to lose some money to the network. It follows the principle that when one has something to lose, the person is more careful.

Blockchain network that uses this algorithm includes Algorand, Cosmos, and Ethereum 2.0.

## What Is The Problem With PoW and PoS?

The drawback of using these methods of consensus is that the security of the blockchain is dependent on the size of its members.

The computational power required for a small PoW blockchain is lesser than for a larger one. This means that the smaller chain is at a higher risk than the larger one. 

In like manner, a small PoS blockchain requires the verifier to stake lesser than a larger chain. A larger chain has less risk since the stake goes a long way to determine the level of security.

## How To Fix The Issues With PoW And PoS

The best way to fix this issue is to employ larger chains to do the verification for smaller chains until they get big enough to stand on their own. It requires that these chains are connected somehow. The larger chains can do the verification for the smaller chains when they can interact with each other. This is what [Cosmos](https://dev.to/ebereplenty/introduction-to-cosmos-network-and-cosmos-hub-hja) has done with the [Inter-Blockchain Communication](https://medium.com/the-interchain-foundation/eli5-what-is-ibc-def44d7b5b4c) (IBC) Protocol.

IBC provides a way to connect blockchains and help them exchange resources. Cosmos leveraged this technology to create an internet of blockchain using the [Cosmos Hub](https://dev.to/ebereplenty/introduction-to-cosmos-network-and-cosmos-hub-hja). With that in place, it becomes easy for larger chains to help smaller chains grow using Cosmos shared security known as [Interchain Security](https://blog.cosmos.network/interchain-security-is-coming-to-the-cosmos-hub-f144c45fb035).


## Conclusion

Security is more important now than ever before. Web3 promises a lot of it but is still a work in progress.

I explained the difference between Proof-of-Work and Proof-of-Stake in basic terms, the issues with the algorithms, and how Cosmos fixes it using IBC.

It is a short article with helpful resources all over. I suggest you check out those links to see more details on Blockchain’s security.