To form a distributed timestamp server as a peer-to-peer network, bitcoin uses a proof-of-work system similar to Adam Back's Hashcash and the internet rather than newspaper or Usenet posts. The work in this system is what is often referred to as bitcoin mining.

The mining process involves identifying a value that when hashed twice with SHA-256, begins with a number of zero bits. While the average work required increases exponentially with the number of leading zero bits required, a hash can always be verified by executing a single round of double SHA-256.

For the bitcoin timestamp network, a valid "proof-of-work" is found by incrementing a nonce until a value is found that gives the block's hash the required number of leading zero bits. Once the hashing has produced a valid result, the block cannot be changed without redoing the work. As later blocks are chained after it, the work to change the block would include redoing the work for each subsequent block.

Majority consensus in bitcoin is represented by the longest chain, which required the greatest amount of effort to produce. If a majority of computing power is controlled by honest nodes, the honest chain will grow fastest and outpace any competing chains. To modify a past block, an attacker would have to redo the proof-of-work of that block and all blocks after it and then surpass the work of the honest nodes. The probability of a slower attacker catching up diminishes exponentially as subsequent blocks are added. To compensate for increasing hardware speed and varying interest in running nodes over time, the difficulty of finding a valid hash is adjusted roughly every two weeks. If blocks are generated too quickly, the difficulty increases and more hashes are required to make a block and to generate new bitcoins.

Bitcoin mining is a competitive endeavor. An "arms race" has been observed through the various hashing technologies that have been used to mine bitcoins: basic CPUs, high-end GPUs common in many gaming computers, FPGAs and ASICs all have been used, each reducing the profitability of the less-specialized technology. Bitcoin-specific ASICs are now available. As bitcoins become more difficult to mine, computer hardware manufacturing companies have seen an increase in sales of high-end products.
Computing power is often bundled together or "pooled" to reduce variance in miner income. Individual mining rigs often have to wait for long periods to confirm a block of transactions and receive payment. In a pool, all participating miners get paid every time a participating server solves a block. This payment is proportional to the amount of work an individual miner contributed to help find that block.

In Cloud mining equipment is hosted in a data center. Mining power is sold for a certain period of time. Cloud mining providers generally use "pooled" mining to to speed payouts.

GPU-based mining rig
Lancelot FPGA-based mining board
FPGA-based mining board
Avalon ASIC-based mining machine


A rough overview of the process to mine bitcoins is
  New transactions are broadcast to all nodes.
  Each miner node collects new transactions into a block.
  Each miner node works on finding a proof-of-work code for its block.
  When a node finds a proof-of-work, it broadcasts the block to all nodes.
  Receiving nodes validate the transactions it holds and accept only if all are valid.
  Nodes express their acceptance by moving to work on the next block, incorporating the hash of the accepted block.
Nodes generally work on extending the longest chain to avoid wasting their efforts. If two nodes broadcast different versions of the next block simultaneously, some nodes receive one before the other. In that case, they work on the first one they receive, but save the other branch in case it becomes longer before they complete their own extension. The tie is broken when the next proof-of-work is found and one branch becomes longer; the nodes that were working on the other branch switch to the longer one.

Transaction broadcasts do not necessarily reach all nodes. As long as they reach many nodes, however, they will get into a block. Block broadcasts are also tolerant of dropped messages. If a node does not receive a block, it can request a resend when it receives the next block and realizes it missed one.

Mined bitcoins

By convention, the first transaction in a block is a special transaction that produces new bitcoins owned by the creator of the block. This is the incentive for nodes to support the network. It provides the way to move new bitcoins into circulation. The continual and steady addition of new coins is analogous to gold miners expending resources to add to gold stocks. In this case, it is computing power (CPU time) and electricity that is expended.

The incentive can be funded with transaction fees. If the output value of a transaction is less than its input value, the difference is a transaction fee that is added to the incentive value of the block containing the transaction. Once a predetermined number of coins have entered circulation, the incentive can transition entirely to transaction fees and coin creation ends.

Mining versus attacking

The incentive may help encourage nodes to stay honest. If a greedy attacker is able to assemble more CPU power than all the honest nodes (a 51% attack), the attacker would have to choose between using it to defraud people by stealing back their payments, or continuing to use it honestly to generate new coins. The attacker ought to find it more profitable to play by the rules, such rules that favor them with more new coins than everyone else combined, than to undermine the system and the validity of their own wealth.