WHAT: Bitcoin mining is a peer-to-peer network process that verifies and secures Bitcoin transactions and adds transaction records to Bitcoin’s public ledger which contains all past transactions (i.e. blockchain) via the use of computer processing power provided by miners.
WHY: Miners keep the blockchain consistent and unalterable by grouping new transactions into a block, which is then sent to the Bitcoin network and verified by recipient nodes. Each block contains a SHA-256 hash algorithm of the previous block.
To be accepted by the rest of the network, a new block must contain a proof-of-work (PoW); who’s origins go back to Adam Back’s 1997 DDoS and anti-spam system Hashcash. PoW requires miners to find a number called a nonce; when the block content is hashed along with the nonce, the result is numerically smaller than the network’s difficulty target. For a secure cryptographic hash, miners must try many different nonce values (usually the sequence of tested values is the ascending natural numbers: 0, 1, 2, 3, … before meeting the difficulty target.
PoW plus blockchains makes ledger modification extremely hard, as an attacker must modify all subsequent blocks in order for the modifications of one block to be accepted by all. As new blocks are mined the difficulty of modifying a block increases as time passes and the number of subsequent blocks that are confirmed increases.