How does Bitcoin Work? The Best Explanation for Everyone
Bitcoin is a neutral, open, sometimes called trust-less decentralised digital currency which uses cryptography to ensure security. What exactly does this mean?
Let’s look at it with an example with some simplifications for better understanding.
Maya bought some bitcoins on a crypto exchange and now she wants to send them to John. In order to do so, John needs his own digital wallet and an address to which Maya can send some of her bitcoins. We can look at wallets as some kind of email addresses accessible only to the owner (who owns a private key or password), whereas the addresses themselves are public; the owner can give these addresses to anyone, but nobody can spend the bitcoins stored there.
A wallet may have more addressees, just like a person can have multiple email addresses. Each address in the wallet is a combination of two keys: a private key known only to the owner and a public key from which the address is actually calculated using cryptography. It sounds complicated but John, who wants to receive bitcoins, needs only his own wallet where he can create a private key (64 random letters and numbers) with a single click and safely store it; at the same time, he gets also an address to which Maya can transfer her bitcoins.
It is very important not to give the private key to anyone when using bitcoin, as the key essentially allows us to have full access to all bitcoins on a particular address. It is therefore crucial that we pay great attention when storing private keys so that these do not to get into the hands of hackers (or anybody else in that manner), who would be happy to redirect all our bitcoins to their wallets. At the same time, owners must not forget their private keys, since without a key one is not able to access the bitcoins on his/her address. It would be like having a kilogram of gold in an indestructible safe that no one in the world can open and the owner has lost its key.
The goal of bitcoin wallets is to simplify the storage of private keys. John can have in his wallet several private keys and related addresses, where Maya can transfer her bitcoins. John is thoughtful and so he protects his wallet with a strong password, which he writes on a piece of paper and saves it in his safe at home; at the same time, he makes also a backup copy of his wallet. In case his computer breaks down and he cannot access his wallet, he can restore it on a new computer using the password he has stored. The password usually consists of 12 (or 24) randomly selected words so it is practically impossible to decipher.
Now that John has set up his wallet and taken care of additional security measures, Maya can transfer some of her bitcoins to the address provided by John from his wallet. Due to the relatively high price of bitcoins currently, they agree Maya will send him a thousandth of bitcoin, which is about 10 euros. Bitcoin is a highly divisible currency having as many as eight zeros following a whole number. The smallest unit (100-millionth bitcoin) is called Satoshi after the father of bitcoin.
John now sends Maya his address, to which she will transfer a thousandth of a bitcoin (100 thousand satoshis), worth approximately 10 euros. Maya also needs a wallet to carry out the transaction. Having bought the bitcoins on the crypto exchange, she already has a wallet in her trading account. Through her wallet (on the crypto exchange website) she enters John’s bitcoin address and the number of bitcoins she wants to transfer.
This transaction contains information about the sender (Maya’s bitcoin address from her wallet), the amount of bitcoins she wants to send and the information about the recipient (John’s bitcoin address). In order to complete the transaction, Maya has to sign it with her private key in the wallet. This happens automatically, so Maya does have to worry about it.
The transaction is now signed and sent to the entire bitcoin network. The function of the bitcoin network, where all wallets and miners are, is to record transactions, check their accuracy and then approve them. Wallets monitor and record all approved transactions, making it easy to calculate the number of bitcoins in each individual wallet (or more precisely, every bitcoin address). The so-called miners check all performed transactions and confirm their correctness.
Transaction verification is relatively simple. Miners have to check whether Maya has as many bitcoins as she wanted to transfer to John. They do so by looking at the source of Maya’s bitcoins. Since all transactions are public, this is easily done. Miners monitor all transactions and therefore it is known from which bitcoin address the transactions are carried out for the entire history of the bitcoin existence.
Miners combine new transactions, including Maya’s, into blocks containing about a thousand transactions. Now it all becomes interesting. Since miners confirm transactions, they actually have the power to enter their fictitious transactions and confirm them. Miners could see Maya’s bitcoin address, notice that there are some bitcoins on it, and transfer these bitcoins through a new transaction to their address. This of course cannot be done, as Maya must sign each and every transaction from her bitcoin addresses with her private key.
Miners could attack the network also via dual consumption. Since miners confirm all transactions, they could transfer bitcoins from one of their addresses to two other addresses at the same time. Let’s say there is one bitcoin on the first address, and the malicious miner transfers this bitcoin to two other addresses. If such a transaction is approved, an additional bitcoin is created out of nothing; this new bitcoin can then be sold, and profit generated. However, the bitcoin system resists to such attacks.
Against such attacks, the bitcoin system defends itself by using a certain type of consensus mechanism. All miners must approve that the transactions in a block are correct, so they must somehow reach an agreement. Considering that all transactions are public, miners should only confirm transactions that comply with the basic rules (the sender who has sufficient funds sends bitcoins to a valid address). The bitcoin system assumes there is no honesty in the world, so miners have to prove they have spent some of their processing power and energy to validate the block of transactions.
The process of blocks validation (and transactions in these blocks) is called mining. When Maya sent a thousandth of a bitcoin to John, she sent this transaction to all miners via her wallet. Miners add Maya’s transaction to a block and start mining. Mining is the search for a solution to the mathematical problem that miners must solve in order to prove they have consumed their processing power and energy.
These mathematical problems solved by miners come from cryptography. Miners take the current block and use it as input information for a particular cryptographic algorithm (SHA256). The characteristic of this algorithm is that as input information we can offer it anything from words such as “Blocktrade.com” to any file of preferable size. The algorithm will then in a few milliseconds (or seconds if the input is large) extract exactly 64 letters and numbers that appear completely random. Despite their random appearance, the output of the algorithm is deterministic. This means that the result is exactly the same every time we enter the same identical content in the SHA256 algorithm. The most important characteristic of these cryptographic algorithms is their irreversibility; the 64 characters are obtained very quickly from the input data, and from these 64 characters it is (close to) impossible to calculate the input data.
Since the calculation of the algorithm results from the input data, which in the case of bitcoin is the entire content of the block (and therefore all new transactions included in this block), Satoshi Nakamoto has invented a simple solution to the problem. Miners must use the SHA256 algorithm so that the result (these 64 characters) starts with a certain number of characters equalling zero, for example, the first 18 characters must be zero. Miners achieve this by using one more number (called nonce) as an additional input. This number is then being modified for so long until the combination of the input data of the block and that added number bring the desired result – 64 characters beginning with a certain number of zeros.
This means that miners must test a huge variety of options of this number, which serves as an additional input for block mining, thereby using a lot of processing power and electricity. Why would anyone want to use so much energy to simply verify transactions and why do miners do this at all?
As soon as a miner (a computer, server, or special equipment specialised in mining) finds a solution in the form of a unique number that in combination with the block of transactions solves the algorithm, the miner sends it across the entire bitcoin network to all wallets and miners. These then very quickly (in a few seconds) check that the first miner has really found the right solution and then approve the certified block of transactions as correct and valid. All transactions in the block are confirmed for the first time and therefore become valid. With the confirmation of the block, John receives his first bitcoins to his address only ten minutes after Maya sends him a thousandth of a bitcoin.
Miners are awarded for confirming blocks (and transactions), but only those which solve the mathematical problem first. This is why all miners strive towards the most powerful processors in order to find the number that is the key to solving the algorithm with the highest probability. At first, miners used central processing units (CPU), then they needed faster processors, so they began using graphics processing units (GPU), and now they use special circuits that can only calculate the SHA256 algorithm and nothing else. The circuits can be up to 100 times faster than graphics cards, which can be another 100 times faster than conventional computer processors. The struggle for speed is intense, which is all grist to mill for graphics card producers (Nvidia and AMD), whose shares have grown exponentially in the past couple of years.
The reward received by the miner that first finds the solution to the problem is currently 12.5 bitcoins, which is about 100 thousand euros. The prize (in bitcoins) decreases with time.
»Upon the origin of the bitcoin, 50 bitcoins were awarded for a successful block confirmation (for the solution of the problem); in 2012 the reward was halved to 25 bitcoins and later in mid-2016 it was halved again to 12.5.”
The prize will continue to decrease by a factor of 2 approximately every four years. In 2140, there will be no rewards for miners; for validating transactions they will only receive transaction costs.
In order to understand why it takes so much energy to simply confirm transactions, we should take a look at the process of formation of chains of blocks or blockchains. When Maya transfers some of her money to John, the transaction is added to a block. Since transactions are public, it is very easy to track how many bitcoins someone owns, because transactions can be easily connected backwards – all the way to the origin of bitcoin. Blocks are connected to one another chronologically.
The block which includes Maya’s transaction to John and has just been confirmed is linked to a previous block containing past transactions (approximately one thousand transactions from about 20 minutes ago). This previous block is also linked to its predecessor, and so on, until the very first block created by Satoshi Nakamoto.
How safe is blockchain technology at all?
All blocks are interconnected so that the result of a problem (64 characters where the first few characters are zero) is used as the input parameter in the next block. Once the next block is confirmed and the result of the problem is known, the result is again used as the input parameter in the next block and so it goes on. The process creates a continuous chain of interconnected blocks.
The solution is really ingenious as it limits potential fraud that miners might commit. If a miner wants to change the selected transaction in the last block, the result of the problem of the block is “broken” due to the characteristics of the cryptographic algorithm. With every block modification, the miner is required to find a new solution, which, of course, requires additional processing power and energy. Until the malicious miner tries to find a new solution for the rearranged block, other miners continue to validate new transactions in new blocks and add them to blockchains.
The probability that a malicious miner manages to find a solution to the problem for the previous block of transactions that was changed, and the solution for the new one, which is calculated also by other miners, is very small. In other words, the malicious miner should have more than half of the processing power of the entire bitcoin network on disposal in order to make it work. This means that the miner should invest millions of euros in equipment and pay huge amounts for electrical energy. Even if the miner succeeded, this dominance would be noticed by other miners that would take appropriate action. The cost that such an attacker would suffer is much greater than the potential reward it could get, so something similar has not been accomplished by any miner yet, and probably it also will not happen (at least until quantum computers are produced).
Every new verified block confirms all the blocks behind. If the miner wanted to change the transactions in the penultimate block (where two other were previously confirmed), the miner itself would have to find a solution to the problem for three blocks in a row. Every additional confirmed block requires even more processing power, so everyone agrees that after six approvals (after about an hour) the transaction is valid to such an extent that no one will ever be able to change it.
Blockchain in the bitcoin system therefore enables the validation of transactions without a central authority trusted by everyone; this is why bitcoin is called also the currency that requires no trust. At the same time, the bitcoin blockchain reaches consensus throughout the network by publishing the result of the mathematical problem that can quickly be confirmed by others which is called Proof of Work. This form of consensus results in another useful bitcoin property: the irreversibility of approved transactions.
“Blockchain technology makes bitcoin a currency that does not need trust among users and is both safe and fast.”
Maya’s transaction was added to the blockchain with the first block confirmation within ten minutes; with every additional confirmation of a new block, her transaction is deeper in the blockchain, which means that no one will ever be able to change it. John, who received Maya’s bitcoins, can also be sure that these bitcoins are now at his address and safe in his wallet.
Pros and Cons
Although the entire process is relatively complex, blockchain transactions are considerably faster and may be cheaper than a bank transfer or the use of PayPal or credit cards. The costs of these last two vary between two and three percent, which can be a huge amount for a company with low margins. That is, if a company sells a product with a 5-percent margin and the cost of the received payment is 2-percent of the value, the margin is almost halved. This is of course not acceptable in a highly competitive world, since such a difference may result either in success or failure of a company.
By using bitcoin, the company would pay minimum transaction costs, which currently amount around two euros (but keep in mind that the transaction fees have been as high as 50 euros). For products worth some thousands of euros, the difference between using bitcoins or credit cards for transactions can be huge. Here, however, we quickly find the current weakness of the bitcoin system: bitcoin is not very attractive for small value transactions. An additional disadvantage of the bitcoin system is also the number of transactions that can be carried out every minute.
Currently, the number of transactions is limited by the size of blocks: the more transactions miners add to each block, the greater is the capacity of the bitcoin network. The Visa payment card system can approve almost 100 thousand transactions every second, while bitcoin stops at less than ten. That is why there was a real battle during the last summer between miners, as some wanted to ease this limitation, while others were against it. There was a disagreement over which standard to apply to new blocks that resulted in two different bitcoin blockchains. Some agreed that the size of the blocks should increase (thus the number of transactions would increase as well), while some defended the previous standard. Two bitcoins were created: bitcoin and bitcoin cash.
Maya does not have to think about how her bitcoins arrive to John, as her wallet ensures the application of the right standards. However, such complications in the bitcoin network show the immaturity of the system, which, on the other hand, develops very quickly.
With the reduced block size limit, the number of confirmed transactions every ten minutes increased, which made bitcoin cash a bit more attractive payment method. Bitcoin system upgrades are also being developed; small value transactions will be merged into one, which will further accelerate the network, lower costs and allow a larger number of transactions. The main problems of bitcoin (limited number of transactions per minute and high costs for small value transactions) are basically just an engineering problem that will be resolved in the coming months and years. At that time, bitcoin might be able to stand alongside Visa’s system or even overtake it.
It will, nevertheless, take some time before bitcoin becomes interesting as a means of payment for the general public in developed countries. Its simple use will probably be the most important factor. Until it will be necessary to create wallets, store public and private keys in them and send bitcoin addresses around in order to receive bitcoins at all, the use of bitcoin as a means of payment will be limited. But when bitcoin will become as easy to use as a credit card (or perhaps even easier), people may start massively using the most important cryptocurrencies as a means of payment.