When wij were talking about mining, wij mentioned a difficult puzzle that a miner has to solve. What is this puzzle and what is it for?

Before reading this article, I suggest you read thesis two articles

#### So what is the puzzle that has to be solved by a miner?

The puzzle that a miner has to solve during the block creation is called **proof-of-work**. The proof-of-work is a chunk of gegevens which requires computational power to be created but it can be verified quickly. Thanks to the proof-of-work the blockchain’s gegevens becomes immutable.

Ter the previous article wij created a ordinary blockchain and wij eyed that tampering a block causes the invalidation of the following blocks.

Ter that example recalculating the hash of invalid blocks is elementary, but if wij add complexity te the calculation wij will make the bad guys’ life difficult.

#### What is the proof-of-work for? Why do miners spend so much effort on mining?

The proof-of-work is a mechanism for reaching global **overeenstemming** on the valid blockchain: since all knots have a copy of the blockchain, each knot voorwaarde agree on the conditions that prove how much effort a knot has spent on verifying transactions.

Ter other words: if the content of the blockchain is effortless to switch then everyone can tamper with it, instead, if each block is calculated with ingewikkeld mathematical functions then it takes a loterijlot of effort to tamper with the blockchain.

#### Let’s check the proof-of-work more ter depth.

Let’s create a blockchain where the blocks are linked to each other through an identification code, a block contains the following gegevens:

To make the calculation difficult, every identification code voorwaarde commence with ** 0000 (four zeros)**. To do this wij have to add a fresh field called

**NONCE**.

#### For a better understanding let’s take an example.

The very first block of our blockchain includes the following gegevens (please note that the identification code of the previous block is 0 because this is the very first block):

Now let’s copy this block content, then paste it ter the __hash zakjapanner__ and press the button * Calculate SHA-256 Hash* (be careful with spaces and fresh lines). The hash is spil goes after:

Spil you can see the code starts with * b273* and not with

*, so you voorwaarde increase the NONCE and repeat the calculation again (note that enhancing the NONCE from 1 to Two leads to the switch of the content and consequently the hash switches too).*

**0000**Now our block is:

and its hash is:

The code still does not embark with * 0000*! You vereiste repeat the calculation all overheen again until the code starts with

*. OK, I will give you the solution: you have to repeat this process*

**0000****22683 times!**

Hash code: 00000d7d33ebf71c24c15119c925acf9d9d45f8f9972034e2c8b1aabe29163a7

Spil it wasgoed said te the previous article, the hash is a one way function, so the only way to find the block’s identification code that starts with * 0000* is making random attempts (the method is called brute force).

Let’s create a blockchain that wij made ter the previous article but this time wij will apply the proof-of-work to it, this is what wij get:

If you tamper the very first block, you will pauze all the blockchain and for every block you will have to calculate the hashes that commence with * 0000* again! So, when a certain block has many blocks after it, this block becomes secure.

Te the bitcoins world a block becomes secure when it has at least **6 following blocks**, keep ter mind that the difficulty of the hash calculation is much higher than our example.

If you want to tamper the bitcoin’s blockchain, reminisce that every fake block vereiste serve with the calculation difficulty criteria and moreover you have to create fake blocks swifter than the other miners ter the network… to achieve this you need 51% of the computational power of the entire network!

Nowadays the blockchain technology is pushing to find other ways to reach the network overeenstemming because the proof-of-work is not energy-efficient at all. Some of thesis fresh ways are **proof of stake**, **proof of burn** or **casper**.

## No comments