Proof of work or proof of stake
Published: 2022-03-02 22:08:32


### Division of a Blockchain

Blockchain , a distributed but robust database of nodes ,is divided into six parts :

- OOR Interface: Part for the mapping and delegation resolution using
LISP
- Peer to peer protocol: Protocol used in order to communicate the
multiple nodes in the network.
- Consensus Algorithm(Focus of this report): Algorithm used to
decide, depending on the inputs, who signs a block.
- User input: Module to allow the communication from the user with the
blockchain. Typically a file with transactions to be added.
- Keystore: Storage of the keys.
- Chain persistence: Database structure in which all the data from the
Blockchain will be stored.

Our major focus here is the  Consensus algorithm

## What's Consensus Algorithm ?

 A consensus algorithm is a mechanism in computer science theory used to establish agreement on a single data value across distributed processes or systems. A consensus algorithm is a protocol through which all the parties of the blockchain network come to a common agreement (consensus) on the present data state of the ledger and be able to trust unknown peers in a distributed computing environment. Sounds simple .

For blockchain networks, the consensus algorithms are an essential element because they maintain the integrity and security of these distributed computing systems.

Proof Of work and proof of Stake are forms of Consensus algorithm

## Proof Of Work (P.o.W)

The main idea behind proof of work is to work hard in order to demonstrate
the commitment a node has with the network and thus, receiving a reward for
the work done. This is often known as mining.
In Bitcoin, for example, a reward is given to the first node that finds a specific
hash by hashing some information. The correct hash is a SHA-256 string made
by the transactions of the block, the previous block hash and the nonce, which
consists on having a leading number of zero bits. Two of the three parameters
of the SHA-256 hash are static, but one of them, the nonce, is selected by using
brute force, as it is the only known way to find the correct hash.
Proof of work is used nowadays in blockchains because it provides security to the chain as it is very complex to modify old blocks due to the fact that the
valid chain for the vast majority of the nodes is the longest one, i.e. the chain
with more accumulated computing power. This property ensures that data in
old blocks will not be modified, as it requires a hard computational work in
order to generate "by your self" a blockchain longer than the one that is shared
with the rest of the network.
Despite proof of work seems to be secure, there are some drawbacks that should
be mentioned:
- about 30% attack: Some research has been done about the problem of having
a group with at least 34% of the hash mining power over the network. Such group could modify the chain and thus turning the blockchain insecure.
- Increasing complexity: One of the properties of proof of work blockchains
is that the complexity of mining a block increases over time. This can seen as a strength of the protocol, because it protects the network against new hardware, but it is not. As the complexity increases, there
are only few mining farms1
that can spend enough money to achieve new
specific hardware in order to mine a cryptocurrency. This can lead do a centralization of the mining power, which is contrary to the idea of
decentralization of blockchain.

- Energy waste: As the complexity of mining a block increases, it is needed
more hashing power, which can be seen as more energy used. This is nowadays the main problem to solve on blockchains, as there are a lot of
cryptocurrencies using proof of work, i.e. wasting a lot of energy.

## Proof Of Stake (P.o.S)
The basics of this Algorithm is that participants or nodes in the network with
more stake in the blockchain, will be able to add blocks more often. Normally,
for each new expected block, a new signer of the block will be selected, through
random criteria, from the list of participants given its weight, i.e., the amount
of stake they have. With this in mind, the power effort destined to mine a block
is much less compared with PoW, thanks to the no hash power needed.
Although PoS give us the advantage of wasting much less energy than PoW and
some more decentralization, it has some drawbacks:
- Monopoly: The main drawback of PoS algorithms is that a potential
monopoly from the major stakeholders of the network could be possible.
This possibility puts those algorithms at the same level of PoW situation
that should be avoided.
- Nothing at stake: Regarding any proof-of-work blockchain, in front of a
double-spend attack or in a chain fork
, nodes will have three options to
choose:

    – Follow chain 1 and probably get benefit if chain 1 wins.

   – Follow chain 2 and probably get benefit if chain 2 wins.

    
   – Do nothing and get no benefit

Only one of these three options can be chosen, otherwise you would waste
energy mining on the wrong chain, costing you a lot of money in terms of
electricity.
Using the proof of stake protocol, this situation changes. Having in mind
the small cost of energy on creating a block in a PoS environment, you could easily follow the two created chains using less power than a proof-of-work blockchain miner do.
If this situation occurs, the blockchain will have no order and thus be a
chaos. Moreover, if there is more than one unique chain being followed, it
is probable to have more forks, which could cause more chaos.
On the other hand, proof of stake is suitable for us in this aspects:

- Nothing at stake is not worth it in our environment as the major stake-
holders are the most interested in the proper functioning of the chain. In
order to succeed in a nothing at stake attack, a high percentage of the nodes in the network should follow more than one chain when a fork occurs. As the nodes with more stake are the ones interested on a healthy chain, it makes no sense to follow the attack.
Energy is not wasted as it is in proof-of-work blockchains. Typically, the
election of a new signer is made by the use of random criteria and weighted
depending on the stake a node has. So making more attempts per second
do not increase the possibility of being selected as the new signer. Hence,
a reduction in time and energy can be noticed.

- Faster chains are possible by using proof-of-stake algorithms. Without the
need of computing a lot of hashes to find the correct one, is possible to create a chain with a higher rate of block generation. Nowadays, taking Bitcoin as an example of a proof-of-work blockchain, one block is createdevery 10 minutes. This situation is not scalable, so proof of stake offers a
faster way for block creation by reducing the time to chose a new block signer.

That seems like a lot , it only gets better......