– Reading time: 12 minutes –
Hello, welcome to this new article. If you are here it is because you often hear about Bitcoin and want to learn more about it by trying to understand what it is and how it works. Well, today I will try to explain it to you in the simplest way possible.
I will start by trying to answer the question:
What is Bitcoin?
The idea of Bitcoin (BTC) was born in 2008 when, in a paper entitled “Bitcoin: A Peer-to-Peer Electronic Cash System”, a person or group of people using the pseudonym “Satoshi Nakamoto” introduced a digital payment system based on cryptography. The founding concept was that of decentralization: they wanted to create an environment in which no “third party” had full control over the transactions made. In traditional payment systems, this “third party” is typically a bank: the user entrusts their money to the bank, which is responsible for storing it and overseeing all transactions involving it. Unfortunately, the supervision of banks makes international transactions very slow, some can even take several days and this can be a problem in today’s world where everything rushes. With Bitcoin, on the other hand, it is possible to send currency without any intermediary. If the banks close on the weekend, Bitcoin is always operational (24/7) and allows you to exchange in a few minutes any amount of money to any other part of the world, often with commissions even more convenient than bank ones. In this case, there is no external entity to have the power and the management of the currency is entrusted directly to the user who has full control over it. We can see this system as a digital alternative to cash: we all keep our money in our wallet and, barring thefts and special cases, we alone decide when to give it to another person. Of course, having full control also implies having some responsibility. In fact, if you have Bitcoins, you will have to take care of keeping them in a safe way. Furthermore, since there is no guarantor authority to supervise the transactions, it will not be possible to make any alterations to the operations carried out. If you send Bitcoin to another person, there will be no one to guarantee you a refund in case of errors or fraud. In other words, once a quantity of Bitcoin is sent to someone else, the transaction cannot be reversed, and in case of errors, the exchanged value will be completely lost. Moreover, the value of Bitcoin is regulated by the market’s supply and demand and, for this reason, can be very unstable.
Bitcoin is not the only one of its kind but, on the contrary, it is the forerunner of a whole series of digital currencies called cryptocurrencies. Like these, it is not tied to any state and to use it all you need is a simple internet connection. This makes it accessible to a wide range of users, regardless of their geographic location, social class, financial background, and availability of traditional banking services.
Now that you have a general idea about Bitcoin, let’s try to understand its mechanism better. As we mentioned, there is no bank or institution that controls it, so
How Does Bitcoin Work?
The doubt is legitimate: let’s assume that our friend Alice needs to send 1 BTC to her friend Bob, who registers this transaction? Who is responsible for verifying its validity?
You should know that Bitcoin works thanks to a large network of computers (called nodes) that are responsible for recording and verifying transactions. As already mentioned, this network is completely decentralized, there is no one in charge and anyone can, from one day to the next, enter and participate by adding their own node. These computers work together to maintain a large ledger, a sort of record of all the transactions made, of which everyone keeps a copy. This register is not the classic document you might expect but has a particular structure: it is built in the form of a chain of blocks called blockchain. Each block in this chain is nothing more than a container inside which there is a series of information including the transactions made by users. Each block is linked to the previous one in the chain thanks to a value called hash.
What is a hash?
A hash is a unique value that serves as a “fingerprint” of a particular set of data. To calculate it you need to use a particular function, called hash function. To give a practical example, let’s forget about Bitcoin for a moment and suppose that our dataset is a simple photo. The hash of a photo will be something like this:
“0b7e34a8cbbdd711fcc2139e2243619515b54451”
You can imagine this value, as already mentioned, simply as an identifier of that photo. In fact, the following properties apply to a hash function:
- Each time it is applied to the same input, it will always get the same output. This simply means that if you calculated the hash of our photo several times, you would always get the same value “0b7e34a8cbbdd…”.
- Generate unique output for each input. This means that if we applied the hash function on two different photos, we will not get the same value.
- A small change in input must generate a large change in output. So the hashes of two photos, differing by even a small pixel, will always be completely different.
- It is difficult to reverse. This means that if “0b7e34a8cbbdd…” is the hash of the photo, no one will be able to completely reconstruct the latter having only the hash as starting information.
- It is simple to calculate. This means that, starting from our photo, a computer can obtain the hash “0b7e34a8cbbdd…” quickly.
These properties obviously do not apply only to photos. To introduce you to the concept, I preferred to use an object that everyone knows but, as I already told you, a hash can be calculated on any set of data: a number, a string, a video, a file and so on.
Now that you have an idea of what a hash is, let’s go back to Bitcoin. We had said that it is precisely this hash that defines the chain and keeps all the various blocks connected. In fact, among the many pieces of information contained in a block, there will be the hash of the previous block. In this way, you build an immutable chain, in fact, if we think about it for a moment, the properties of the hashes we saw just now make it extremely difficult to change one block without changing the entire chain. Let’s take a practical example, suppose we have a chain constructed in this way:
If I were to modify block Z, even with just a tiny modification, for the properties seen before it would completely change its hash and this would break the connection that existed with block X. Block X, in fact, would continue to have the hash of Z block calculated at the beginning, when Z had not yet been modified. To successfully change Z, therefore, the HASH(Z) field of block X would also have to be affected, but this modification of X would have repercussions on HASH(X) by breaking the connection that existed with block Y. This reasoning can be iterated for all the blocks in the chain before Y. In other words, thanks to the properties of the hash, once a new block is registered in the blockchain, it will be practically impossible to modify it and, consequently, alter the transaction history. Of course, theoretically an attacker could try to modify all the hashes in the chain, from block Z up to the first produced block, but this would be practically impossible. In fact, to do this the attacker would have to have control over all the nodes of the network and modify their copy of the blockchain, needless to say that it is a difficult undertaking. An alternative for the attacker would be to build his own new chain of blocks and try to convince the other nodes that this is the main chain, but even this is extremely difficult since Bitcoin uses the Proof-of-Work (PoW) mechanism.
What is PoW?
Until now we have said that anyone can participate in the computer network that manages Bitcoin but, actually, this means that even malicious actors could do so. Who assures us that whoever owns a node always behaves honestly? This is where Proof of Work comes into play. The idea behind PoW is to create a mechanism that makes it unwise for anyone to behave dishonestly. In fact, in order for a node to add a block to the blockchain, it must provide proof of having performed a task, a task that is quite expensive. Cheating is not possible: before a node can add any block to the blockchain, all transactions contained in it, along with the PoW, must be verified by all other nodes in the network. In the specific case of Bitcoin, PoW corresponds to the calculation of a nonce, which is a value such that by calculating the hash of [block + nonce] a result with a sufficiently high number of zeros at the beginning is obtained, for example:
“0000000000000000000480a1b4cd8936290f395abedc5957967d6252218b5cfd”
Mathematically, finding such a value is complicated, which is why the various nodes have to do many calculations and spend a lot of electricity before being able to add a block to the blockchain. Spending a lot of energy means spending money, so a malicious node would no longer benefit from trying to insert dishonest transactions into a block. In fact, assuming that an attacker is also able to calculate the PoW, when the block produced is controlled by the remaining nodes of the network it will be discarded and the attacker will only have consumed energy unnecessarily. At this point you may be wondering: doesn’t it become inconvenient for honest nodes too? Not exactly. Indeed, the Bitcoin network provides rewards for honestly participating nodes: when a node generates a new valid block, which passes all checks, it will receive a certain number of Bitcoins as a reward for the work done. These Bitcoins will be created at that moment and added to the amount of cryptocurrency in circulation. It should be noted that Bitcoin is a scarce asset and the maximum amount of Bitcoin that can ever be created with this mechanism is 21 million. That’s why the reward given to honest nodes is halved every 210,000 blocks in an event called Halving. This mechanism is designed to limit the supply of Bitcoin and control inflation. By reducing the amount of new BTC generated with each block created, the rate of new Bitcoin issuance slows down. This slowing down helps to maintain the scarcity of the cryptocurrency and ensure that its value does not decrease over time. Warning, I am not saying that in the future, thanks to this mechanism, the price of Bitcoin will definitely rise. The price of Bitcoin depends on many other factors, and no one can make certain predictions. What I meant is that if the issuance of new Bitcoin were unlimited, there would be an ever-increasing amount of it in circulation, which would lead to a long-term devaluation of the currency.
Let’s put some order
So far, I have introduced you to a lot of concepts, now let’s use them to organize what happens when a Bitcoin transaction is sent. Let’s go back to the example of Alice and Bob. To send 1 BTC, Alice will have to create a transaction destined for Bob and send it to all nodes on the network. Each node, independently of the others, will take Alice’s transaction, check if it’s valid, and, collecting it along with other transactions sent by other users, will form a new block. To publish this block, the node will have to provide proof of having done work, and will then start calculating the PoW. At this point, a real competition will arise between the nodes: whoever calculates the PoW first will be able to request the insertion of the new block into the blockchain. After calculating the PoW, the block must be sent to the other nodes on the network who will validate it. These other nodes will have to verify that all the transactions included in the block are honest, not related to a previously spent asset, and that the PoW is valid, only then will they decide to add it to the blockchain. In the end, the node that produced the block first will receive its reward and will be ready to validate new transactions.
Privacy in Bitcoin
Before concluding, I would like to talk to you about privacy in Bitcoin, a fairly delicate topic that is often not fully understood by those approaching this world for the first time. Many believe that Bitcoin is completely anonymous and that transactions cannot be traced, there is some truth to this but it still needs to be contextualized. I didn’t point this out before, maybe you guessed it, but all transactions that take place on the Bitcoin network are public. Anyone can observe the transfers made, the blocks created with all the corresponding information simply by using a block explorer. All of this information contained in the Bitcoin blockchain is pseudonymous and not directly associated with the identity of the users. In fact, Bitcoin addresses and transactions do not provide any information about the name or identity of the user who made the transaction. So yes, by purely observing the public information that is in the blockchain it is not possible to know anything about who is executing those transactions but, when someone manages to discover that your Bitcoin address is associated with you, they could exploit any block explorer to get information on all the transfers you have made and will make associated with that address. So be careful who you give your Bitcoin address to, I recommend you think twice before sharing it with anyone else.
That’s all for today, I hope I have made you understand how Bitcoin works in general, if the topic interests you, remember to come back to this blog because in the future I intend to deepen the topic with other articles and also talk about some other interesting cryptocurrencies . Thanks for reading this far, greetings!