My brief introduction about Bitcoin
1 - Overview
To first understand blockchain how it is today, we have to place ourselves back in 2009, just after the Global Financial Crisis of 2008. People were losing faith in the current banking system after all losses and insecurity they generated in that period. Satoshi Nakamoto, whose the identity was never revealed, is the author of Bitcoin first white paper. He realised the need of changing the financial system, and he proposed a new economical model in which the people recover the control of their money. He started to talk about a decentralised model where banks no longer hold the entire control of the economy.
Based on the one-way functions, namely hash functions, Nakamoto creates a protocol that relies the information on blocks that are connected to other blocks for its hash, forming a chain of blocks, named Blockchain. Originally the blockchain proposes information that is immutable, transparent and free to anyone that wants to join the network. In Bitcoin’s case, the information represents fund’s transactions between the participants, but there is no limit of what we can store in one blockchain implementation, it can be any kind of binary data.
The immutability is the main characteristic of the protocol, and some consensus mechanisms are used to ensure the security of the network. Proof of Work (POW), Proof of Stake (POS), Delegated Proof of Stake (DPOS) and many others algorithms are used to solve the Byzantine Fault issue that can be found when working with decentralised systems, in this case the Peer-to-Peer (P2P) network.
In the past few years, a lot of new blockchain models were proposed, each one adapted for a different use case, solving scalability issues, privacy issues and any others. Bitcoin code is an open source project, and anyone can take the code, modify it a little bit and create their own blockchain.
Today, blockchain’s implementations haven’t stopped growing and it’s getting more and more efficient as far as technology is concerned. One important thing is that the cryptocurrency’s price is not completely related to its technological advance. It takes in count its uses cases, but also the trust that people have on it.
2 - Bitcoin Protocol
2.1 Hash Functions
As mentioned before, Hash Functions are one-way functions. It means that if the entry is known, the result is so, but with the result it’s impossible to know the entry. In computer science, the result of a hash function is called « hash », and there are many possible implementation of it. In Bitcoin, they use SHA-256, that produces a 256 bit (64 bytes) hash. This means that there are 2^256 possible combinations, a huge number, even bigger than the number of atoms in the observable universe. This insures that the algorithm has a collision rate almost null (one entry will almost never have the same result that one different entry). In order of that, hashes can be seen as a data’s digital fingerprint. Any kind of binary data can be used as input and had its hash as output. Another property of this function is that if we change just a bit of the entry, we will have a completely different result, that can not be predicted before the computation is done. This is very important to ensure the security of the Bitcoin Protocol.
As its name says, it’s a chain of blocks. The most important rule of the blockchain is « the longest chain is the right chain », which means the blockchain in the same network that has more blocks that the other ones is considered as the valid one. Each block contains mainly a certain amount of information (in Bitcoin’s case, the information is a trans- action). Each block is linked to its previous by the hash of it: imagine we have a block with the number X with a few transactions in it. We hash it all and we will have a block hash Y. The block X+1 will contain the block hash Y among others transactions. We hash it all and we will get a block hash Z. The next one, X+2, will contain the block hash Z among others transactions. Now, if anything is changed in the block X, like the amount of one transaction, it will have a completely different block hash, then the block X+1 will also give an other block hash and then its hash will change too. The rest of the blockchain will no longer be connect to the others blocks, so every computer in the network will know that this is not valid. That’s why the blockchain is know as « immutable », once the information is in it, it can not be changed (in theory). in order for change a transaction in the block X, the person will have to reproduce the blocks X+1 and X+2, and recompute their hashes. This could be made within some milliseconds if there were not a consensus mechanism that secures the network against this kind of action. In the Bitcoin’s case, one block is produced every 10 minutes approximatively due to the Proof of Work.
2.3 Consensus Mechanisms
This is not a blockchain itself, it’s due to the decentralised systems, as peer-to-peer networks, and it applies to the Bitcoin’s blockchain. As each computer holds a node, it’s as important as any other computer in the network. But not all computers can decide at the same time which trans- action they are going to put in the next block. It’s just not possible, because the will probably never choose the same transactions, so they will never be in agreement with each other. Instead, each node produces its own block with the transactions it had chosen and then they have to agree which one is going to be integrated in the blockchain. The consensus mechanisms are important because they allow this agreement between all nodes and also the are used to protect the network against a malicious attack. With a consensus mechanism, every one in the ecosystem is encouraged to follow the rules, therefore it can be seen as as Byzantine Fault Tolerance system. This name came from the Byzantine general’s problem: several byzantine generals surrounded a city they wanted to attack. The are geographically distant, so they have to send a messager to communicate. They will only win if all generals attack at the same time, so they have to choose between attack or go back. The problem is that there are traitors in the army, and they can be a messenger or a general. Here we can see the problem in the configuration, because a traitor will do everything to induce others to the mistake, therefore to lose the battle. The same could happen in a decentralised system as Bitcoin’s blockchain, one person (traitor) can propagate wrong or useless information (invalid blocks) to others peers and induce them to the mistake. The consensus mechanism will act in a way to encourage people to work according the roles, and the reward of a good behaviour is an economical incentive. There are many possible ways to achieve consensus, the first I will present is the Proof of Work, proposed by Nakamoto in his original Bitcoin Protocol.
2.4 Proof of Work
This is the consensus mechanism implemented in Bitcoin. Nodes that work with this proof are called miners. Min- ers have to select the transactions and a random number called « nonce ». Then it’ll compute the block hash. in order for produce a valid block, this hash must be lower than a certain number (it must start by some zeros). The quantity of zeros is give by the mining difficulty, grater the difficulty, lower the hash should be. As the hash can not be predicted before computation, miners have to test and if doesn’t fill the criteria they will have to try another number. The difficulty is adjusted weekly in order for keep the block time always near 10 minutes. If there were no adjustment, the block time would be every time lower, because a lot of people join the network each day, which means more computation power (hashing power). In this case, miners spend time and electricity to validate blocks. They receive in return Bitcoin (BTC) for each block that integrates the blockchain. In the beginning it was 50 BTC per block. This amount is reduced by its half every 4 years approximately. Nowadays it’s 12.5 BTC or almost 65,000 USD. This economical incentive is important to grant safety to the network, because if there are more people working in the block validating, more unlikely a malicious person will be able to attack it. To be able to perform an attack, one single person might control more than half of the network’s hashing power.
3 - Access Mechanism
Bitcoin works on Transmission Control Protocol (TCP) in the port 8333. In order for peers connect to each other, they must know the other’s Internet Protocol (IP) address first. A Domain Name Service (DNS) is implemented in the core of the Bitcoin code in order for provide a dynamic list that contains some IP address whose a node can connect. There are 8 DNS Seeders hardcoded in the source code. The network size is estimated in 12,000 nodes approximately. In case of all DNS Seeders are offline, a node can choose one of 1,200 IP address (700 IPv6 + 500 IPv4) that were also hardcoded in the source code. This was made in order for prevent any kind of attack involving the Seeders, because even if they are not responding, a node can still communicate with another node.
4 - Forks
A Bitcoin Fork is a split of the Bitcoin blockchain, but there are different types of forks. There are several forks each day. This is normal and natural, because of the geographical distribution of the nodes. If 2 blocks are mined almost at the same time, but in different locations, maybe the in- formation hasn’t had time to propagate through the entire network. This means that the network will be temporarily split into two, each one will consider the blockchain they’ve seen first was the valid one. After some time, a new block will be mined in one of the two sub-blockchain, and then it will be announced to the rest of the network. If we take that the most important rule of any blockchain in consideration, the longest chain will that place over the other one, and then the network will be reunited again. It can be the case the previous block didn’t have the same transactions that the other part of the blockchain that has been abandoned, and they will return to the network and will be able to be picked by miners again, like they had never been in a block before. This opens an opportunity for an attack, because fund could be double expended, that’s why it’s important to way a few more blocks to be mined before the payment be really accepted.
The other kind of forks involve its open source characteristic. Anyone can see and modify the code, therefore create their own version of the blockchain. Soft Forks are modifications in the code that are compatible with its older version. In this case, a node can choose either to update or not. On the other hand, a Hard Fork its a modification that is not compatible with its older version, and then the two can not communicate anymore. If a node decides to implement it, all blocks before the update block will be considered as part of a new blockchain. The incentive of doing this can be either economic or because they have a different vision of how the blockchain has to evolve. When a hard fork has place, all persons that had Bitcoin in the original’s blockchain will have the same amount in the new one, therefore they will gain some money, even if the price of the two in USD are not the same. An example of a non compatible modification is augmenting block size. The original Bitcoin was hard forked in August 2017 into Bit- coin and Bitcoin Cash for this reason. The same happened to Bitcoin Cash in November 2018, and became Bitcoin ABC and Bitcoin SV.