Proof of Work (PoW) describes a system that requires a not-insignificant but feasible amount of effort in order to deter frivolous or malicious uses of computing power, such as sending spam emails or launching denial of service attacks. The concept was adapted to money by Hal Finney in 2004 through the idea of «reusable proof of work». Following its introduction in 2009, bitcoin became the first widely adopted application of Finney’s idea (Finney was also the recipient of the first bitcoin transaction). Proof of work forms the basis of many other cryptocurrencies as well.
This example will focus on PoW as it functions in the bitcoin network. Bitcoin is a cryptocurrency that is underpinned by a kind of distributed ledger known as a «blockchain». This ledger contains a record of all bitcoin transactions, arranged in sequential «blocks», so that no user is allowed to spend any of their holdings twice. In order to prevent tampering, the ledger is public, or distributed; an altered version would be rejected by other users.
The method that users detect tampering in practice is through hashes, long strings of numbers that serve as proof of work. Put a given set of data through a hash function (bitcoin uses SHA-256), and it will only ever generate one hash. Due to the «avalanche effect»” however, even a tiny change to any portion of the original data will result in a totally unrecognizable hash. Whatever the size of the original data set, the hash generated by a given function will be the same length. The hash is a one-way function: it cannot be used to obtain the original data, only to check that the data that generated the hash matches the original data.
Generating any hash for a set of bitcoin transactions would be trivial for a modern computer, so in order to turn the process into «work», the bitcoin network sets a certain level of difficulty. This setting is adjusted so that a new block is mined – added to the blockchain by generating a valid hash – approximately every 10 minutes. Setting difficulty is accomplished by establishing a target for the hash: the lower the target, the smaller the set of valid hashes, and the harder it is to generate one. In practice, this means a hash that starts with a long string of zeros: the hash for block #429818, for instance, is 000000000000000004dd3426129639082239efd583b5273b1bd75e8d78ff2e8d. That block contains 2 012 transactions involving just over 1 000 bitcoin, as well as the header of the previous block. If a user changed one transaction amount by 0,0001 bitcoin, the resultant hash would be unrecognizable, and the network would reject the fraud.
A given set of data can only generate one hash, so how do miners make sure they generate a hash below the target? They alter the input by adding an integer, called a nonce (number used once). When a valid hash is found, it is broadcast to the network, and the block is added to the blockchain.
Mining is a competitive process. On average, someone will generate acceptable proof of work every ten minutes, but who it will be is anyone’s guess. Miners often unite and create mining pools to increase their chances of mining blocks, which generates transaction fees and, for a limited time, a reward of newly-created bitcoins.
PoW makes it extremely difficult to alter any aspect of the blockchain, because such an alteration would require re-mining all subsequent blocks. It also makes it difficult for a user or pool of users to monopolize the network’s computing power, because the machinery and power required to complete the hash functions are expensive.