How to achieve Proof of Work?

in miner •  6 years ago 

Mining involves the process of producing a hash whose value is less than the target value. When this hash has been found, it is called a valid hash and hence proof of work is achieved.

The mining algorithm uses a counter known as the nonce to generate the hash using the SHA256 cryptographic function. A hash algorithm always produces the same arbitrary length data given the same inputs. It is impossible to compute the same hash with two different inputs. It is also impossible to predict the output of any given data in advance.

The value of nonce is initialised to 0. Mining is finding the nonce, the only input that changes every time we run the hash function. The goal is to find a value for the nonce that will result in hash lower than the target. So, the mining node might need to try billions or trillions of nonce values before it gets a valid hash. As you can see, mining is like playing the slot machine, there is no way to predict when can you strike a jackpot.

It is very easy to prove that the nonce found indeed produces a valid hash. All the information are available, everyone in the network can run the hash function and confirm if the hash is valid or not. Because it is also impossible to predict what the nonce will be, it also acts as a proof that the miner has indeed achieved Proof-of-Work.

Calculation of the Valid Hash

(The numbers are based on block #540909)

The formula to calculate the current target of the block is

Current target= maximum target / difficulty

Maximum target is set to

0x00000000FFFF0000000000000000000000000000000000000000000000000000

This is a hexadecimal number. After conversion to a decimal number

Maximum target= 26959946667150639794667015087019630673637144422540572481103610249215

Difficulty is (as given in the block)

7019199231177.17

Therefore,

Current target=(26959946667150639794667015087019630673637144422540572481103610249215)/7019199231177.17

= 3.84089×10^54

The hash of the block is

00000000000000000000ef17668e407e78c5a247f731b1138ad16f5bf79f1c0d

After converted to a decimal number, the value is as follows:

89454716205495239548871016846060264708718561584946189

The hash value is approximately 8.95×10^51

Clearly, the hash value is less than the current target, therefore it is a valid hash.



Posted from my blog with SteemPress : http://www.blockchainguide.biz/how-to-achieve-proof-of-work/
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Hi! I am a robot. I just upvoted you! I found similar content that readers might be interested in:
https://dev.to/damcosset/blockchain-what-is-mining-2eod

In order to achieve success, your desire to succeed should be greater than your fear of failure