What is a blockchain? Simply put, the blockchain is a decentralized database, or it can be called a distributed ledger. Traditionally, all databases are centralized. For example, bank account books are stored in the central server of the bank. The disadvantage of centralized database is that the security and correctness of data all depend on the database operator (that is, the bank), because anyone who can access the centralized database (such as bank staff or hackers) can destroy or modify the data in it.
Blockchain technology allows databases to be stored on thousands of computers around the world, and everyone's books are synchronized through peer-to-peer networks. Once any user in the network adds a transaction, the transaction information will be notified to other users through the network for verification and recorded in their own books. Blockchain is named because it is a data structure that blocks containing transaction information are sequentially linked from back to front.
Many people's questions about blockchain are: If each user has an independent account book, does it mean that any transaction information can be added to his account book? How can thousands of account books ensure the consistency of accounting? Solving the problem of accounting consistency is the goal of the blockchain * * * recognition mechanism. The blockchain * * * knowledge mechanism aims to ensure that all nodes in a distributed system have exactly the same data and can agree on a proposal (such as transaction records). However, due to the introduction of multiple nodes in the distributed system, various very complicated situations will occur in the system; With the increase of the number of nodes, the failure of nodes and the interference or even blocking of network communication between nodes have become common problems, and solving various boundary conditions and emergencies in distributed systems has also increased the difficulty of solving distributed consistency problems.
Blockchains can be divided into three types:
Public chain: anyone in the world can access the system at any time to read data, send confirmable transactions and compete for accounting. Public chains are usually considered as "completely decentralized" because no one or organization can control or tamper with the reading and writing of data in them. Public chain generally encourages participants to compete for bookkeeping through token mechanism to ensure the security of data.
Alliance chain: Alliance chain refers to the blockchain managed by several institutions. Each institution runs one or more nodes, the data of which only allows different institutions in the system to read, write and send transactions, and * * * records the transaction data together. This type of blockchain is considered to be "partially decentralized".
Private chain: refers to the blockchain whose writing rights are controlled by organizations and institutions. The qualification of participating nodes will be strictly restricted. Because the participating nodes are limited and controllable, private chains often have extremely fast transaction speed, better privacy protection, lower transaction cost, are not easy to be maliciously attacked, and can meet the necessary requirements of financial industries such as identity authentication. Compared with centralized database, private chain can prevent a single node in an organization from deliberately hiding or tampering with data. Even if there is an error, the source can be found quickly, so many large financial institutions prefer to use private chain technology at present.
Second, the classification of blockchain * * * identification mechanism
The difficulty of solving the distributed consistency problem has given birth to several cognitive mechanisms, each of which has its own advantages and disadvantages and is also suitable for different environments and problems. * * * knowledge mechanisms generated by common sense are:
L PoW (proof of work) workload proof mechanism
L PoS (proof of equity) equity/equity proof mechanism
L DPoS (certificate of entrusted equity) share authorization certificate mechanism
Lpbft (practical Byzantine fault tolerance) practical Byzantine fault tolerance algorithm
Byzantine Fault Tolerance Algorithm Authorized by Ldbft (Entrusted Byzantine Fault Tolerance)
L SCP (star consensus protocol) star knowledge protocol.
Lrpca (ripple protocol consistency algorithm) ripple * * * identification algorithm
L pool authentication pool * * * knowledge mechanism
(A) PoW (proof of work) workload proof mechanism
1. Basic introduction
In this mechanism, every node on the network uses SHA256 hash function to calculate the hash sum of changing block headers. * * * Knowledge requires that the calculated value must be equal to or less than the given value. In the distributed network, all participants need to use different random numbers to continuously calculate hash values until the goal is achieved. When one node calculates the exact value, all other nodes must confirm the correctness of the value. After that, the transactions in the new block will be verified to prevent fraud.
In Bitcoin, the node on which the hash value is calculated is called "miner", and the process of PoW is called "mining". Mining is a time-consuming process, so the corresponding incentive mechanism (such as granting miners a small amount of bitcoin) is also proposed. The advantage of PoW is complete decentralization, but the disadvantages are the waste of resources caused by consuming a lot of computing power, the long period of reaching * * * knowledge, and the low efficiency of * * * knowledge, which is not suitable for commercial use.
2. Application examples of cryptocurrency
Bitcoin and Litecoin. The first three stages (frontier, homeland, metropolis) of Yitai Square all adopt the PoW mechanism, and the fourth stage (tranquility) will adopt the rights and interests proof mechanism. PoW applies to public chains.
Although the PoW mechanism has successfully proved its long-term stability and relative fairness, under the existing framework, adopting the "mining" form of PoW will consume a lot of energy. The energy it consumes just keeps doing SHA256 operations to ensure a fair workload, which has no other significance. At present, the transaction efficiency that BTC can achieve is about 5TPS (5 transactions per second). At present, limited by the upper limit of the total gas consumption per block, the transaction frequency of Ethereum is about 25TPS, which is far from the average processing efficiency of VISA and MASTERCARD 1000 transactions per second and the peak processing efficiency of each transaction per second 10000 transactions.
3. Sketch understanding mode
(ps: Among them, the process of calculating the hash values of A, B, C and D is "mining". In order to reward the time cost, the mechanism will use a certain amount of bitcoin as an incentive. )
(PS: PS: POS mode, your "mining" income is directly proportional to your coin age (number of coins * days) and has nothing to do with the computing performance of the computer. We can think that the accumulation of any probability event is a proof of workload, such as gold panning. Assuming that the gold content of ore is p% by mass, when you get a certain amount of gold, we can assume that you must have excavated 1/p ore. And the more gold you get, the more reliable this proof will be. )
(B) PoS equity/equity certification mechanism.
1. Basic introduction
PoS requires people to prove the ownership of money, thinking that people with more money are less likely to attack the network. The choice based on account balance is very unfair, because the single richest person will inevitably dominate the network, so many solutions are put forward.
In the equity authentication mechanism, whenever a block is created, miners need to create a transaction called "currency rights", which will send some coins to miners in advance according to a certain proportion. Then, according to the proportion and time (currency age) of tokens held by each node, the equity proof mechanism reduces the difficulty of node mining proportionally according to the algorithm, thus speeding up the speed of node searching for random numbers and shortening the time needed to realize * * * knowledge.
Compared with PoW, PoS is more energy-saving and more efficient. But because the cost of mining is close to zero, it may be attacked. Moreover, in essence, PoS still needs nodes in the network to carry out mining operations, so it is difficult to be applied to the commercial field.
2. The application example of digital currency.
The mature digital currency under PoS mechanism are Peercoin and Future Coin (NXT). Compared with PoW, PoS mechanism saves energy and introduces the concept of "currency day" to participate in random operation. PoS mechanism can allow more holders to participate in bookkeeping without purchasing additional equipment (mining machines, graphics cards, etc.). The computing power of each unit token is positively related to its holding time, that is, the more tokens the holder holds and the longer he holds them, the greater the probability that he can check out the next piece. Once it signs the next block, the number of days of currency held by the holder will be cleared and it will enter a new cycle again.
PoS is suitable for public chains.
3. Method for generating group signer
Under the PoS mechanism, because the signers of the block are randomly generated, some currency holders will hold tokens in large quantities for a long time in order to gain a greater probability of generating the block, so as to clear his "currency day" as much as possible. Therefore, the circulation of tokens in the whole network will be reduced, which is not conducive to the circulation of tokens in the chain, and the price is more prone to fluctuations. Because there may be a few large households holding most of the tokens in the whole network, with the increase of running time, the whole network may become more and more concentrated. Compared with PoW, the cost of doing evil under PoS mechanism is very low, so more mechanisms are needed to ensure the knowledge of bifurcation or double payment attacks. In a stable situation, about 12 transactions can be generated per second, but due to network delay and * * identification problems, it takes about 60 seconds to completely broadcast * * * blocks. In the long run, the speed of generating blocks (that is, clearing "currency day") is much lower than the speed of network transmission and broadcasting, so it is necessary to "limit the speed" of generating blocks under PoS mechanism to ensure the stable operation of the main network.
4. Sketch understanding mode
(PS: The more "shares" a person has, the easier it is to get the right to keep accounts. This means that how much money you get depends on your contribution to mining. The better the computer performance, the more mines you will get. )
(In a pure POS system, such as NXT, there is no mining process, the initial equity distribution has been fixed, and then only equity flows between traders, which is very similar to the real stock. )
(C) DPoS (Certificate of Entrusted Equity) share authorization certificate mechanism
1. Basic introduction
Due to the disadvantages of PoS, DPoS (Certificate of Entrusted Equity) initiated by this stock came into being. The core element of the organization mechanism for the disabled is the election. The original token holders of each system can participate in the blockchain election, and the balance of the tokens held is the voting weight. Through voting, shareholders can elect members of the board of directors and express their attitudes on issues related to the development direction of the platform, which form the basis of community autonomy. In addition to voting in elections, shareholders can also vote on their behalf by authorizing their own electoral votes to other accounts they trust.
Specifically, DPoS was invented by Bitshares project team. Equity owners have the right to elect their representatives to generate and verify blocks. DPoS is similar to the modern enterprise board system. In the bit stock system, token holders are called shareholders, who elect 10 1 representatives, and then these representatives are responsible for generating and verifying blocks. If the currency holder wants to be called a representative, he/she needs to register with the blockchain with his/her public key to obtain a unique identifier with a length of 32 bits. Shareholders can vote on the logo in the form of transaction, and the former 10 1 vote is selected as the representative.
The client generates the block in turn, and the income (transaction fee) is divided equally. The advantage of DPoS is that it greatly reduces the number of nodes involved in block verification and bookkeeping, thus shortening the time required for verification and greatly improving the transaction efficiency. To some extent, DPoS can be understood as a multi-center system, which has both decentralized and centralized advantages. Advantages: the number of nodes participating in verification and billing is greatly reduced, and second-level authentication can be realized. Disadvantages: the voting enthusiasm is not high, and most token holders did not participate in the voting; In addition, the whole knowledge mechanism still depends on tokens, and many business applications do not need tokens.
The DPoS mechanism requires that before generating the next block, it must be verified that the previous block has been signed by the trusted node. Compared with the "national adoption" of PoS, DPoS adopts a system similar to "Congress" to directly select trusted nodes. These trusted nodes (that is, witnesses) exercise power instead of other money holders, and the witness nodes require long-term online, thus solving a series of problems such as congestion and delay that may be caused by PoS signers' infrequent online. DPoS mechanism can usually reach the transaction speed of 10000 transactions per second, and can reach the level of 100000 seconds with low network delay, which is very suitable for enterprise applications. Because the data exchange of Gongxinbao requires high data transaction frequency and long-term stability, DPoS is a very good choice.
2. Institutions and systems under the shared authorization and authentication mechanism
The board of directors is the authority of the blockchain network. The candidates for the board of directors are elected by the shareholders of the system (that is, the holders of money), and the members of the board of directors have the right to initiate proposals and vote on them.
One of the important responsibilities of the Council is to adjust the variable parameters of the system as needed, including:
L cost-related: the rates of various transaction types.
L authorization-related: related parameters for charging and subsidizing third-party platforms accessing the network.
L block production related: block production interval time, block reward.
L identity audit related: audit and verify abnormal institutional account information.
At the same time, matters related to the interests of the Council will not be set by the Council.
In Finchain system, the witness is responsible for collecting all kinds of transactions broadcast during the network operation and packaging them into blocks. Its work is similar to that of miners in the bitcoin network. In the bitcoin network with PoW (proof of workload), which miner node generates the next block is determined by lottery method, and the winning probability of this method depends on hash calculation. In the financial chain network with DPoS mechanism, the number of witnesses is decided by the board of directors and the candidates of witnesses are decided by the holders. The selected active witness packages transactions in order and generates blocks. After each round of box making, the witness will randomly shuffle the cards and decide the new order, and then enter the next round of box making.
3. Application example of 3.DPOS
Bitshares uses dpo. DPoS is mainly suitable for alliance chain.
4. Sketch understanding mode
(D) PBFT (Practical Byzantine Fault Tolerance) Practical Byzantine Fault Tolerance Algorithm.
1. Basic introduction
PBFT is an algorithm based on strict mathematical proof, which requires three stages of information interaction and local knowledge to achieve the final consistent output. Three stages of preparation-preparation, preparation and submission. PBFT algorithm proves that as long as there are more than 2/3 normal nodes in the system, the consistent knowledge results can be guaranteed. In other words, in the system using PBFT algorithm, the number of failed nodes (including nodes that intentionally mislead, intentionally destroy the system, timeout, repeatedly send messages, forge signatures, etc.). , also known as the "Byzantine" node) can be tolerated at most.
2. Application example of 2.PBFT
The famous alliance chain Hyperledger Fabric v0.6 adopts PBFT, and v 1.0 introduces the improved version of SBFT PBFT. PBFT is mainly suitable for private chain and alliance chain.
3. Sketch understanding mode
The above figure shows the simplified protocol communication mode of PBFT, where C is the client, 0–3 is the service node, 0 is the master node, and 3 is the fault node. The basic process of the whole agreement is as follows:
(1) The client sends a request to activate the service operation of the master node;
(2) When the master node receives the request, it starts the three-phase protocol to broadcast the request to all slave nodes;
(a) in the sequence number allocation stage, the master node allocates a sequence number n for the request, broadcasts the sequence number allocation message and the request message m of the client, and constructs a pre-preparation message for each slave node;
(b) in the interactive stage, receiving the pre-prepared message from the node and broadcasting it to other service nodes;
(c) In the sequence number confirmation stage, after verifying the request and order in the view, each node broadcasts a submit message, executes the request received from the client, and responds to the client.
(3) The client waits for responses from different nodes, and if there are m+ 1 responses that are the same, the response is the result of operation;
(5) Byzantine fault-tolerant algorithm authorized by DBFT.
1. Basic introduction
DBFT is based on PBFT. In this mechanism, there are two kinds of participants, one is the "super node" of professional bookkeeping, and the other is the ordinary user who does not participate in bookkeeping in the system. Ordinary users vote for the super node according to their own equity ratio. When a * * * knowledge (accounting) needs to be transferred, a spokesman is randomly selected from these super nodes to draw up a scheme, and then other super nodes make statements according to the Byzantine fault-tolerant algorithm (see above), that is, the principle that the minority obeys the majority. If more than two-thirds of the super nodes agree with the speaker's plan, then * * * will be realized. This proposal becomes the final release block, which is irreversible, and all transactions in it are confirmed by 100%. If no unanimous proposal is reached within a certain period of time, or illegal transactions are found, other super nodes can re-sponsor the proposal and repeat the voting process until a consensus is reached.
2. Application example of 2.DBFT
NEO, a domestic cryptocurrency and blockchain platform, is the developer and adopter of DBFT algorithm.
3. Sketch understanding mode
Assuming that there are only four super nodes selected by ordinary users in the system, when it is necessary to transfer a * * * knowledge, the system will randomly select a spokesman from the representatives to draw up a plan. The speaker will give the proposed scheme to each representative, and each representative will first judge whether the calculation result of the speaker is consistent with his own record, and then discuss with other representatives to verify whether the calculation result is correct. If two-thirds of the delegates unanimously agree that the calculation result of the speaker's scheme is correct, then the scheme is passed.
If less than two thirds of the delegates have reached an understanding of * * * *, a new speaker will be selected at random, and then the above process will be repeated. The system is designed to protect the system from the influence of an inoperable leader.
The above figure assumes that all nodes are honest, reaching 100%***, and Scheme A (block) will be verified.
Since the speaker is a randomly selected representative, he may be dishonest or collapse. The above figure assumes that the speaker sent malicious information to two of the Theory of Three Represents (Scheme B) and correct information to 1 representatives (Scheme A).
In this case, malicious information (Scheme B) cannot pass. The calculation results of the middle and right representatives were inconsistent with those sent by the spokesman, and the plan drawn up by the spokesman could not be verified, which led them to refuse to pass the plan. Because the representative on the left received the correct information, which was consistent with his own calculation results, he was able to confirm the scheme and then successfully completed 1 verification. However, this plan still cannot be passed because less than two-thirds of the delegates have reached a consensus. Then a new speaker will be randomly selected to start the knowledge process again.
The above picture assumes that the speaker is honest, but 1 stands for pervert; The representative on the right sent incorrect information to other representatives (B).
In this case, the correct information (a) drawn up by the speaker can still be verified, because both the honest representatives on the left and in the middle can verify the scheme drawn up by the honest speaker, reaching two-thirds of the knowledge. The representative can also judge whether the speaker lied to the right node or the right node was dishonest.
(6) SCP (Star Consensus Protocol) star identification protocol.
1. Basic introduction
SCP is a * * * identification algorithm developed and used by Stellar (a decentralized global payment protocol based on the Internet), which is based on the federal Byzantine protocol. Traditional non-federated Byzantine protocols (such as PBFT and DBFT above) are centralized systems, although knowledge and Byzantine fault tolerance can be guaranteed by distributed methods (at most, 1/3 of the total number of system nodes can be tolerated). The number and identity of nodes in the network must be known and verified in advance. The difference between the federal Byzantine agreement and the federal Byzantine agreement is that it can be decentralized and realize Byzantine fault tolerance.
[…]
(7) RPCA (Ripple protocol consistency algorithm) Ripple * * * identification algorithm.
1. Basic introduction
RPCA is an algorithm developed and used by Ripple (an open source payment protocol based on Internet, which can realize decentralized currency exchange, payment and settlement). In Ripple's network, transactions are initiated by clients (applications) and broadcast to the whole network through tracking nodes or verification nodes. The main function of the tracking node is to publish transaction information and respond to customer account book requests. The verification node not only contains all the functions of the tracking node, but also can add new account book instance data in the account book through the * * * knowledge agreement.
Ripple's * * * knowledge achievement occurs between verification nodes, and each verification node is pre-configured with a trusted node list called UNL(Unique Node List). Nodes in the list can vote on transactions. * * * The knowledge flow is as follows:
(1) Each verification node will continuously receive transactions sent by the network. After verification with local ledger data, illegal transactions will be directly discarded, while legal transactions will be summarized into a candidate set. The transaction candidate set also includes unconfirmed transactions left over from previous * * * knowledge processes.
(2) Each verification node sends its own transaction candidate set as a suggestion to other verification nodes.
(3) After receiving the proposal from other nodes, if the proposal is not from the node on UNL, the verification node ignores the proposal; If it is from a node on UNL, the transaction in the proposal will be compared with the local transaction candidate set, and if there is the same transaction, the transaction will get one vote. In a certain period of time, when the transaction gets more than 50% of the votes, the transaction enters the next round. No more than 50% of transactions will be confirmed in the next * * * knowledge process.
(4) The verification node sends the transaction with more than 50% votes as a proposal to other nodes, and at the same time raises the threshold of required votes to 60%, and repeats steps (3) and (4) until the threshold reaches 80%.
(5) The verification node formally writes the transactions confirmed by 80%UNL nodes into the local general ledger data, which is called the last closed general ledger, that is, the last (latest) status of the general ledger.
In Ripple's * * * authentication algorithm, the identity of the voting node is known in advance, so the efficiency of the algorithm is more efficient than the anonymous * * * authentication algorithm such as PoW, and the transaction confirmation time only takes a few seconds. This also determines that * * * knowledge algorithm is only applicable to alliance chain or private chain. Ripple*** knowledge algorithm has a Byzantine fault tolerance (BFT) of (n- 1)/5, which means that 20% of nodes in the whole network can tolerate Byzantine errors without affecting correct knowledge.
2. Sketch understanding mode
* * * Schematic diagram of process node interaction:
* * * Algorithm flow:
(8) The talent pool verifies the knowledge mechanism of the talent pool.
Pool verification pool knowledge mechanism is a mechanism developed on the basis of traditional distributed consistency algorithms (Paxos and Raft). Paxos algorithm is a highly fault-tolerant and consistent algorithm based on message passing proposed in 1990. Paxos has always been the standard of distributed protocols in the past, but Paxos is difficult to understand and even more difficult to implement. Raft is a consistency algorithm released on 20 13, which is simpler than Paxos and can solve the problems solved by Paxos. Parks and Rafter met in the same way as an election. Candidates need to convince most voters (servers) to vote for them, and once they are selected, they will follow their instructions. The difference between Paxos and Raft lies in the specific process of election. Pool verification pool knowledge mechanism is based on these two mature distributed consistency algorithms, supplemented by data verification mechanism.