In proof-of-work cryptocurrencies like bitcoin and litecoin, mining is the process by which the blockchain – a distributed ledger of all transactions ever made on the network – is maintained. Miners receive transaction data broadcast by the various participants in the network since the last block was found, they assemble those transactions into structures called Merkle trees, and they work to find an acceptable hash.
A hash is a result of running a one-way cryptographic algorithm on a chunk of data: a given dataset will only ever return one hash, but the hash cannot be used to recreate the data. Instead, it serves the purpose of efficiently ensuring that the data has not been tampered with. Change even one number in an arbitrarily long string of transactions, and the hash will come out unrecognizably different. Since every block contains the previous block’s hash, the network can know instantly if someone has tried to insert a bogus transaction anywhere into the ledger, without having to comb through it in its entirety every 2.5 minutes.
The mining process illustrated. This image comes from our bitcoin infographic, but litecoin miners follow the same process.
Why must miners run these hash functions over and over again, if doing it once – a near-instantaneous process for a modern computer – would do the trick? The reason is that, by harnessing a lot of hash power, an attacker could spend some coins, then pile a huge number of spam transactions on top of it – ones that do not reference the attacker’s original spend. In this way they could spend their coins and have them too; this is known as a double-spend attack. By requiring the network to plug through millions or billions of hash functions, the blockchain generates so much “work” that undoing it or overwhelming it would be too expensive. (Since a given set of data only generates one hash output, miners must append meaningless numbers known as nonces to the end and run the function again.)
Mining is competitive. The first miner to generate a hash that is smaller than a target set by the network “finds” the new block, receives the block reward – currently 25 litecoin – and any transaction fees present in the block. Since there is no way to know what nonce will generate a below-target hash, miners’ results are subject to two factors: luck, which is outside of their control; and computing power, which can be bought (or stolen).
To maximize their computing power, miners have developed specialized gear to plow through hash functions as fast as possible. They have assembled enormous collections of these machines, pooled their resources, and concentrated in places where electricity is cheap, so as to maximize profits. These trends have led to the increasing centralization and professionalization of mining.