HTML Table

eurosa

Blockchain basics - Proof of Work

 

Blockchain basics - Proof of Work

In this article, we are going to talk about one of the most important blockchain technologies or components, Proof-of-Work. Proof of work is the revolutionary component of blockchain that prevents double-spending.

What is double-spend?

To understand what problem Proof of Work solves, one must first understand what the actual problem is.

Double spend is an illegal action on the blockchain, where one Bitcoin is spent more than once.

In a physical world, Bob gives Alice a picture. Since Bob gave the picture to Alice, he does not own the picture anymore. Bob cannot give the same picture to John as Alice owns it now. 

In a digital world, Bob sends an email with the picture to Alice. Bob still owns the picture on his computer and he can send the same picture to John. This way, he sent the image twice and can continue doing this indefinitely.

This was a big issue with digital currency in the past. How to prevent sending the same digital currency twice? And how to prevent someone from simply just copy-pasting his virtual coins indefinitely. Proof of Work solved this.

What is proof of work double spend

What is Proof of Work?

Proof of Work or PoW, in short, is a method of confirming transactions on the blockchain also called mining. 

Blockchain is a distributed ledger (database) of past blocks. Blockchain is distributed over the globe by nodes that enable decentralization. One of the node functionality is adding new blocks to the blockchain, these nodes are called miners. Only nodes who are willing to spend computational resources are able to add new blocks to the blockchain.


With PoW, miners are solving mathematical, one-way functions. Multiple miners simultaneously compete against each other. Whoever solves the function first, gets a financial reward and his solution is broadcasted to all the other nodes.
How proof of work actually works?

With SHA256, one can get Y from X, but cannot get X back from Y. This is called a one-way function and is often used in cryptography. Bitcoin wallet address, for example, is an output of a private key, which is hashed into a SHA256 output.

Example of SHA256 hashed word “NiceHash”:
D22df564d771ed4e6785029de215e9f9e2affe9bbe37bacc8544c32f0a162ba3

Word NiceHash acts as a private key and the output is a public key. It would be practically impossible to reverse the function and find out what it means without the private key or input data.

Note that Sha256 can be used with an infinite amount of data, it can be even used with images. 

Try it yourself:

If a miner has some input data, he will get a long random string, which cannot be reversed. But blockchain uses another string called a nonce (number only used once). By using a nonce, a miner can manipulate the SHA256 output to guess the desired output.

Blockchain network will for example set a desired output to start with 6 zeroes, for example: 000000c49ede7f965ba8e7e6419d6efb0afc99e7ecd10095b286310ca55a6355

The miner will literally guess the nonce until the block hash output will start with 000000. This is what miners do, they combine block transactions as a data input then guess the nonce, until the SHA256 output starts with 000000.

Input random data in the form below and try to find a hash that starts with four zeroes (0000) by guessing the nonce:

Or simply press MINE to find the correct nonce automatically.

Note that this is a simplified version. A miner must also include previous block hash output in the data input alongside the transaction data. Also, with increasing difficulty, the number of zeroes increases, which makes guessing the correct nonce less likely to occur, therefore it is more difficult to guess the correct output hash. It is easier to find output with one zero (0) than with four zeroes (0000).

0 Comments:

Earn