Understanding the Nakamoto Consensus
Blockchain is a decentralized, peer-to-peer network that operates without a central government. In order for participants to agree on a single truth in the system, a consensus mechanism is required. The consensus mechanism used by Bitcoin is called the Nakamoto consensus. We will explain why the Nakamoto consensus is important not only to understand Bitcoin, but the whole blockchain environment.
The Concept of Blockchain
Before that, let’s look at the blockchain as a whole. It is a distributed system with several ingredients, of which we can highlight two of them. The first is the presence of a distributed ledger, where transactions are recorded. The ledger works as a kind of database, storing records. In the particular case of Bitcoin, these are records of all transfers involving bitcoin coins.
In this distributed system, all participants have a copy of the ledger. Here, some questions arise. If different participants have differing copies of the ledger, who decides which version is correct? Who decides who will be responsible for updating the ledger? At this point it should be clear that an algorithm is needed to decide this, and that all participants must run that algorithm. Such an algorithm is known as a consensus mechanism.
Advantages of Distributed Systems
The technology of distributed systems predates the launch of Bitcoin. One of the main advantages of a distributed system is that there is no single point of failure. Let me explain this. As the system does not have a center, a failure in one of the participants (called nodes) does not imply that the system will stop working. In avionics, for example, this is fundamental. An airplane cannot rely on just one component that can fail. Therefore, the system of an airplane must be distributed. And at the same time they must agree on only one truth: the plane is at only one height and with only one speed.
Distributed systems can be divided into 2 types. Crash tolerant and fault (Byzantine) tolerant. Fault tolerant systems are those in which nodes can not only stop working, but also deliver false messages. This is the case on the blockchain, where malicious users can be present. Thus, the blockchain consensus mechanism needs to be fault tolerant.
Limitations of Voting-Based Consensus Mechanisms
The consensus mechanism of such systems used to be based on voting. As long as a certain number of participants vote for the same true state, that state is accepted by all other participants. This kind of consensus mechanism does not work for the blockchain, because users can create an unlimited number of accounts. This is known as a sybil attack. A malicious participant could create innumerable accounts, and make them all vote for a certain truth, thus imposing their will on the network.
The path chosen by Satoshi Nakamoto, the inventor of Bitcoin, had to be different. To create a fully decentralized network, Bitcoin’s consensus mechanism is based on a mechanism called proof of work. Instead of the participants voting, they participate in a kind of lottery, where a mathematical puzzle must be solved, and the first participant to solve this puzzle will be the one who will have the right to include the next block in the blockchain. A block is like a new ledger sheet and contains a certain amount of transactions.
The Nakamoto Consensus and Proof of Work
To solve this mathematical puzzle and win the lottery, participants must employ computational power. The greater the computational power of a participant, the greater their chance of solving the puzzle and winning the lottery. This method solves the problem of the sybil attack. It doesn’t matter how many accounts the malicious user can create, what matters is their computational power. Creating 100 accounts would not be a problem, but the malicious user would have to increase their computing power 100 times to achieve their goal.
Once one of the participants solves the computational puzzle, he will inform the other participants, who will verify and then accept the result of the lottery, that is, that the one who solved the puzzle has the right to insert the next block. It is possible that two participants solve the puzzle at about the same time, so that there will temporarily be two versions of the blockchain, or two versions of the system’s truth. This is called a temporary fork. If that happens, one has to wait for the next mathematical puzzle to be solved. Whoever solves the next puzzle will choose which of the two versions of the truth is the correct one; the other will be discarded. This is the Bitcoin consensus, which is known as the Nakamoto consensus.
Variations in Consensus Mechanisms
Although the proof of work used by Satoshi is not used in all blockchains, the idea of a lottery mechanism is one of the most used mechanisms today. Ethereum, for example, currently uses a mechanism called proof of stake. In it, users must keep deposited (stake) a certain amount of ether in a contract, and for each certain amount of ether deposited, such user receives a type of lottery ticket. The person responsible for inserting the next block in the chain is then drawn among all ticket holders.
Consensus mechanisms based on votes can still be used, but in this case those responsible for updating the blockchain must be properly known. That is, they cannot be anonymous and must be previously defined by the protocol, to prevent the sybil attack. Neo, for example, uses a voting-based mechanism called Delegated Byzantine Fault Tolerance (dBFT). The advantage of such a mechanism over lottery-based mechanisms is that, with no need for a draw, blocks can be included and finalized more quickly. It is for this reason that Neo is more scalable, yet less decentralized.
There is no consensus mechanism that is more correct or better than the others, just different choices. They all have advantages and disadvantages, and we’ll talk more about that in a future article.