Blockchain technology to solve Byzantine general problem
The strict definition of blockchain refers to the distributed database technology that multiple nodes in peer-to-peer network jointly maintain a continuously growing list ledger constructed by time stamp and orderly record data blocks through consensus mechanism based on cryptography technology. This technical solution allows any number of nodes in the participating system to calculate and record all the information exchange data in the system in a period of time to a data block through cryptography algorithm, and generate the fingerprint of the data block for linking the next data block and checking. All participating nodes in the system jointly determine whether the record is true
blockchain is a technical solution similar to NoSQL (non relational database). It is not a specific technology, and can be implemented through many programming languages and architectures. There are many ways to realize blockchain, including pow (proof of work), POS (proof of stake), dpos (delegate proof of stake), etc
the concept of blockchain was first proposed in the paper "bitcoin: a peer-to-peer electronic cash system" by indivials (or groups) who call themselves Satoshi Nakamoto. Therefore, bitcoin can be regarded as the first application of blockchain in the field of financial payment
< H2 > [popular explanation]no matter how big the system or how small the website is, there is a database behind it. So who will maintain this database? In general, who is responsible for the operation of the network or system, then who is responsible for the maintenance. If it is wechat database, it must be maintained by Tencent team, and Taobao database is maintained by Alibaba team. We must think that this way is natural, but blockchain technology is not P>
if we think of the database as a book, for example, Alipay is a typical account book. Any change of data is bookkeeping. We can think of database maintenance as a very simple way of accounting. In the world of blockchain, everyone in the blockchain system has the opportunity to participate in bookkeeping. The system will select the fastest and best bookkeeper in a period of time, maybe within ten seconds or ten minutes. The bookkeeper will record the changes of the database and the account book in a block. We can think of this block as a page. After the system confirms that the records are correct, the system will record the changes of the database and the account book in a block, It will link the fingerprint of the past account book to this paper, and then send this paper to everyone else in the whole system. Then, over and over again, the system will look for the next person with fast and good bookkeeping, and everyone else in the system will get a of the whole ledger. This means that everyone as like as two peas in the system is called Blockchain. It is also called distributed account technology. P>
as like as two peas (computer) have identical accounting books, and everyone has the same rights, they will not collapse e to the loss of contact or downtime of a single person. As like as two peas, the data is transparent and everyone can see what changes are in every account. Its very interesting feature is that the data can't be tampered with. Because the system will automatically compare, it will think that the same number of books with the largest number are real books, and a small number of books with different numbers are false books. In this case, it's meaningless for anyone to tamper with his own account book, because unless you can tamper with most nodes in the whole system. If there are only five or ten nodes in the whole system, it may be easy to do so. However, if there are tens of thousands or even hundreds of thousands of nodes and they are distributed in any corner of the Internet, unless someone can control most computers in the world, it is unlikely to tamper with such a large block chain
< H2 > [elements]combined with the definition of blockchain, we think that we must have the following four elements to be called public blockchain technology. If we only have the first three elements, we will consider it as private blockchain Technology (private chain)
1, peer-to-peer network (power equivalence, physical point-to-point connection)
2, verifiable data structure (verifiable PKC system, non tampering database)
3, distributed consensus mechanism (Solving Byzantine general problem, solving double payment)
4 Game design of Nash equilibrium (cooperation is the strategy of evolutionary stability)
combined with the definition of blockchain, blockchain will realize four main characteristics: decentralized, trustless, collective maintenance and reliable database. And the other two will be derived from the four characteristics Features: open source Privacy. If a system does not have these characteristics, it can not be regarded as an application based on blockchain technology
Decentralized: there is no centralized hardware or management organization in the whole network. The rights and obligations of any node are equal, and the damage or loss of any node will not affect the operation of the whole system. Therefore, it can also be considered that the blockchain system has excellent robustnesstrustworthiness: there is no need to trust each other when participating in the data exchange between each node in the whole system. The operation rules of the whole system are open and transparent, and all data contents are also open. Therefore, within the specified rule range and time range of the system, nodes cannot and cannot cheat other nodes
collective maintenance: the data blocks in the system are maintained by all the nodes with maintenance function in the whole system, and these nodes with maintenance function can be participated by anyone
reliable database: the whole system will enable each participating node to obtain a of the complete database in the form of sub databases. Unless more than 51% of the nodes in the whole system can be controlled at the same time, the modification of the database on a single node is invalid, and the data content on other nodes cannot be affected. Therefore, the more nodes and computing power in the system, the higher the data security in the system
Open Source: since the operation rules of the whole system must be open and transparent, the whole system must be open source for the program
Privacy Protection: since there is no need to trust each other between nodes, there is no need to disclose the identity between nodes, and the privacy of each participating node in the system is protected
1-contains a distributed database
2-distributed database is the physical carrier of blockchain, blockchain is the logical carrier of transaction, all core nodes should contain full copies of the blockchain data
3-blockchain serializes blocks according to time, And blockchain is the only body of the whole network transaction data
4-blockchain is only effective for addition, but not for other operations
5-public and private key verification based on asymmetric encryption
6-accounting node requires that Byzantine general problem can be solved / avoided
7-consensus progress is evolutionarily stable, That is, in the face of a certain amount of contradictions between different nodes, the data will not collapse
8-consensus process can solve the problem of double spending
The way in which people keep accounts together is also known as "distributed" or "decentralized", because everyone keeps accounts, and the accuracy of the account book is determined by the program algorithm, not by an authoritative organization
this is the blockchain, the core is finished, blockchain is so simple, a common account book
six core algorithms of blockchain Technology:
blockchain core algorithm 1: Byzantine agreement
the story of Byzantine is like this: the Byzantine Empire has great wealth, and the surrounding 10 neighbors have been around for a long time, but the Byzantine walls stand tall and firm, No single neighbor has been able to successfully invade. Any single neighbor's invasion will fail, and at the same time, it may be invaded by other nine neighbors. Byzantine Empire's defense ability is so strong that at least more than half of its ten neighbors attack at the same time before it can be broken. However, if one or several of the neighbors agree to attack together, but betray in the actual process, then the invaders may be annihilated. So each side was careful and could not easily trust its neighbors. This is the question of Byzantine Generals
blockchain core algorithm 2: asymmetric encryption technology
in the above Byzantine agreement, if several of the 10 generals send messages at the same time, it is bound to cause confusion in the system, resulting in different attack time schemes and inconsistent actions. Anyone can send the message of attack, but who will send it? In fact, it only needs to add a cost, that is, only one node can spread information in a period of time. When a node sends a unified attack message, each node must sign and seal to confirm its identity when receiving the message from the initiator
blockchain core algorithm 3: fault tolerance problem
we assume that in this network, messages may be lost, damaged, delayed and sent repeatedly, and the order of receiving is inconsistent with the order of sending. In addition, the behavior of nodes can be arbitrary: they can join or exit the network at any time, they can discard messages, forge messages, stop working and so on, and they may also have all kinds of human or non-human failures. Our algorithm provides fault tolerance for consensus system composed of consensus nodes, which includes both security and availability, and is suitable for any network environment
blockchain core algorithm 4: Paxos algorithm (consistency algorithm)
the problem solved by Paxos algorithm is how a distributed system can reach an agreement on a certain value (decision). A typical scenario is that in a distributed database system, if the initial state of each node is consistent, and each node performs the same operation sequence, then they can finally get a consistent state. In order to ensure that each node executes the same command sequence, it is necessary to execute a "consistency algorithm" on each instruction to ensure that the instructions seen by each node are consistent. A general consistency algorithm can be applied in many scenarios, which is an important problem in distributed computing. There are two models of node communication: shared memory and message passing. Paxos algorithm is a consistency algorithm based on message passing model
blockchain core algorithm 5: consensus mechanism
blockchain consensus algorithm is mainly workload proof and equity proof. Take bitcoin as an example. In fact, from a technical point of view, POW can be regarded as a reusable hashcash, and the generation workload proves to be a random process in probability. When mining a new secret currency and generating a block, the consent of all participants must be obtained, and the miner must obtain the pow work proof of all data in the block. At the same time, miners have to constantly observe and adjust the difficulty of this work, because the requirement for the network is to generate a block every 10 minutes on average
blockchain core algorithm 6: distributed storage is a kind of data storage technology, which uses the disk space of each machine through the network, and forms a virtual storage device with these scattered storage resources, and the data is stored in every corner of the network. Therefore, distributed storage technology does not store complete data in each computer, but stores the data in different computers after cutting. It's like storing 100 eggs, not in the same basket, but separately in different places. The total number is 100. Want to learn more, you can make more use of network search, network search results - small knowledge
the development of blockchain application technology is more in the use of its decentralized and tamper proof technology. These two characteristics successfully push the blockchain application technology to the world. People suddenly realize that in this lack of trust society, there can be a technology to change the status quo, and do not need to go through a third party, Completely decentralized technology
if this technology can be popularized, it will be a breakthrough, so the development of blockchain application technology has become the focus of research and development in various countries and regions.
although POW is not optimal, it is now the most practical consensus algorithm. For example, bitcoin, lightcoin and decent all adopt the pow proof mechanism.
imagine that in Byzantine times, there was a rich city-state with all kinds of gold, silver, jewelry, silk and satin, and its Lord Doraemon enjoyed all the luxury and glory. On the outskirts of the city-state, four Byzantine Generals, Daxiong, panghu, Xiaofu and Jingxiang, coveted Doraemon's wealth, so they decided to join hands to capture Doraemon's city-state. According to the strength comparison between the two sides, more than half of the generals must attack at the same time to defeat the enemy, so the winning condition is that at least three of the four can agree on the attack time. What are the odds of the four generals
the answer to this question depends on the cooperation mode of the four people. If it is a centralized system and there is an alliance leader, such as panghu (equivalent to a central server), then there is no doubt about their victory, because it is very easy to reach an agreement on the attack time. As long as panghu calls Daxiong, Xiaofu and Jingxiang to have a meeting to discuss it, Even if we have different opinions, panghu can make a final decision. Now let's go back to the assumption of Byzantine Generals. In a distributed network without trust, what are the odds of four generals winning< br />
?
first of all, e to the lack of trust between the four generals, the possibility of gathering in a small dark room for a conspiracy meeting is ruled out (what if they are kidnapped by panghu in a small dark room?); Secondly, since there is no leader, the opinions of all four people will be equally valued. In this case, the four generals could only negotiate the attack time by sending messages between their camps by messenger. For example, if Daxiong thinks 6 a.m. is a good time to launch an attack, he will send messengers to tell panghu, Xiaofu and Jingxiang their opinions. At the same time, panghu may think it's better to launch a surprise attack at 9 p.m., Xiaofu prefers to launch an attack at 3 p.m., and Jingxiang hopes that it will be 10 a.m., and the three of them will send their own messengers at the same time. In this way, after the first round of communication, each of the four generals had four attack times to choose from, and each of them had to inform the other three of their chosen time in the next round of communication. Because four people make decisions independently, there are 256 possible final choices. Only when more than three people choose the same time can consensus be reached, and there are only 64 such results, that is to say, the probability of reaching consensus is only 1 / 4. This is only the case of four generals. What if the number of generals is 10, 100 or 1000? With a little calculation, we can see that as the number of people increases, the hope of reaching a consensus will become increasingly dim
change the general in the above example into the node in the computer network, the messenger into the communication between nodes, and the attack time into the information that needs to reach a consensus. Then you can understand the dilemma described by the consensus problem. The ability to reach a consensus is self-evident for a payment system. If you remit a sum of money to your family to buy a car and go to the bank the next day for verification, the counter will tell you "about how much money you remit, there are three versions of records in our system". Obviously, you dare not deposit money in such a bank. Before the emergence of bitcoin, the consensus problem is difficult to be solved perfectly. In order to reach a consensus, we need to adopt a centralized system (unless the nodes meet certain conditions), and in order to decentralize the consensus, we can't guarantee it. So how does blockchain technology solve this problem Pay attention to the official account weoption, reply to "block chain", you can view the full text.