Earlier I wrote about bitcoin and its potential to revolutionize the monetary system beyond all recognition. Over the past weeks the digital currency has attracted quite some attention. From politicians (who want to forbid it), economists (who test its merits against their theories) and thieves. The traction is driving up the exchange rate. A year ago, when only hardcore enthusiasts were in the game 1 bitcoin (BTC) was worth a couple of dollar cents. Today buying 1 BTC exchanges for $16. Bitcoins are generated through a process called mining. And because it is an open source, peer-to-peer currency everybody can start mining. But what exactly is mining and what hardware do you need to get started?

Bitcoin is the world’s first decentralized currency. This poses challenges to preventing double spending. In a traditional centralized money system, all transactions are monitored by a single authority. Because the central authority is aware of all transactions, it can verify that money isn’t spent twice and subsequently approve the transaction. Bitcoin, on the contrary, has no central authority to clear transactions. The bitcoin infrastructure is peer-to-peer, a distributed network in which all the nodes are equal. Therefore, in order to prevent double spending all the nodes in the network need to be aware of all transactions. To achieve this, all transactions are publically announced to the network. When the transactions are approved they are added to a log that records the history of all transactions. To secure the log from being tampered with bitcoin founder Satoshi Nakamoto came up with a solution: hashing and proof of work.

What is mining?

The data about new transactions is sent to the entire network in portions called blocks. The nodes in the network turn the data of the block into a hash function. A hash function is a mathematical function that turns a large dataset into a small datum which can look like this: 93ef6f358fbb998c60802496863052290d4c63735b7fe5bdaac821de96a53a9a. A certain data set will always yield the same hash value. But a slight change to the data will yield a completely different hash. So once the block is hashed, the data in the block can’t be altered without changing the hash.

Every block contains the hash of the previous block linking all the blocks together in a block chain. Going all the way back to the first block or genesis block. This block chain is the log of the history of all approved transactions. Changing the transaction history in an approved block would require making a new block containing the same predecessor. And because all the blocks that come after it include the hash of that block, they too need to be regenerated. To make it extremely difficult to change the hash of an approved block and redo all the work of the blocks that come after it, proof of work is introduced. A proof of work is a piece of data which is difficult to produce. In case of hashing the blocks this is done by introducing a difficulty target.

A hash is easily created, a computer can do it almost instantaneously. But in order for a hash to ‘sign’ for a block it needs to meet a certain condition. For instance, it is preconditioned that the hash has to start with four zero’s, this is called the difficulty target. To find a hash that meets the difficulty target the computer adds random data to the block. There is a special field in de block header where this random data can be added which is called the nonce. The computer has to generate millions of hashes until the right nonce input is found to generate a hash that starts with four zero’s. There is no method to find a hash value below the target other than brute force work. This takes up a lot of resources (time, electricity) therefore finding the hash that meets the difficulty target constitutes proof of work. The difficulty target is set thus, that it takes the combined computing power of the entire network to generate a valid hash every ten minutes. Inserting a counterfeit block into the block chain requires redoing all the work that is done by the network as a whole. This means it can only be done by a user who controls more than half of the network’s computing power.

Once a hashed block is approved by the network and added to the block chain a reward of 50 BTC is issued to the individual node that offered the first solution. That is why the labor of hashing the blocks is called mining. The reward serves as an incentive for the nodes to spend resources hashing the blocks and thus secure the network against double spending. Which node is the first to find a hash below the difficulty target is ultimately a matter of chance. But of course the more computing power a miner has to his or her disposal the greater the chance to find the solution and collect the coins. The more Mhash/s (million hashes per second) the hardware can achieve, the greater the chance to be rewarded bitcoins.

Hardware

In the early days of its existence the bitcoin network consisted only of a few nodes. Therefore the difficulty target was so low you only needed a minimal amount of computing power to mine for bitcoins. The early miners used the CPU of an average computer to crunch the numbers. CPU mining is now virtually dead and miners have moved on to GPU’s. A CPU or Central Processing Unit is the main executive of the computer. It carries out the instructions of the computer program loaded onto the computer. Because it is designed to quickly switch between tasks rather than dedicate itself to a single task, it can do hashing but it’s not particularly good at it. A GPU or Graphics Processing Unit is built to perform a specific task. They are used for gaming and video editing, telling over a million pixels what to do in order to build an image on the screen. Because they are designed perform complex but repetitive mathematical calculations they are much better at hashing than CPU’s.

You can build a dedicated mining system. For instance, putting together a MSI 890FXA-GD70 motherboard, a AMD Sempron 140 CPU and three Radeon HD 6990 GPU’s will yield approx. 2.1 Gigahash per second (Ghash/s). What to keep in mind when setting up a mining rig is the cost of the hardware and the energy consumption as these constitute the money investment that goes into the mining before you get anything out of it. The mining rig above (including casing, power supply unit etc.) will set you back $3,021 (€2,132) and drawing approx. 1,3 Kw/h. The cost for electricity depends on your local utility rates.

At the current difficulty target the 2.1 GHash/s rig mines about 1.5 BTC every 24 hours which at the current exchange rate converts to $24. But nowadays one mining rig will make you a small fish in the pond. There are big players who mine with 48 GPU’s or more like the guy in the video below, who aspires to hash 44 GHash/s. You could consider joining a mining pool where multiple clients generate blocks together and split the earnings.

FPGA vs ASIC

But GPU mining might become a thing of the past. As the bitcoin network is expanding rapidly the difficulty increases in order to keep block generation consistent at every ten minutes. There is a lot of talk in the bitcoin community about custom designing hardware for mining. The first open source FPGA bitcoin miner was released may 20 2011. An FPGA or Field-programmable Gate Array is a chip that can be configured after it is manufactured. A developer named Progranism released a code to turn a Terasic DE2-115 FPGA into a bitcoin miner. The FPGA hashes 80 Mhash/s (M for mega) and costs $595. Under the current circumstances FPGA’s can’t compete with GPU’s. They are too expensive and do not achieve great hashing performance. Nevertheless, there may come a tipping point where FPGA mining will be replace GPU’s because they use significantly less electricity. Each time the difficulty target is lowered more electricity is needed to generate a block. Up to a point where optimizing computing power per watt becomes relevant. Next to that, further development of the FPGA bitcoin miner might drastically improve its performance.

Another candidate for eventually replacing the GPU is the ASIC (Application-Specific Integrated Circuit). These single-purpose chips are even more expensive than FPGA’s because they are custom build. ASIC’s too use significantly less watt per hash/s than GPU’s and potentially yield more hash/s than FPGA’s. The time for ASIC mining may come when mining becomes so popular that someone is willing to invest in the engineering costs, trusting the market for dedicated mining chips will grow big enough to earn back the investment. But Bitcoin is still young and nobody really knows where it is going. Is bitcoin the currency of the future? Or is it a wildly interesting experiment in keeping track of transactions over a distributed network. The company LargeCoin bets on the former. They’ve announced to bring an affordable ASIC for hashing on the market this fall. And with the high and rising exchange rate, it may proof to be a good bet.


Photo: Lain