Thoughts on Bitcoin Mining

Alright, I wrote about Bitcoins before, but I never really understood it very well. Bitcoins are a digital 'currency', that is, digital money that is generated by making your computer do a whole lot of CPU/GPU-intensive calculation. The introduction to Bitcoins is probably best done by Wikipedia's article on Bitcoins, which explains quite well how they can be used. You may ask why this is interesting. Well, I just made $400 by generating and trading in Bitcoins, much like a foreign exchange market. Here's my thoughts.

In December 2010 I used one of the websites that allow trading in bitcoins for US dollars, MtGox. Getting the money there from a European bank account is either very difficult, very high in fees, or both. I planned to exchange $1000 for bitcoins, but I chickened out at the last minute and tried it with $100 instead. The exchange rate at that time was about 0.25 dollars to one bitcoin. Last week, about 2 months since that investment, the exchange rate soared at 1.04 dollars for one bitcoin. I missed my cashing-out window a bit and it soon dropped back to ~0.8/0.9, but still, the gains were huge, and I very much regret not investing $1000.

Let's start at the beginning. What are bitcoins? Essentially, they are hashes of numbers, a mathematical function that is easy to calculate in one way, but very difficult to calculate in the other. It takes tremendous to predict, given a hash of a number, which number originally belonged to it. Vice versa, you have no idea what hash you are going to get until you actually calculate it. This is the essence of a 'raw' bitcoin. The bitcoin network gives out 'challenges'. An example is "find me the numbers that generate hashes whose numerical value is less than a certain amount". Because you don't know what the output of the hash function will be, your pc will just have to generate (semi-)random numbers, hash them and compare the output. If you're lucky, one of those hashes is indeed the answer to the challenge, in which case it will be transformed into bitcoins.

So, for some reason I don't quite understand, the bitcoin network uses a 'difficulty' setting. This basically regulates which hashes will be turned into bitcoins. You can think of the coin generation happening in rounds. The client knows which round it's on because it has a history of all the generated blocks. And given that the round is x, only hashes with a numerical value lower than y will become valid bitcoins. This difficulty level is increased every couple of rounds, with the goal of always generating roughly the same amount of coins in the same amount of time. As far as I can tell, this is probably being done to prevent the market from suddenly being flooded with a whole lot of bitcoins, which would severely destabilize it. Since all clients are bound to this difficulty setting, it's pretty much impossible to generate massive amounts of coins all at once.

As a side note, I'd like to mention that the bitcoin network is quite crucial to validating this money. Each node in the network has the complete history of bitcoins and transactions. And because each client is running the same code, they know how to reject fake coins. It is very feasible to generate a fake coin and push it to the network, but it would be completely useless because you wouldn't be able to spend it. The network also knows about the history of each bitcoin, which makes it even more difficult to mess with.

Probability is what makes this process interesting. As I mentioned before, the difficulty level pretty much determines how many percent of hashes will become bitcoins in that round. So at that point it's just a matter of probability. For example, if only 1 in 2 million total hashes is a hash that can become a bitcoin, and your computer can calculate 2 million hashes per second, then you will definitely have found the bitcoin after one second. But there's also a 50% chance that you'll have found it after 0.5 seconds! Because of this even slow computers can participate. Even though they are very unlikely to find a bitcoin, multiply that chance by the amount of time spent, and eventually everyone will hit the jackpot. (Note: the difficulty becomes increasingly higher each round, so if you're not calculating fast enough the chance that you won't find any hashes before the round is over becomes higher. So you do need to keep up with the network).

There are risks. Although each client uses their own unique combination of variables (eg. their account number, history of transactions etc.), there is a small chance that other people will be calculating the same hash as you. So if they find the bitcoin first, you're screwed. This hasn't happened to me yet, but it could. It's all about probability.

One of the most interesting recent innovations, is the introduction of clients that generate their hashes on the graphics card - GPU miners using OpenCL. Amazingly, the fastest graphics cards are 10 to 100 times faster than the fastest CPUs available (for calculating hashes, anyway). My Intel i7 950 can generate  about 18 million hashes per second, but my Radeon HD6870 graphics card does 230 million, more than 10 times as fast as my CPU. Using the probability calculator here you can estimate how long it will take you to find a valid hash, currently worth 50 bitcoins. (The amount a valid hash is worth halves every x rounds. So far, about 110000 rounds have taken place, and the value of newly generated coins is scheduled to be halved at round 200000-ish).

When I first found this out, I was seeing dollar signs in my eyes and planning my trip to Hawaii. After all, it's free money, right? All you have to do is run your PC and it generates money. If the exchange rate keeps around $1 per bitcoin you're earning $50 a week if you use one PC. Add another graphics card, a couple more PCs, and you can basically multiply that amount by whatever hardware you throw at it. I calculated how much money I would spend on electricity, and it's only a small portion of the profits. Believe me when I say that, given that like me, you pay ~$0.25/KWH and the USD/bitcoin exchange rate stays the way it is, you will make way more money from the generated bitcoins than it will cost you on electricity.

But there's two major catches, and possibly a third one too. First of all, there's the very real possibility that the bitcoin value will go down. It's not really worth $1.00 if you only spent $0.25 generating it. As more people generate coins, the market will be flooded with coins being offered without people wanting to buy them. After all, why would you buy if you can just generate them? I think this is a very real possibility, despite the people at the bitcoin forums being very optimistic. Some analysts are predicting that the exchange rate will soar up to $10 per coin. I really can't see how given that there is as of yet so little demand for them.

The second big issue is the difficulty factor of the network. Every iteration it becomes harder and harder to find the suitable hashes. It takes me on average 8 days to find a winning hash and be awarded 50 bitcoins. As more people join the network, more bitcoins will be found, and the difficulty factor will be increased. It won't be long from now until it takes me 16 days to find the right hash. It'll just keep increasing, keeping the amount of bitcoins in the system very stable, but the amount of bitcoins awarded to each individual becomes less every time. This seems a bit odd to me.

The third thing that worries me and that might grow into a big issue is the popularity of the bitcoin system. As I mentioned before, the more people join, the smaller the individual payout becomes. If all of these bitcoins are traded for USD then the exchange rate will end up very poor indeed. But if people could actually use the coins to pay at actual shops for actual products and services then the currency would be a lot more stable. There's a whole list of sites that accept payment in bitcoins, and that list is growing every day. But if there will never be any mainstream acceptance then who knows what will happen to the value of a bitcoin. It probably won't be good.

I should note that a nice quirk of this system is that anyone who has bitcoins has a vested interest in helping the system expand and catch on. Because once bitcoins gain more popularity, their value will go up, and everybody who owns bitcoins becomes richer. It's a very simple idea, and it's super effective.

Personally I'm not sure if it's a good idea either to buy bitcoins with USD or to generate them yourself. While I expect them to lower in value this year, they still might be a good investment on the long term. Technically I've never seen such a robust system. I keep thinking of ways to sabotage it so I can get rich quick, but I really can't think of any. It's secure. The bitcoins themselves are stable, even if the market isn't. It's an emerging market, and I think it might well be worth the risk. As for me, I'm going to buy a second graphics card with the money I've earned from the bitcoins. That way I can generate coins twice as fast, as well as enjoy a good game every once in a while :)

If my explanation is wrong in any part, please let me know. I tried to explain it to the best of my ability, but I may have overlooked or misexplained some part. Thanks.

Posted in Tech | Tagged