Bitcoin is the one that started it all.
In 2008, someone called Satoshi Nakamoto released a paper, in which he described a way of implementing an electronic cash system without a central authority.
Creators of Bitcoin ran into a quite hard problem of making a truly free electronic cash. Electronic cash systems existed for years (for example, Paypal or Webmoney), but they all had one flaw — they required a central authority to operate. Centralized solutions like this are easier to implement, but they require a trust in the company that runs that solution. Not only the company can take the money and disappear, the can also be attacked by hackers. One security flaw can lead to the loss of billions of dollars. That way, running an ecash service by a single company seems like a practical solution, but it can be fragile long-term.
Once you decide to go without a single point of trust, you face another two problems: how to verify transactions and how to solve a double-spending problem? Here’re the solutions Bitcoin came up with.
First, how to make sure that person that made a transaction and the person that owns the money is the same person? This can be easily solved by cryptography. Each Bitcoin user starts by generating a private key. The process of generation is completely random, so no one can guess the key. Then, a math function is applied to the private key to make a public key, or a wallet address. The private key must be kept safe, while the public key can be shown to other people. From now, each transaction needs to be signed by the private key. Other people can easily verify that the signature is correct without knowing the private key. Only the owner knows the key, thus only the owner can make transactions and spend money.
Second, how to make sure that the person won’t spend his money twice? What stops him from making two transactions to different people and getting goods from both of them? This is called the double-spending problem. Bitcoin solves it by introducing public ledger and utilizing the consensus algorithm.
All transactions are grouped into blocks. These blocks contain a handful of transactions and also some meta information, like the time when the block was created and an index number of the block. The block also contains its hash, which is used to validate its integrity. The hash is based on the block content and the hash of the previous block. It means that changing the block (for example, by adding or removing a transaction) will change the hash. It also means that changing any block will change the hash of all subsequent blocks.
Bitcoin is a peer-to-peer network, and there isn’t a central authority that tells which transactions to approve and which not, so users should find a way to agree on that. The whole idea of consensus is to provide a fair share of power to vote on whether the transaction is good or bad. This is done by using proof-of-work algorithm. This algorithm requires a lot of computational work to be done to issue a block. Computers called miners try to find valid hash by brute-force. They try to find such number, that, together with block hash and the hash of the previous block, will form small enough hash. On average, all computers find new block every 10 minutes. If new miners connect to Bitcoin and start mining, the difficulty increases. The same is true when miners leave the network. The difficulty changes every 2 weeks.
The system is distributed, and there’s no guarantee that new blocks will reference the last one. Intentionally or not, forks may occur. A fork is a situation in blockchain when there are multiple versions of a chain. In that case, nodes refer to the longest chain. The “longest” here means not “the biggest number of blocks”, but “the most work is done”, so the chain that accumulated more proof-of-work wins.
To reward the miners, each block introduces new coins. These coins go the miner that found the block. Miner also receives transaction fees. Transaction fees are used when there are too many transactions, and not all of them fit into a block. Miners usually select transactions with biggest fees, so the bigger the fee, the higher the chances that a transaction will appear in the next block.
It is possible for someone to overwrite the history of Bitcoin. It is called 51% attack because to be successful, the attacker needs to get the majority of mining power. The attack is still possible if someone has less than 51% hashrate, but it is improbable. Say, someone who has 10% of mining power made a transaction which was included 6 blocks before, and he wants to overwrite this transaction. The only way to do that is to overwrite all 6 blocks and all other blocks that will be mined in future while he makes an attack. He has 0.02% chance to succeed, so he will succeed in 2 out of 10000 attacks. Not only this is a really low chance, the attacker will also waste a lot of money on electricity and ASIC miners.
Bitcoin proposed an efficient way of hashing the block content. Most of the data in a block are transactions. When we get the hash of the block, we need to calculate it based on the hash of all transactions, otherwise changing one transaction may not change the hash. To solve the problem, Bitcoin utilizes a data structure called Merkle tree. The Merkle tree is a binary tree where leaves are transactions from one block. On each level of the tree, two hashes are merged together to get a single hash. At the root of the Merkle tree, there is one hash formed by hashes of all transactions. This hash is included in the block header. Changing one transaction will change its hash, which in turn change the root hash.
Merkle tree also allows Simplified Payment Verification (SPV). Even if the node doesn’t contain the whole history of transactions (nodes like these are usually called light nodes), it can still verify that its transaction is included in the block. First, the node needs to get the number of the block to which the transaction was included. Then, it needs to download the branch of the Merkle tree that includes this transaction. Finally, the node needs to calculate all hashes of the branch and make sure that the root hash made from his calculations is the same that the root hash included in the block. If the hashes are equal, he can be sure that his transaction included in the blockchain without downloading the whole history of transactions.
Although light nodes can be used to verify their transactions, full nodes that contain the whole history are essential to Bitcoin network security. Without them, miners can agree on new rules, and no one will find out the fraud. For example, miners can increase mining rewards, and light nodes will never know it. Only full nodes are able to look at each block and verify whether it is valid or not. In short, some nodes can be light, but not all of them.
Bitcoin is not 100% private and never intended to be. Indeed, all transactions are public, and though instead of real names there are digital addresses, there are ways to de-anonymize Bitcoin users. One design flaw of a public ledger is that once you can link at least one transaction to the person, you can look all transactions made from his wallet, so you can know both the history of transfers made by this person and the balance of his wallet. One way to mitigate that is to use multiple wallets, or even use each wallet once, which is effective, but impractical. Another solution is to use mixers, which “mix” coins from multiple wallets. Using mixers is more convenient, but costs money and requires a trust in the company that organizes mixing.
What Satoshi Nakamoto did was a truly exciting invention. However, it’s worth to note that all the science and algorithms were known. Cryptographic signatures were used since the 80s. The proof-of-work of Bitcoin is based on hashcash, which was proposed in 1997 and was used to limit email spam and protect from DoS attacks. Merkle tree was introduced by Ralph Merkle in 1979. To make a Bitcoin, Satoshi connected right pieces together.
- October 31, 2008: Release of the paper “Bitcoin: A Peer-to-Peer Electronic Cash System” bitcoin.org
- January 3, 2009: Launch of the network blockchain.info
- January 9, 2009: The first public release of Bitcoin mail-archive.com
- August 30, 2009: First commit on Github github.com
- April 18, 2011: The launch of Namecoin, first altcoin in history bitcointalk.org
- May 2011: Bitpay, the first Bitcoin gateway for merchants, was founded bitpay.com
- May 2012: First issue of Bitcoin Magazine, the first publication that wrote exclusively about Bitcoin bitcoinmagazine.com
- June 1, 2012: Coinbase, the web wallet that allows buying and selling Bitcoin, was founded coinbase.com
- October 3, 2013: FBI seized about 26,000 BTC from Ross Ulbricht, founder of Silk Road forbes.com
- February 7, 2014: MtGox, one of the largest Bitcoin exchanges at the time, halted all withdrawals. Later it filed for bankruptcy and were closed. bloomberg.com
- August 1, 2017: Bitcoin hard forked, and the new coin Bitcoin Cash appeared fortune.com
- August 24, 2017: Activation of Segregated Witness (SegWit). SegWit allowed cheaper transactions and transaction signatures more reliable bitcoinmagazine.com