This is a primer on cryptocurrency (BitCoin, LiteCoin, etc.): what it is, how it works, and some specific (though probably ill-informed) recommendations from me if you are interested in mining it.
Crypto-what now?
Cryptocurrency is the name given to any currency based on a couple of key concepts and a common theoretical architecture. The first cryptocurrency was BitCoin, which "set the mould" for what it means to be a cryptocurrency. Another important cryptocurrency is LiteCoin, which has a couple of key differences from BitCoin that will be covered later. In addition, there are now dozens (if not hundreds) of "AltCoins"; that is, other cryptocurrencies in addition to BitCoin and LiteCoin. They have many of the same features and underlying concepts, but have small yet important tweaks or differences that make them suitable for specific niche purposes.
Cryptocurrencies have two central features that make them unique from normal "fiat" currencies:
- anonymous transactions
- no central processing or legal authority
Why do I care?
Let's say I have $50 and I want to give you $5. How do I do this? Well, if we can meet in person I can just give you a $5 bill. That's an anonymous transaction to the rest of the world, but it's not anonymous between us. Further, in an online and interconnected world, it's really inconvenient to have to meet in person any time we want to exchange money.
Another option is that I can keep my $50 in a bank account and then tell my bank to send you $5. This means my bank will subtract $5 from my account, then my bank will tell your bank to add $5 to your account. This works because we both trust our banks to perform this transaction (typically backed by government regulations), and likewise the banks trust each other.
This process works really well and is the basis for the modern financial system. However, this process is never anonymous because our banks know a lot of information about each of us. And you will never find a bank that doesn't, because in order to comply with banking regulations imposed by the government in most countries, a bank MUST collect this information about you or else the government won't allow them to be a bank. And if they aren't a bank in the eyes of the government, not only can they go to jail for trying to do "banking" things, but more importantly no other bank will trust them and they won't be allowed to participate in these kinds of transactions, which makes them kind of useless as banks.
On top of this, the transaction itself is logged by the banks and, again due to those government regulations, the processing authorities involved (typically quasi-governmental central bank agencies) can intervene at any point. They could tell our banks to stop the transaction, or reverse it, or even confiscate the transaction (or my entire account) for any number of legal reasons. This legal and regulatory framework and government involvement is, in fact, the very basis of a fiat currency, and is the reason familiar currencies (such as the Canadian dollar or the UK pound) are associated with a specific country. Those currencies are effectively defined by the laws of their relevant governments.
Now, it might sound quite paranoid to worry about a government confiscating my transaction or banks knowing who I am, and I personally believe that, yes, in reality those aren't things most people need to worry about most of the time. Not only that, but some of these things are actually positive attributes that most people WANT in a bank. I LIKE the ability to call my bank and cancel or reverse a transaction in the case of fraud, and I appreciate the fact that if my bank screws it up my government can fine or jail them or order my funds returned to me. These are useful and powerful features of fiat currencies!
But choice is king, and in the modern world there are enough people who ARE worried about the limitations of fiat currencies that there is a demand for a currency that can be used anonymously and without any potential for intervention from any central authority or government. Whether you personally worry about that or not, enough OTHER people were worried about it to figure out a way to do it. Thus, cryptocurrencies and BitCoin were born.
The Secret Sauce of Cryptocurrencies
Cryptocurrencies are based on asymmetric cryptography, hence the name. Asymmetric cryptography is based on decades of research into advanced mathematical ideas that are crazy genius. However, all you need to know are three basic facts:
- modern crypto is based on having a "key" that is split into two parts: a "private key" and its corresponding "public key"
- encryption: anyone with your public key can create a message that can only be read using your private key; everyone else just sees it as undecipherable gibberish
- signing: you can use your private key to "sign" a message (that anyone can read) and anyone with your public key can can verify that only you could have written the message
In this kind of system, "you" are anonymous because no one knows who you are. Instead, "you" are defined by the fact that you have the private key. Assuming you don't share your private key with anyone else, then no one else can pretend to be "you". You don't need to reveal your identity or register with a central authority to prove that a message came from you or to read encrypted messages sent to you. All you have to do is share your public key and then do a good job of keeping your private key secret.
Another key technology underlying cryptocurrencies is peer-to-peer networking (P2P). This is the technology underlying things like BitTorrent. Again it's not necessary to understand the technical details of P2P; all you really need to know is that it enables software on many computers to talk to each other (create a shared network) in a de-centralized fashion. There is no central authority managing the network or controlling who can connect to it, and yet everyone still manages to "get along". As long as your computer can find another P2P client to talk to, you can participate in the P2P network.
Transaction Redux
Given these key bits of technology, let's now examine the case where I have 50 "coins" and I want to give you 5 of these coins. We'll ignore for the moment how I got a balance of 50 coins (or how anyone knows I have this balance, though that will become clear shortly). How can I do this without bank accounts, or even banks, or any central authority enforcing transactions?
In cryptocurrency lingo, I have a "wallet" that contains the 50 coins, and you have a wallet where I want to transfer 5 of those coins. A wallet has an address (a string of letters and digits) and each wallet is associated with a public key. I can prove to other people that I "own" a wallet because I'm the only one who has the matching private key for the wallet. Only I can sign public messages sent from the wallet. Note that in real usage, you'll actually have many wallets. At least one for each cryptocurrency you use, and often several for a single currency that you use for different purposes. This is kind of like having multiple bank accounts.
Now, I can create a message from my wallet and sign it with my wallet's private key that says "Hey, I'm taking 5 coins from this wallet and putting them in your wallet". Now, assuming I can find you to give you this message, you can verify that I am, in fact, the owner of the "from" wallet because I signed it with the private key. Great! I've "given" you 5 of my coins! Of course, at this point only you and I know anything about this transaction. You know those 5 coins now belong in your wallet, but I could easily lie to everyone else and tell them I still have all 50 coins I started with.
The trick here is the P2P network. Instead of only giving YOU the message that I'm taking 5 coins from my wallet and putting it into your wallet, I'll give EVERYONE that message. The entire P2P network will get the message that my wallet is sending your wallet 5 coins. They can all verify that it is a valid message that could only have been sent by someone who has the private key to my wallet. Now the entire network agrees that, in fact, my wallet now only has 45 coins and your wallet received the other 5 coins. Interestingly, you don't even need to get the message for the transaction to have taken place. Everyone else agrees that your wallet now "owns" those 5 coins, even if you don't get the message right away.
Finally, if we track every transaction ever made in this manner from the beginning of the currency, it becomes obvious why the network accepts the fact that I had the 5 coins to send to your wallet in the first place. Somewhere in the history of transactions, my wallet must have received those 5 coins from someone else. A wallet address that has never been seen before must have 0 coins, so the only way my wallet could have 5 coins to send to you is if I can prove via some other verified and confirmed transaction in the P2P network that my wallet received those 5 coins from somewhere else.
This complete record of every coin moving between every wallet is called the "block chain". Each cryptocurrency has its own block chain stretching back to the beginning of the currency. It contains a complete record of every transaction ever made. Counter-intuitively this completely open and transparent system, in which I can see the flow of currency from every wallet to every other wallet, is 100% anonymous. Because each wallet is just a random identifier, and because all I need to prove I "own" a wallet is the private key, there is no way for anyone to know who I am. I can prove I own a wallet and that a transaction is valid without sharing any personal information of any kind. For all I know, every transaction that ever happened in the currency is just one guy sending stuff back and forth between all his millions of wallets.
Further, it's also 100% de-centralized. Because all of these messages happen on a P2P network, there is no central authority that can control the process. As long as I find enough P2P clients to confirm the transaction and the message gets to most of the P2P clients eventually, it's practically impossible to forge or undo.
The Two Big Gotcha's
This de-centralized and anonymous nature does have two significant limitations. One is a simple result of there being no central enforcement body. As a natural result, there is NO WAY to reverse a transaction! Once I create a message that I'm sending coins from my wallet to your wallet and it is confirmed in the block chain, I CANNOT undo that transaction! I no longer own those coins. The only way to "undo" the transaction is if YOUR wallet sent the coins back to me, voluntarily. This means that when doing business with coins you'd better trust the other person or else use a trusted 3rd-party/escrow agent. There is no bank or credit card company to call to reverse a transaction if you are being swindled or defrauded.
The second major issue has to do with the specifics of how all the transaction confirmations are handled and the way the block chain is created over time. I won't cover the very technical details, though I will talk about the block chain more in the mining section coming next. However, the important take-away is that if a single entity gains control over more than 50% of the block mining effort (NOT 50% of the P2P network, but 50% of mining new blocks), they can subvert the entire process! They can lie and cheat and forge information about past and present transactions.
Mining Blocks
If you were paying close attention in the previous section, you might have noticed one missing detail. If every new wallet starts out empty, and if the only way to "own" coins in a wallet is to have a valid transaction showing that the wallet received coins from somewhere else... then where do the coins actually come from?
The answer lies in the specific details of how the block chain, or transaction ledger, is created and updated over time. For a number of technical and practical reasons that I won't get into, the transactions in the P2P network are organized into "blocks". A single block records all of the transactions and confirmations that have taken place since the previous block. Once a new block starts, the current block is "closed out" and added to the block chain.
However, the only way for the current block to end and the new block to start is if someone FINDS a new, valid block. The process of looking for the next new valid block is called "mining". Again, due to super genius math that I won't cover, everyone on the network knows what the next valid block should look like so they can all agree when somebody finds it. But nobody actually knows how to find it except by random chance. Finding the next block takes a ton of processing power, trying random numbers over and over (and over and over... billions of times). If you happen to be the one who finds the next valid block, your reward is to get some coins "out of thin air" as part of that block. When you find the new block and then tell everyone on the network about the new block, they all agree that the first transaction recorded in the block is you adding "new" coins to the wallet of your choice. This is how new coins come into existence in the currency.
The block mining process has two key inputs that are initially set by the original creators of the currency: the block reward and the difficulty factor. They are based on algorithms and consensus within the P2P network, so while the starting values are set arbitrarily by the original creator, they can't just be changed arbitrarily afterwards.
The first key input is the number of coins to reward to the person who finds each block. For instance, when BitCoin first started, the reward for finding a new block was 50 coins. However, everyone also agreed that the reward would be cut in half each time 210,000 blocks had been found. Since there are currently 279,748 blocks, the current reward for finding a BitCoin block is now 25 coins. Once the 420,000th block is found, everyone will agree to cut the reward in half again.
The second key input is the difficulty factor. The goal of mining blocks is to find a new block after a certain amount of time has passed. For BitCoin, the target is for someone to find a new block every 10 minutes. However, finding a new block is based on random chance, and the number of "random guesses" being made is dependent on how many people are mining and how fast their computers are. If the random chance were fixed, then as more people mined with faster and faster computers, blocks would be found more quickly. To avoid this, the difficulty factor is used to adjust what the next valid block "looks like" in a way that makes it easier or harder to find. In BitCoin, the difficulty factor is adjusted every 2160 blocks (based on an initial algorithm and by consensus on the P2P network) so that, based on how many people are mining and how fast they are mining collectively, it will always be about 10 minutes (on average) until someone randomly finds the next new block.
I'm a cryptominer and hash a-way, I SHA all night and I scrypt all day!
The process of finding a block involves "hashing". Everyone on the network knows what the hash of the next block needs to look like, but because of the nature of hashing, there's no way to know how to FIND a hash that looks like that except to just hash random values over and over until you find it. This is the part of the process that takes "work" (computing power) to do.
In a cryptocurrency, the type of hashing being done has a big impact on how "hard" the work of finding the next block really is. BitCoin uses a hashing algorithm called "SHA-256", which has an important trait in that it is not hard "equally". Specialized hardware using ASIC's can be MUCH more efficient at hashing SHA-256 than a typical CPU or video card. An ASIC is basically a custom microchip that some very smart people with EE and CompE degrees have created from scratch. It costs them hundreds of thousands of dollars in research and development efforts to do this, and ASIC-based miners often sell for upwards of $10,000. But they are so much better and faster at mining SHA-256 than a CPU or video card that if you don't have an ASIC miner you might as well not even bother mining a SHA-256 based currency (like BitCoin).
Why does this matter? Well, if you recall earlier I pointed out one key weakness in the cryptocurrency architecture is that if any single entity gains control over more than 50% of the mining efforts, they can subvert the whole block chain process. The more expensive it is to get into mining, and the more custom hardware that is required, the more likely it is that the mining efforts will become consolidated into the hands of a few rich people who can afford the investment. This isn't a fatal flaw, but it is a danger.
In order to avoid this problem, another group decided to come up with a cryptocurrency based on a hashing algorithm that would stay "hard" even on ASIC's. This meant that ASIC's would not have a giant advantage over miners using modern video cards. Since there is a huge pool of people with advanced video cards, and since this pool is not going anywhere since it's not based on cryptocurrency mining but instead on playing video games, then as long as mining on ASIC's isn't much more efficient than mining on video cards, there should always be a large pool of people willing to mine without the high barrier to entry of having to buy specialized ASIC hardware. This algorithm is called "scrypt", and the first currency to use it was LiteCoin.
The benefit is that this keeps the cost of entry lower, hopefully leading to more diversity among miners and reducing the chance that any single entity could ever get more than 50% control of the mining effort. The key difference with scrypt is that it requires a lot of memory, and video cards just so happen to be very fast processors attached to very fast memory. ASIC's designed to mine scrypt currencies still require fast memory too (and a fast memory controller), so it can't be much cheaper than an equivalent video card. Anything that makes memory faster or cheaper will benefit video cards just as much as ASICs. While an ASIC scrypt miner can certainly be a bit more efficient (typically in terms of power usage), it should never become such an overwhelming advantage that mining scrypt currencies on video cards becomes pointless like it has for SHA-256 currencies.
AltCoins
There are now dozens (if not hundreds) of alternate cryptocurrencies in addition to BitCoin and LiteCoin. These are collectively referred to as "AltCoins", and most of them are based on the scrypt hashing algorithm.
The reason for this proliferation of currencies is two fold. One, sometimes there are actual practical reasons for a new cryptocurrency to exist. For instance, someone might have a use case where they want to tweak the block reward or target "time until new block" for various practical reasons. Or the currency might exist to support some other process; for instance, the process of finding and exchanging cryptocurrency can be an effective way to enforce network limitations or access control. There are cryptocurrencies that exist solely so that regular users of a network won't notice the processing power required to mine coins to "spend" on participating in the network, but spammers would have to devote a ton of resources just to mining currency in order to "pay" the cost required to spam the network. So there are some altcoins that exist for practical niche reasons.
The second and more common cause of proliferation is greedy speculation. A side effect of the mining process and the cryptocurrency architecture is that, at the start of a cryptocurrency's lifetime, it is MUCH easier for a single person to find new blocks since fewer people are mining the currency. This means that if you start mining a cryptocurrency very early on, you will get a large number of coins from mining while the difficulty is very low. If the currency then becomes popular later on, this speculative mining can pay off in a big way.
Of course, this only works if you get in on mining a currency very early in its lifetime and if the currency then becomes popular enough to have real value. What better way to be the first to mine a currency than to make a brand new cryptocurrency of your own? And thus, a ton of altcoins are born. Realistically most of these are speculative currencies created by people trying to get rich quick, while simultaneously trying to convince you that there is a real reason for the currency to exist (even though there probably isn't) so that it will become more popular... so that they (the early miners) can get rich quick. As such, you will see a lot of fervor and passion in early cryptocurrency adopters trying to promote whatever altcoin they've dedicated speculative mining efforts into (see, for example, coinye, DOGEcoin, Memecoin, etc.)
Cashing out (or in)
So... how do you turn a fiat currency (like, say, Canadian dollars) into a cryptocurrency? Or vice versa?
More and more, you can often avoid this question entirely. Every day more retailers and businesses are supporting transactions directly in the common cryptocurrencies of BitCoin and LiteCoin. For instance, EasyDNS, my preferred DNS registrar, let's you pay your domain registration and renewal fees directly in BitCoin.
That said, at the end of the day you still need a way to convert cryptocurrency to fiat currency (and back again). To do this you need a bank or currency exchange that supports both. Most exchanges of this kind only deal in BitCoin or, sometimes, LiteCoin. Once you have BitCoin or LiteCoin you can then transfer it to other wallets or other exchanges where you can convert it into other altcoins. Likewise, you can turn your other cryptocurrencies into BitCoin or LiteCoin and then transfer it to an exchange lets you turn that into fiat currency.
Since this exchange will be dealing with fiat currencies, any legitimate exchange of this kind will be doing its best to comply with local laws and regulations for banks or money exchanges. The legal implications of this are kind of up in the air right now in most countries and it's all a bit gray, but if the exchange you use isn't thinking about this aspect at all, chances are they (and you) are in for a big surprise some day.
Because the exchange must deal with government regulations, the exchange that works for you is going to depend in large part upon which country you live in and which country's fiat currency you want to use. In Canada, two major exchanges are CA VirtEx and the Vault of Satoshi. CA VirtEx has a cool feature where you can even get a debit card that works in all standard Canadian debit terminals that draws on your BitCoin balance behind the scenes. Pretty cool! Another popular exchange that supports US dollars is MtGox.
It's important to remember that the actual value of any cryptocurrency in terms of "real" fiat currency is completely dependent on the exchange rate between the two, just like the exchange rate for any two fiat currencies affects their relative value. Because cryptocurrencies are very young and niche, these rates can fluctuate wildly over short time periods. Cryptocurrencies are considered to be extremely volatile compared to most fiat currencies.
Mining and you; a practical guide
So, after all that... are you interested in mining cryptocurrency? Then read on!
1.21 Giga Hashes!?!?
The key metric you need to know for mining is the number of hashes per second you can perform. This is basically the number of "random guesses" per second you are making at trying to find the next valid block. Modern ASIC-based SHA-256 mining hardware is just now reaching several gigahashes per second (Ghash/s) while mining SHA-256 currencies (that's several billion guesses per second). In contrast, hashing SHA-256 on a video card is usually measured in, at best, megahashes per second (Mhash/s)... that's only several million guesses per second. You can see why ASIC mining is practically required for SHA-256 currencies.
For scrypt mining, a modern video card is typically measured in kilohashes per second (Khash/s). A good single video card setup will run from 100 to 400+ Khash/s, and ASIC's are unlikely to improve this number much for equivalent cost.
Profit
The most important thing about choosing to mine a cryptocurrency is to ensure that you aren't losing money on the prospect! If you are going to mine an scrypt-based currency on hardware and video cards you already own, then all you really have to worry about is the cost of electricity. Unless you are paying obscene amounts on your power bill, you are likely to come out ahead in this case.
However, the profitability calculation becomes much trickier when you are talking about buying new hardware JUST for mining. In this case you have to figure out how long it will take for that initial investment to pay off. The thing that is most often overlooked while trying to figure this out is the reality that, as time passes, the difficulty factor of the currency increases over time as more people are mining the currency more efficiently. Trying to estimate the profit (or loss) of buying new mining hardware depends on accurately estimating how this difficulty increases over time.
The previous point is critical, and can make a huge difference. If you could buy one of the most advanced $10,000 SHA-256 ASIC-miners today and have it mining BitCoin starting tomorrow, you could pay off the initial investment in a week and make a killer profit! However, if it takes 3 months for that same hardware to be delivered to you then, estimating with the current average increase in the difficulty factor for BitCoin mining, you would LOSE money. This problem is exacerbated in SHA-256 mining due to the recent introduction of ASIC-based mining hardware and the huge effect it has on the overall mining curve. If you can get your hands on an ASIC miner right now, you can make a killing, but by the time you actually get your hands on one... so will everyone else. And then you'll just be back to barely breaking even.
As a result of this, I'd strongly recommend starting with an scrypt-based currency (like LiteCoin) using hardware you already own. If you can't make a profit mining when your hardware costs are free (since presumably you already have a computer and video card that goes unused most of the time), then it probably wouldn't make much sense to invest a bunch in mining hardware either.
This calculator is a great tool for trying to determine profitability.
Mining Pools
While there was once a time when you could mine a currency on meagre hardware and find the next valid block all by yourself (thus keeping all the reward coins for you), that time has long passed. Unless you are investing thousands of dollars into a giant mining farm, the chances that you will find the next block yourself are pretty slim (and if you ARE investing thousands of dollars into a giant mining farm, you should probably find a better guide than this one!).
Remember, the chance to find the next block is completely random. You could find it on the very next hash, or never. When the overall mining difficulty was very low, the chance that you wouldn't find any blocks was also pretty low, so people could "solo" mine with reasonable results. But nowadays the chance that you are the lucky winner who finds the next block is extremely small.
To address this problem, miners consolidate their efforts into "mining pools". Everyone contributes to the pool by looking for the next valid block. They get a "share" of the pool based on the portion of work they do compared to everyone else. Once someone in the pool randomly finds the next valid block then everyone in the pool gets a split of the reward based on the number of shares they have contributed.
There are TONS of mining pools out there. I've settled on using TradeMyBit for a variety of reasons. First, it has sub-pools for many currency types so you can choose which currency you want to mine. Second, it has a "multi-pool", which allows you to mine the scrypt-based currency that is "most profitable" right now based on current exchange rates. Third, the mining pool servers (called stratum servers) have, so far, all been pretty reliable compared to other pools I've tried. Fourth, they aren't in any danger of reaching 50% mining share; remember, DON'T simply join the biggest pool you can find, you don't want any single pool to reach 50% mining share! Fifth, their fees are very reasonable compared to other pools I've looked at (the fee is simply the cut they'll take out of the shared profits to keep everything running).
Mining Software
Profitable scrypt mining uses modern video cards. If you are mining on an ATI card (Radeon), you want to use cgminer (note: use version 3.7.2 or lower; the 3.8 and 3.9 branches do not support GPU scrypt mining). If you are mining on an nVidia card, you want to use cudaminer.
I'm not going to cover setting up the miner software; there are a ton of guides out there (time to exercise your Google-fu!). However, here is a guide for cgminer on Windows and one for cudaminer on Windows. The mining pool you join will determine which stratum server you use, and many mining pools also have their own setup guides for the miner software.
AltCoin Exchanges
When mining currencies, especially AltCoins of any kind, you usually want to get your earnings transferred into LiteCoin and/or BitCoin. This is especially true if you are mining in a multi-pool setup like TradeMyBit where the currency you mine changes routinely to chase the most profitable exchange rates.
As such, you'll need exchanges that let you convert between all the various AltCoins and LiteCoin/BitCoin. The one I like to use is cryptsy (if you happen to sign up there, please use my referral link, thanks!). Cryptsy lets you setup wallets on their site for a bunch of AltCoins without actually having to download the wallet software for each and every AltCoin yourself. You can also setup automatic sell rules so that as soon as you receive deposits on those wallets they are automatically exchanged for BitCoin or LiteCoin. This works very well in conjunction with a multi-pool miner like TradeMyBit.
The Final Word
Cryptocurrencies are neat, and in many ways represent a far simpler and easier way to move monetary value around the internet in this day and age of international trade. There is even a cryptocurrency dedicated solely to simplifying the exchange of fiat currencies (ripple). As more and more online retailers and service providers begin to support direct BitCoin and LiteCoin payments, the landscape gets even more interesting.
Realistically a lot of the hype and buzz about cryptocurrency was from the speculation, bubbles in BitCoin value, and meteoric rise in BitCoin wealth for those lucky or smart enough to mine or invest in coins several years ago. For the rest of us, though, there is real, interesting, and practical value in the simple nature of cryptocurrencies far beyond this transient hype.