“What is Bitcoin ?”. In this article, I’m going to try to explain it in plain English. To do so I’m going to walk you step by step of how you would create your Bitcoin and why different Bitcoin components were necessary to make Bitcoin so powerful and widely used.
What is Bitcoin?
Bitcoin is a stack of technologies and concepts combined to create a virtual digital currency ecosystem. The bitcoins are the units of currency circulating in the bitcoin network, they are created through the mining process done by nodes in the bitcoin network called “miners”. The bitcoin protocol stack is open source and easily accessible via a variety of devices including laptops and smartphones. Bitcoin is called a cryptocurrency because the technology includes features from cryptography to ensure security over the network which makes it the perfect form of money for the Internet. Users of bitcoin own private keys that enable them to prove ownership of transactions in the bitcoin network, unlocking the value to spend it and transferring it to a new recipient. Those keys are often stored in a digital wallet on each user’s device. Possession of the key that unlocks a transaction is the only prerequisite to spending bitcoins, putting the control entirely in the hands of each user.
Easy right? no really!
A ledger of transaction
Forget about all the above forget about all you know about money and currencies. Let’s imagine that you and your friends are trying to keep track of payments, let’s say you exchange money to pay for rent or bills, so you create a communal ledger in which you record your transactions and to make it accessible to everyone, you decided to publish it into a website where every one of you can add new lines. At the end of every month, you’re all good together look at the list of transactions and settle up.
Seems like a simple protocol, but one problem that emerges here is that since the ledger is in public and accessible, anyone can add a line so there is nothing to prevent Ahmed from adding a new line that says that Youssef paid him 100$ without Youssef’s approval.
Now, this is where the Digital signature comes to be useful. Just like a handwritten signature, the purpose is to add something unique to the transaction that proves that he is the one to add the transaction and approve it so that it is infeasible to anyone else to forge that signature. But in this case, anyone can copy/paste the signature, so how does a digital signature prevent forgeries?
The way a digital signature works is that everyone generates what’s called a private key or secret key (sk) and public key (pk) pair.
The private key is used to create a signature while the public key is something that others can use to check it, think of the private key as the password that you need to keep for your self and signature is the intermediary that proves you have the password without requiring you to reveal it.
Producing a signature involves a function that depends both on the message itself and the private key, the private key ensures that only you can produce that signature and the fact that it depends on the message means that no one can just copy one of your signatures and then forge it on another message. Another important function is used to verify that the signature is valid. This is where the public key comes into place, all it does is put true or false to indicate this was a signature produced by the private key associated with the public key that you are using for verification. To keep this article simple I’m not going into technical details of how these two functions work.
The idea is that it should be completely unfeasible to find a valid signature if you don’t know the secret key.
The only strategy to guess that 256 bit is to guess and check random signatures with which you can use the public key and the message. If you think about how many tries it’s 2 to the power of 256 (2²⁵⁶ = 115 792 089 237 316 195 423 570 985 008 687 907 853 269 984 665 640 564 039 457 584 007 913 129 639 936), that’s an ridiculously large number. So, when you find that the given signature is true, you can be extremely confident that the only way someone could have produced it, is if they have the secret key associated with the public key used for verification.
Double spending problem
Digital signatures remove a huge aspect of trust, but even if we were to use this we still need to rely on an honor system, of course, I mean you are mainly trusting that everyone will follow through and settle up in cash at the end of each month, but what if for example Aicha owns Ahmed a big amount of money and by the end of the month she refuses to show up and pay. To prevent people to take out more than they take in, we can maybe start the month by having everyone pays for example 100$ and make sure no one spends more than there is. And for example, if Ahmed tries to pay Aicha 50$ and pay Abdo 50$, and then tries to pay Youssef 50$ that shouldn't be possible, this last transaction shouldn’t be possible, and that’s is called the double-spending problem.
Verifying a transaction requires knowing the entire history of transactions.
Now as we said before, we need to know the entire history of transactions, so in the next step, we are going to remove the connection between the ledger and the physical dollar. In theory, if everyone in the world was using this ledger, we can spend our whole life sending and receiving money in this ledger without having to convert to real dollars, let’s refer to the quantities of bits of units on the ledger as Digital Currency or “DC” for short. You are of course free to exchange DC for real dollars. For example, Ahmed gives real 5 dollars for exchange Youssef will send Ahmed 500 DC and will add it to the communal ledger.
But exchanges like this one are not going to be guaranteed by the protocol, it’s like how you would exchange dollars for euros or any other currency on the open market. This is the first important thing to understand about bitcoin or any other digital currencies. A currency is a history of transactions, and it is not created with people exchanging it for cash. Now, if the currency is the ledger of records, how can we protect these records while sharing the ledger among participants?
Decentralized peer to peer network
We mentioned before that we are going to deploy the ledger into a public website where anyone can add new lines, this requires trusting a central location, who will host the website, and controls the rules of adding new transactions. Otherwise, we can remove this central website and have everyone keep their copy of the ledger. We can have a decentralized peer-to-peer (P2P) network, where participants interact directly with each other with no intermediary or a middle man.
When a participant wants to make a transaction, let’s say Ahmed pays Aicha 100 DC, He needs to add that transaction to his copy of the ledger and then broadcast the message to the rest of the network for other participants to receive and record the transaction into their copy of the ledger.
Since now, every participant has their copy of the ledger, a new problem arise, how can we get everyone to agree on the same ledger? How can we be sure that Abdo received Ahmed’s message, or if he recorded the same transaction in the same order? We need to think of a protocol that ensures everyone has a personal ledger that is identical to everyone else. This is an interesting problem and it is usually referred to as the byzantine generals' problem.
Cryptographic hash function
At a high level, the solution that bitcoin offers is to trust whichever ledger has the most computational work put into it. It involves what’s called the cryptographic hash functions, the general idea that if you used the computational work as a reference to which ledger to trust you can make it so that fraud in transactions would require an infeasible amount of computation. Let me first explain what a hash function means. A hash function takes as input any kind of message or file, and the output is a string of bits with a fixed length like 256 bits, the output is called a hash or the digest of the message, the digest although it looks random, it is not, in fact, it always gives the same output for the same given input. SHA256 is one of the novel hash functions.
The idea is that if you slightly change the input, maybe changing just one of the characters of ‘hello’ the resulting hash changes completely, it’s unpredictable, and it's called a cryptographic hash function, which means it’s infeasible to compute in the reverse direction. If I give you output and ask you to find an input so that the sha256 hash of the input gives the exact output, you will have no better method than to guess and check, again and again, in our case, it’s again 2 to the power of 256. Now, back to our problem, how do we use this hash function to prove that a particular list of transactions is associated with a large amount of computational effort and therefore it’s the credible ledger?
Proof of work
We need to come out with a hard problem or puzzle to solve, so that if we gave a hash function input of a list of transactions with a special number it should give an output with special criteria. What if this criterion is 256 bits that start with 20 bits of zeros. How hard do you think it’s going to be to find the special number?
For a random message, the probability that a hash happens to start with 20 consecutive zeros is on in two to the power of 20.
Which is about a one in million, replace 20 to 30 zeros and it’s one in billion. And since SHA256 is a cryptographic hash function, the only way to find the special number is by just guessing and checking. So if someone found that special number to output 20 consecutive zeros for a given list of transactions, we can be certain that this person had to go through a million different possible numbers, and we can quickly verify if this number respects our condition without having to go through the same effort.
This is called Proof Of Work or POW, and note that this work is linked to a list of transactions, if we were to change one of these transactions even slightly, we would completely change the hash.
So now back to our distributed ledger, everyone is broadcasting their transactions, and we want a way for them to agree on what the correct ledger is. As we said we want to trust the ledger that has to most computational work.
The way this work, is that we first organize the ledger into blocks, where each block contains a list of transactions and a proof of work so that the hash of the entire block is 256 bits that start with 20 zeros, we will later discuss how we systematically choose the number of zeros.
And just like a transaction is considered valid when it’s signed, a block is only considered valid if it has proof of work. And to make sure that there is order to these blocks, we will stamp every block with the hash of the previous block in its header. That way if you were to change any block, you would change the block that comes after, and that would also mean redoing the proof of work and finding a new number.
Because blocks are chained together, we called Blockchain instead of the ledger.
Now we will answer a previous question, how Bitcoin is created? like we previously discussed, Blockchain is a series of blocks linked together, anyone in the world can be a block creator, which means a creator must listen to transactions requests, collect them into a block and do the computational work to solve the problem and find the number that makes the hash of that block start with 20 zeros, and once they find it, they broadcast the new block they found, and the block creator gets rewarded for his work, the reward is a special transaction that is added, let’s say that the reward is 10 DC. And that is how digital currency is created. It’s a special transaction that doesn’t come from anyone and it doesn’t have to be signed.
That means that the more blocks are created the more currencies are added to the economy. Creating blocks is called mining and the block creators are called miners.
From the miner's perspective, each block is a lottery where each one is racing to find that number that starts with a specific number of zeros.
All of the bitcoin ultimately comes from block rewards, in the beginning, these rewards were 50 BTC per block, after every 210 000 blocks, which is about every 4 years, that reward gets cut in half.
And because this reward decreases geometrically over time it means there will never be more than 21 000 000 (21 billion) bitcoin in existence. However this doesn’t mean that miners will stop earning money, in addition to the block reward, miners can also pick up transaction fees, the way this works is that, whenever you make a payment you can purely optionally include little transaction fees with it, this is will go to the miner who includes that transaction into their block. The reason you might do that is to incentivize miners to include the transaction that you broadcast into the next block.
We set the number of zeros to 20 this number of zeros is the way the actual Bitcoin protocol works to periodically change the difficulty target so that all the computation in the network will find blocks approximately every 10 minutes. So the more miners added to the network, the challenge gets harder and harder. The block time in Bitcoin is set to 10 minutes, but other newer versions of cryptocurrencies have a shorter time.
Who invented Bitcoin?
I hope that what you previously read made you appreciate Bitcoin technology, I find it to be a genius solution that challenges the current money system. But weirdly enough nobody knows who invented it. In 2008, a person or a group of people used an alias named Satoshi Nakamoto and published a paper titled “Bitcoin: A Peer-to-Peer Electronic Cash System”.
Bitcoin is a cryptocurrency, as mentioned before, Bitcoin uses a lot of cryptography to reduce the trust needed between participants. Hence the name ‘cryptocurrency’. Cryptocurrencies wouldn’t exist without the advances in cryptography.
Since Blockchain doesn’t require trust among participants in the network, it is also called the protocol of trust.
Congratulation, you have now a general understanding of Bitcoin technology. Of course, there is a lot of technical details that we skipped to keep this article as simple as possible. But this should be enough to consider for yourself if you want to join the Bitcoin tribe as a miner, investor, or a simple user.
- Satoshi Nakamoto Bitcoin: A peer-to-peer electronic cash system 2008.
- 3Blue1brown, https://www.youtube.com/watch?v=bBC-nXj3Ng4&t=631s.
- “Mastering Bitcoin by Andreas M. Antonopoulos (O’Reilly). Copyright 2014 Andreas M. Antonopoulos, 978–1449374044.”