# Blockchain – What Is the Proof-of-Work Consensus?

Blockchain is a hot topic at the moment and quite fascinating. But just what is this technology built on?

Let’s explore this question in more depth. In this post, I’ll explain **one of blockchain’s core principles, Proof of Work**, a way of verifying data accuracy.

## What is Proof of Work?

Proof of Work **is the original consensus algorithm in a blockchain network.** This was the first of the various consensuses used to create cryptocurrency when Satoshi Nakamoto used it to develop Bitcoin in 2009.

### What is the Definition of a Consensus?

First, we need to define what a consensus is. A consensus algorithm in IT is a **process used to ensure data reliability** in a network with multiple unreliable nodes. There is a consensus algorithm behind every major cryptocurrency. No consensus algorithm is perfect, but they all have strengths and weaknesses.

Here are some examples of popular consensus algorithms:

**Proof of Work**(PoW): the one we are discussing in this post.**Proof of Stake**(PoS): in this consensus, the miner is chosen at random based on the amount of cryptocurrency the miner holds.**Delegated Proof of Stake**(DPoS): here, the selection is made based on other factors, such as blockchain use, age, the amount of currency held, etc.**Proof of Authority**(PoA): authoritative miners are defined in advance, eliminating the trust principle and requiring authority to be assigned to parties with a minimum common interest.**Proof of Capacity**(or Proof of Space): the miner is selected based on its storage capacity.- Etc.

Read this post on The 30 Most Common Consensus Algorithms to learn more about consensuses and how they work.

### Using Proof of Work in Blockchain

The Proof-of-Work algorithm is used in blockchain to confirm transactions and produce new blocks in the chain. With PoW, the miners compete to perform transactions in the network and are then rewarded.

Each user within a blockchain network sends digital tokens. A decentralized register groups the transactions into blocks to create a history. However, care must be taken to confirm each transaction and organize the blocks. Special nodes called **miners** handle this confirmation. The process itself is called **mining**.

PoW, therefore, provides a quick and easy method of proving transactions.

Source : Cointelegraph

## More About Algorithms?

The mathematical principles we have been talking about are complex problems or equations that take significant computing power to solve.

Here are some examples:

**Hash function**, or how to find the input if you know the output,*f(x) = y***Integer factorization**, or how to present a number as a multiplication of two other numbers.**Guided tour puzzle protocol**: if the server suspects**a DoS attack**(Denial of Service attack), the hash functions for certain nodes need to be calculated in a specific order. This becomes a “how to find a chain of hash function values?” problem. ».

As the blockchain network grows, it faces an increasing number of problems. The algorithms need more and more computing power. This complexity is another major problem for blockchain.

The mathematical problem in question should not be overly complicated. The more complex it is, the longer it takes to create new blocks. This means that transactions get stuck without being executed, and the outcome is also blocked. If the problem is too simple, on the other hand, it is vulnerable to DoS attacks or spam, for example.

Ultimately, the solution should be easy to monitor. If this is not the case, not all nodes can determine whether the calculations are correct. Transparency is one of the most important features of blockchain. Anyone can view blockchain. For example, you can view the Bitcoin blockchain, in other words, the registers of all Bitcoin transactions, via the Blockchain.com explorer.

Source : Cointelegraph

A new block is formed if the miner successfully solves the puzzle. The transactions are placed in that new block and are considered confirmed.

Source : Cointelegraph

## Where is PoW Used?

Many cryptocurrencies and Initial Coin Offerings (ICOs) currently use the Proof of Work consensus algorithm.

The most well-known use of PoW is undoubtedly Bitcoin. Bitcoin paved the way for this type of consensus. This algorithm allows you to change the complexity of a puzzle based on the network’s overall power. The average time to form a new block is ten minutes.

Another major cryptocurrency project that uses PoW is Ethereum. Since nearly three out of four projects are implemented on the Ethereum platform, it’s safe to say that the majority of blockchain applications use the PoW consensus model.

Some examples of ICOs that use PoW:

- Litecoin
- Bitcoin Cash
- Bitcoin Gold
- Verge
- Monero Original
- Lightning Bitcoin
- Litecoin Cash
- Etc.

## Why Use a PoW Consensus Algorithm in the First Place?

The main advantages of PoW are:

**Defense against DoS attacks**and the low impact of stakes on mining possibilities.- The work plan imposes
**limits on actions in the network**. As a result, attacks require a lot of effort to execute. An effective attack takes a significant amount of computing power and time to perform the calculations. So, although an attack is possible, the costs are too high to make it worthwhile. **Mining possibilities**. How much money you have in your wallet is irrelevant. The important thing is having enough computing power to solve the puzzles and form new blocks. Those holding large amounts of money are therefore not responsible for making decisions for the entire network.

## Example of How to Implement Proof of Work

In this section, **I will show you a very simple algorithm** that will help you understand what the miners do.

Imagine we have a block with the text “Cellenza – Does It Better! ” that we want to confirm in the blockchain using PoW.

We need:

- My
*block*- var block = “Cellenza – Does It Better!”

- A
*variable**tick*- The
*variable tick*is the only variable a miner can modify. It increments a number to solve the mathematical problem.

- The
- To understand the difficulty of the problem
- For example, I want my mathematical formula to return a value that starts with “00000”

- The mathematical formula.

There you have it. The puzzle is solved after 9768 tests (just under one second). I solved the block. I send my discovery to the blockchain system, which then compensates me for my time and energy use.

For information, if I had decided to increase the problem complexity by finding at least 000000, it would have taken less than ten minutes to run 26,960,031 tests and find the correct solution.

## Does the PoW Consensus Algorithm Have Any Flaws?

Computing power attacks, known as “51% attacks,” are the main disadvantage.

### What is a “51% Attack”?

A 51% attack, or a majority attack, is when a user, or a group of users, controls the majority of the mining power.

The attackers have enough power to control most of the network events.

They can monopolize generating new blocks and receiving rewards. They can prevent other miners from completing blocks. They can reverse transactions.

A 51% attack is not a profitable option. It takes a tremendous amount of mining power. Once the attack becomes public, the network is considered compromised, which can cause users to leave. As a result, the cryptocurrency price falls, and the funds lose value.

** **