A method and system for constructing a PBFT consensus mechanism based on reputation and game

By using the reputation and game theory-based PBFT consensus mechanism, which utilizes the reputation value of VDF computing nodes to select high-reputation nodes and introduces a reward and punishment mechanism, the inefficiency and security issues of blockchain consensus algorithms in large-scale networks are solved, and an efficient and secure consensus process is achieved.

CN122640158APending Publication Date: 2026-08-25TIANJIN UNIVERSITY OF TECHNOLOGY +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610510859.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-04-17
Publication Date
2026-08-25

AI Technical Summary

Technical Problem

Existing blockchain consensus algorithms are inefficient when dealing with large-scale networks, cannot adapt to dynamic networks, and are vulnerable to security threats, especially Byzantine attacks and malicious nodes.

Method used

The consensus mechanism adopts the reputation-based and game-theoretic PBFT. The reputation value of nodes is calculated through the verifiable delay function VDF, high-reputation nodes are selected to participate in the consensus, and a reward and punishment mechanism is introduced to incentivize cooperation and punish betrayal, dynamically adjusting the number of participating nodes and optimizing the consensus process.

Benefits of technology

It improves consensus efficiency, reduces algorithm complexity, enhances system security, adapts to dynamic networks, and effectively resists Byzantine attacks and other security threats.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122640158A_ABST
    Figure CN122640158A_ABST
Patent Text Reader

Abstract

The application discloses a PBFT consensus mechanism construction method and system based on reputation and game, and solves the problems of poor adaptation of traditional PBFT to dynamic networks, large communication overhead and difficulty in identifying malicious nodes. The method comprises the following steps: initializing nodes, calculating reputation values through node mutual evaluation and VDF (verifiable delay function) calculation; screening nodes based on game theory; gradually reducing consensus nodes to a constant number, and optimizing the complexity to O (m); selecting high-reputation master nodes, and resetting the reputation of a master node with a reputation higher than 100 to 50 to compete again. The system comprises a reputation value calculation unit and a theoretical reputation value calculation unit. The application can resist various attacks, adapt to dynamic networks, balance decentralization and node enthusiasm, and improve consensus security and efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of PBFT consensus mechanism, specifically to a method and system for constructing a PBFT consensus mechanism based on reputation and game theory. Background Technology

[0002] Consensus algorithms in blockchain technology are the cornerstone of its security and accuracy. However, currently used blockchain consensus algorithms suffer from security issues and performance bottlenecks, as detailed below: (1) As the network scale expands, the processing speed of blockchain technology is affected, leading to reduced efficiency. Meanwhile, although the decentralized nature of blockchain increases the system's resistance to attacks, the complex consensus mechanism and the constantly changing technological environment also expose the system to new security threats. Therefore, continuous technological innovation and optimization are key to promoting the development of blockchain technology and solving these problems; (2) The Practical Byzantine Fault Tolerance (PBFT) consensus algorithm cannot be used in dynamic networks, requires a lot of communication overhead to reach consensus, and cannot identify Byzantine nodes in the system; (3) Although the PBFT consensus algorithm can tolerate some malicious nodes, the consensus algorithm is still susceptible to security attacks. To address different types of attacks, the blockchain system needs to comprehensively utilize various means such as encryption technology, identity verification, distributed consensus algorithms, and smart contracts to improve the security and robustness of the system, thereby effectively responding to various security threats. Summary of the Invention

[0003] In view of the technical problems mentioned in the background, the purpose of this invention is to provide a method and system for constructing a PBFT consensus mechanism based on reputation and game theory.

[0004] To achieve the objectives of this invention, the technical solution provided by this invention is as follows: First aspect This invention provides a method for constructing a PBFT consensus mechanism based on reputation and game theory, comprising the following steps: Step 1: Before consensus begins, initialize N nodes as nodes participating in block consensus. Then, the nodes score each other to obtain Votes. After that, the VDF verifiable delay function is used to calculate the reputation value of each node. Step 2: Sort the nodes in descending order of their reputation values ​​calculated using VDF. The theoretical reputation value R, previously calculated using game theory, is calculated using the following formula: ; The reputation value of a node. As an initial reward of reputation points, The credit value used as collateral, The reputation points awarded for producing blocks. Rewards of reputation points will be given for reporting. Step 3: Divide all nodes into two parts according to the theoretical reputation value R. If a node's reputation value is much smaller than the theoretical reputation value R, remove the node from the consensus. Select the largest 2 / 3n nodes from the nodes with a reputation value greater than R, and select the largest 1 / 3n nodes from the nodes with a reputation value less than R, where n is the number of nodes with a reputation value greater than R. Step 4: The selected nodes can participate in the next round of consensus, and most of the nodes have high reputation scores, while a small number of nodes with low reputation scores are retained. As consensus progresses, the number of selected nodes decreases step by step, and the number of nodes participating in consensus becomes a constant, which reduces the complexity of PBFT. Step 5: Select the node with the highest reputation value from the replica nodes that have entered the consensus process as the primary node. The primary node is used for block production consensus, collecting feedback information from nodes, verifying node reports in a timely manner, and organizing nodes to punish malicious nodes. In order to prevent the reputation score of the primary node from continuously increasing and to ensure that it does not serve as the primary node for a long time, when the reputation value of a node exceeds 100, it is reset to the initial value of 50 and re-enters the replica node pool to compete for the primary position.

[0005] Second aspect This invention provides a system for constructing a PBFT consensus mechanism based on reputation and game theory, comprising the following units: a reputation value calculation unit, a theoretical reputation value calculation unit, a sorting unit, a node selection unit, and a master node selection unit; The reputation value calculation unit is used to initialize N nodes as nodes participating in block consensus before consensus begins, then the nodes score each other to obtain Votes, and then use the VDF verifiable delay function to calculate the reputation value of each node. The theoretical reputation value calculation unit is used to sort the reputation values ​​of nodes calculated according to VDF in descending order. The theoretical reputation value R previously calculated by game theory is calculated using the following formula: ; The reputation value of a node. As an initial reward of reputation points, The credit value used as collateral, The reputation points awarded for producing blocks. Rewards of reputation points will be given for reporting. The sorting unit is used to divide the sorting of all nodes into two parts according to the theoretical reputation value R. If there is a node whose reputation value is much less than the theoretical reputation value R, the node is directly removed from the consensus. The largest 2 / 3n nodes are selected from the nodes with a reputation value greater than R, and the largest 1 / 3n nodes are selected from the nodes with a reputation value less than R, where n is the number of nodes with a reputation value greater than R. The node selection unit is used to select nodes that can participate in the next round of consensus, and most of the nodes have high reputation values, while a small number of nodes with low reputation values ​​are retained. As the consensus process progresses, the number of selected nodes decreases step by step, and the number of nodes participating in the consensus becomes a constant, which reduces the complexity of PBFT. The primary node selection unit is used to select the node with the highest reputation value from the replica nodes that have entered the consensus process as the primary node. The primary node is used for block production consensus, collecting feedback information from nodes, verifying node reports in a timely manner, and organizing nodes to punish malicious nodes. In order to prevent the reputation score of the primary node from continuously increasing and to ensure that it does not serve as the primary node for a long time, when the reputation value of a node exceeds 100, it is reset to the initial value of 50 and re-enters the replica node pool to compete for the primary position.

[0006] Compared with the prior art, the beneficial effects of the present invention are as follows: (1) The trusted reputation value of a node can be calculated by the verifiable delay function through VDF. Combined with the two-way scoring mechanism between nodes, malicious nodes with reputation far below the theoretical threshold R can be quickly located and directly removed. Malicious nodes will be replaced by high-reputation nodes that have not entered the consensus, ensuring the honesty of nodes participating in the consensus and effectively resisting Byzantine attacks.

[0007] Based on game theory, a reward and punishment mechanism is designed. Cooperative nodes can receive multiple incentives, including block production rewards and reporting rewards, while betrayal nodes face a penalty of deducting twice their staking reputation value. This causes the optimal strategy for betrayal nodes to shift to cooperation, continuously reducing the number of malicious nodes in the network and ensuring system stability.

[0008] Defend against Sybil attacks (short-term abnormal node influx) by using timestamps and the isinput attribute; defend against double-spending attacks by using inter-node supervision and reputation penalties; defend against denial-of-service attacks by using port connection number threshold detection; and meet the consensus requirement of "node response count exceeding 2f+1" to resist Byzantine attacks from interfering with the consensus results.

[0009] (2) Nodes are selected by theoretical reputation value R (2 / 3 high-reputation nodes + 1 / 3 low-reputation nodes), and the number of nodes decreases to a constant number as consensus progresses, reducing the algorithm complexity from O(n^2) of traditional PBFT. 2 The complexity is reduced to O(m), and the master node selection complexity is simultaneously optimized to O(m).

[0010] (3) Malicious nodes or reputation reset nodes that enter the consensus can be replaced in real time by high-reputation nodes that have not participated in the consensus, adapting to dynamic network topology changes and solving the problem that traditional PBFT cannot be used in dynamic networks. When the reputation value of the master node exceeds 100, it is automatically reset to the initial value of 50 and re-participates in the master node competition, preventing a single node from serving as the master node for a long time and ensuring the decentralized nature of the consensus mechanism.

[0011] (4) Nodes that do not enter consensus will still receive replica node ratings and have the opportunity to replace malicious nodes; low-reputation nodes retain the right to participate in consensus and can improve their reputation value through cooperation to compete for master nodes, thus fully mobilizing the participation enthusiasm of all nodes. Attached Figure Description

[0012] Figure 1 A flowchart illustrating the construction method of the PBFT consensus mechanism based on reputation and game theory provided in this embodiment of the invention. Detailed Implementation

[0013] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.

[0014] It should be noted that this invention proposes an improved PBFT algorithm based on reputation and game theory: Game Practical Byzantine Fault Tolerance (RG-PBFT). This invention establishes a reputation model to dynamically reward and punish nodes based on their consensus behavior. By establishing a game theory model, it minimizes the number of nodes participating in consensus, maximizes the efficiency of eliminating malicious nodes, and thus resists some common attacks, reduces algorithm complexity, and improves algorithm security and consensus efficiency.

[0015] Simulation experiments show that the improved consensus algorithm has significant improvements over the PBFT consensus algorithm in terms of consensus latency, communication overhead, throughput, and security.

[0016] like Figure 1 As shown, this embodiment provides a method for constructing a PBFT consensus mechanism based on reputation and game theory, including the following steps: Step 1: Before consensus begins, initialize N nodes as nodes participating in block consensus. Then, the nodes score each other to obtain Votes. After that, the VDF verifiable delay function is used to calculate the reputation value of each node. Step 1 specifically includes the following: Step 1.1: A node's reputation value is represented by a Score, and the inter-node score is represented by Votes. Each node's initial reputation value is 50. If the reputation value exceeds 100, it will be reset to 50 and re-enter the consensus competition for the primary node. The inter-node score Votes is the main reference for the reputation value Score. Each node scores each other at the end of each consensus round. It is important to note that replicas of nodes that have entered the consensus process will also score nodes that have not entered the consensus process, keeping all nodes in the block synchronized so that nodes can be replaced. This increases the probability of nodes that have not entered the consensus process participating in the competition for the primary node, thereby increasing node enthusiasm. Step 1.2: When a node replica that has entered consensus acts maliciously or resets its reputation value, causing a decrease in reputation value, the node with the highest reputation value can be selected from the nodes that have not entered consensus to replace it. These nodes are also the result of mutual evaluation among nodes, and the probability of them being malicious nodes is very low. This ensures that the node replicas participating in consensus are nodes with good reputation values ​​and high honesty, and the elected primary node is more convincing. Step 1.3: At the start of each consensus round, regardless of whether the consensus is successful or not, you can obtain [something]. The credit score is used as a reward, and nodes participating in the consensus need to stake it. The node's reputation value serves as a participation fee; if the node reaches the correct consensus at the end of each consensus round, it will receive [a reward / benefits]. The reputation value is used as a block reward. After each round of consensus, the reputation value is calculated using a verifiable delay function via VDF.

[0017] For two nodes A and B participating in the consensus, and the initial reputation value of nodes A and B is 50, the reputation value is calculated as follows using a verifiable delay function. Step 1.4: Nodes A and B will store their own public and private key pairs locally.<PK,SK> The hash value H(SK) of the private key SK and the delay parameter t are input into the initialization function SetUp to obtain a parameter pair.<ek,vk> The calculation formula for the initialization function SetUp is as follows: ; Step 1.5: Nodes A and B will score each other based on consensus. If node A performs well, it will receive... + The rating reward; if node B performs poorly, it will only receive a score reward. The rating reward will be adjusted, but if node B engages in malicious behavior, node B will also be penalized 2 points. The score is used as a penalty; therefore, the scores Votes of nodes A and B and the hash value H(pre_Block) of the most recent consensus-generated block are input into the Eval calculation function to obtain a random value y and a proof parameter Π; the threshold of the random value y is [0,1]. The random value y is the result obtained by inputting the hash of the previous block and the score into the Eval function. The random value y will be used as the input value in the Verify function to verify whether the final calculated Score value is correct; if correct, y is 1, otherwise it is 0. Therefore, the threshold of the random value y is [0,1]. The Eval function calculation formula is: ; Step 1.6: Input the scores Votes, H(pre_Block), random value y, and proof parameter Π into the verifiable delay function Verify to obtain the verifiable value Score; the verifiable delay function Verify is calculated as follows: ; Step 1.7: Score is the trusted reputation value of each node, where node A has a reputation value of 50+. + Node B's reputation score is 50+ .

[0018] Step 2: Sort the nodes in descending order of their reputation values ​​calculated using VDF. The theoretical reputation value R, previously calculated using game theory, is calculated using the following formula: ; The reputation value of a node. As an initial reward of reputation points, The credit value used as collateral, The reputation points awarded for producing blocks. Rewards of reputation points will be given for reporting. Step 2 specifically includes the following: Step 2.1: Before consensus begins, any node participating in the consensus process, whether cooperating or betraying, can gain reputation points. Nodes will stake their reputation points. Used to verify blocks; if a block is successfully produced in the consensus process, the user receives a reputation value reward from the blockchain. The integrals are ordered from largest to smallest as follows: , , ; Step 2.2: If two nodes A and B in the consensus process choose to cooperate, then each of them will have a reputation value of [value missing]. - + If both A and B choose to betray, then they will each receive a smaller amount. If A chooses to cooperate while B chooses to betray, then A will gain less benefit. B will gain a larger profit. + Conversely, if A chooses to betray and B chooses to cooperate, then A will gain a greater benefit. + B will receive a smaller benefit. ; While cooperation yields the highest total reward for both nodes, if each only considers their own interests, the optimal strategy becomes betrayal. In this scenario, both participants adopting the optimal strategy will result in a lower total reward than if they both cooperated. This situation compromises the security of the blockchain system, hence the introduction of a reward and punishment mechanism. Step 2.3: Define a reward and punishment mechanism. For nodes that choose to cooperate in the consensus process, they will not only receive [benefits] after producing a block, but also... The reward for producing blocks, and the reward for reporting. For nodes that choose to betray, the blockchain will impose a penalty, deducting 2 reputation points. The integrals are ordered from largest to smallest as follows: , , , ; Step 2.4: After defining the reward and punishment mechanism, the optimal choice for cooperating nodes is to continue cooperating; while for betraying nodes, the optimal choice is to cooperate. This ensures the security of the blockchain system. At the same time, as new nodes join and consensus continues, the number of betraying nodes will decrease. Step 2.5: Based on the game theory model, the theoretical value of a node's reputation can be calculated; for a cooperating node, the optimal choice is to continue cooperating, and its reputation value is... + + + ; Step 2.6: For a betraying node, the optimal choice is to cooperate; its reputation value is... -2 + Regarding the point of betrayal, if you still do not choose to cooperate, the best option is to report the other party and receive the reward for reporting. His reputation score is -2 + If someone consistently betrays others and doesn't choose the optimal outcome, their reputation value will decrease. -2 Since the reputation value of each node changes continuously as consensus is reached, the theoretical reputation value calculated by the game theory model also changes continuously as consensus is reached, which can be used as a threshold to filter nodes.

[0019] Step 3: Divide all nodes into two parts according to the theoretical reputation value R. If a node's reputation value is much smaller than the theoretical reputation value R, remove the node from the consensus. Select the largest 2 / 3n nodes from the nodes with a reputation value greater than R, and select the largest 1 / 3n nodes from the nodes with a reputation value less than R, where n is the number of nodes with a reputation value greater than R. Step 4: The selected nodes can participate in the next round of consensus, and most of the nodes have high reputation scores. Retaining a small number of nodes with lower reputation values ​​gives these nodes an opportunity to improve their reputation, increases their motivation, and gives them a chance to compete for master nodes to produce blocks and reach consensus, which also improves the decentralization of consensus. As consensus progresses, the number of nodes selected decreases step by step, and the number of nodes participating in consensus becomes a constant, which reduces the complexity of PBFT. Step 4 specifically includes the following: Step 4.1: Simplify the two pairwise interactions in the prepare and commit phases of the traditional PBFT algorithm into direct communication; Step 4.2: Construction method of PBFT consensus mechanism based on reputation and game theory. The communication of RG-PBFT is as follows: the number of communication in the request stage is 1, the number of communication in the pre-prepare stage is m-1, the number of communication in the prepare stage is m-1, the number of communication in the commit stage is m-1, and the number of communication in the reply stage is m. Therefore, the total number of communication is: f(m)=1+(m-1)+(m-1)+m=4m-2; Step 4.3: The complexity of the RG-PBFT consensus mechanism construction method based on reputation and game theory is O(m), which optimizes the number of nodes participating in the consensus. Considering the communication and coordination of all nodes in the entire network, the time complexity of master node selection is also related to the number of nodes in the network. However, since the complexity of the RG-PBFT consensus mechanism construction method based on reputation and game theory is O(m), the complexity of master node selection in the RG-PBFT consensus mechanism construction method based on reputation and game theory is also O(m).

[0020] Step 5: Select the node with the highest reputation value from the replica nodes that have entered the consensus process as the primary node. The primary node is used for block production consensus, collecting feedback information from nodes, verifying node reports in a timely manner, and organizing nodes to punish malicious nodes. In order to prevent the reputation score of the primary node from continuously increasing and to ensure that it does not serve as the primary node for a long time, when the reputation value of a node exceeds 100, it is reset to the initial value of 50 and re-enters the replica node pool to compete for the primary position.

[0021] In addition, corresponding to the above method, this embodiment also provides a construction system for a PBFT consensus mechanism based on reputation and game theory, including the following units: reputation value calculation unit, theoretical reputation value calculation unit, sorting unit, node selection unit, and master node selection unit; The reputation value calculation unit is used to initialize N nodes as nodes participating in block consensus before consensus begins, then the nodes score each other to obtain Votes, and then use the VDF verifiable delay function to calculate the reputation value of each node. The theoretical reputation value calculation unit is used to sort the reputation values ​​of nodes calculated according to VDF in descending order. The theoretical reputation value R previously calculated by game theory is calculated using the following formula: ; The reputation value of a node. As an initial reward of reputation points, The credit value used as collateral, The reputation points awarded for producing blocks. Rewards of reputation points will be given for reporting. The sorting unit is used to divide the sorting of all nodes into two parts according to the theoretical reputation value R. If there is a node whose reputation value is much less than the theoretical reputation value R, the node is directly removed from the consensus. The largest 2 / 3n nodes are selected from the nodes with a reputation value greater than R, and the largest 1 / 3n nodes are selected from the nodes with a reputation value less than R, where n is the number of nodes with a reputation value greater than R. The node selection unit is used to select nodes that can participate in the next round of consensus, and most of the nodes have high reputation values, while a small number of nodes with low reputation values ​​are retained. As the consensus process progresses, the number of selected nodes decreases step by step, and the number of nodes participating in the consensus becomes a constant, which reduces the complexity of PBFT. The primary node selection unit is used to select the node with the highest reputation value from the replica nodes that have entered the consensus process as the primary node. The primary node is used for block production consensus, collecting feedback information from nodes, verifying node reports in a timely manner, and organizing nodes to punish malicious nodes. In order to prevent the reputation score of the primary node from continuously increasing and to ensure that it does not serve as the primary node for a long time, when the reputation value of a node exceeds 100, it is reset to the initial value of 50 and re-enters the replica node pool to compete for the primary position.

[0022] The reputation value calculation unit is specifically used to perform the following: Step 1.1: A node's reputation value is represented by a Score, and the inter-node score is represented by Votes. Each node's initial reputation value is 50. If the reputation value exceeds 100, it will be reset to 50 and re-enter the consensus competition for the primary node. The inter-node score Votes is a reference for the reputation value Score. Each node scores each other at the end of each consensus round. Node replicas that have entered the consensus will also score nodes that have not entered the consensus, keeping all nodes in the block synchronized. Step 1.2: When a node replica that has entered consensus acts maliciously or resets its reputation value, causing a decrease in reputation value, the node with the highest reputation value among the nodes that have never entered consensus is selected to replace it. This part of the nodes is also the result of mutual scoring between nodes, and the probability of them being malicious nodes is very low. This is used to ensure that the node replicas participating in consensus are nodes with good reputation values. Step 1.3: At the start of each consensus round, regardless of whether the consensus is successful or not, you can obtain [something]. The credit score is used as a reward, and nodes participating in the consensus need to stake it. The node's reputation value serves as a participation fee; if the node reaches the correct consensus at the end of each consensus round, it will receive [a reward / benefits]. The reputation value is used as a block reward. After each round of consensus, the reputation value is calculated using a verifiable delay function via VDF.

[0023] For two nodes A and B participating in the consensus, and the initial reputation value of nodes A and B is 50, the reputation value is calculated as follows using a verifiable delay function. Step 1.4: Nodes A and B will store their own public and private key pairs locally.<PK,SK> The hash value H(SK) of the private key SK and the delay parameter t are input into the initialization function SetUp to obtain a parameter pair.<ek,vk> The calculation formula for the initialization function SetUp is as follows: ; Step 1.5: Nodes A and B will score each other based on consensus. If node A performs well, it will receive... + The rating reward; if node B performs poorly, it will only receive a score reward. The rating reward will be adjusted, but if node B engages in malicious behavior, node B will also be penalized 2 points. The score is used as a penalty; therefore, the scores Votes of nodes A and B and the hash value H(pre_Block) of the most recent consensus-generated block are input into the Eval calculation function to obtain a random value y and a proof parameter Π; the threshold of the random value y is [0,1]. The random value y is the result obtained by inputting the hash of the previous block and the score into the Eval function. The random value y will be used as the input value in the Verify function to verify whether the final calculated Score value is correct; if correct, y is 1, otherwise it is 0. Therefore, the threshold of the random value y is [0,1]. The Eval function calculation formula is: ; Step 1.6: Input the scores Votes, H(pre_Block), random value y, and proof parameter Π into the verifiable delay function Verify to obtain the verifiable value Score; the verifiable delay function Verify is calculated as follows: ; Step 1.7: Score is the trusted reputation value of each node, where node A has a reputation value of 50+. + Node B's reputation score is 50+ .

[0024] Specifically, the theoretical reputation value calculation unit is used to perform the following: Step 2.1: Before consensus begins, any node participating in the consensus process, whether cooperating or betraying, can gain reputation points. Nodes will stake their reputation points. Used to verify blocks; if a block is successfully produced in the consensus process, the user receives a reputation value reward from the blockchain. The integrals are ordered from largest to smallest as follows: , , ; Step 2.2: If two nodes A and B in the consensus process choose to cooperate, then each of them will have a reputation value of [value missing]. - + If both A and B choose to betray, then they will each receive a smaller amount. If A chooses to cooperate while B chooses to betray, then A will gain less benefit. B will gain a larger profit. + Conversely, if A chooses to betray and B chooses to cooperate, then A will gain a greater benefit. + B will receive a smaller benefit. ; Step 2.3: Define a reward and punishment mechanism. For nodes that choose to cooperate in the consensus process, they will not only receive [benefits] after producing a block, but also... The reward for producing blocks, and the reward for reporting. For nodes that choose to betray, the blockchain will impose a penalty, deducting 2 reputation points. The integrals are ordered from largest to smallest as follows: , , , ; Step 2.5: After defining the reward and punishment mechanism, the optimal choice for cooperating nodes is to continue cooperating; while for betraying nodes, the optimal choice is to cooperate. This ensures the security of the blockchain system. At the same time, as new nodes join and consensus continues, the number of betraying nodes will decrease. Step 2.6: Based on the game theory model, the theoretical value of a node's reputation can be calculated; for a cooperating node, the optimal choice is to continue cooperating, and its reputation value is... + + + ; Step 2.7: For a betraying node, the optimal choice is to cooperate; its reputation value is... -2 + Regarding the point of betrayal, if you still do not choose to cooperate, the best option is to report the other party and receive the reward for reporting. His reputation score is -2 + If someone consistently betrays others and doesn't choose the optimal outcome, their reputation value will decrease. -2 Since the reputation value of each node changes continuously as consensus is reached, the theoretical reputation value calculated by the game theory model also changes continuously as consensus is reached, which can be used as a threshold to filter nodes.

[0025] The node selection unit is used to perform the following: Step 4.1: Simplify the two pairwise interactions in the prepare and commit phases of the traditional PBFT algorithm into direct communication; Step 4.2: The communication process of the PBFT consensus mechanism based on reputation and game theory is as follows: the number of communications in the request phase is 1, the number of communications in the pre-prepare phase is m-1, the number of communications in the prepare phase is m-1, the number of communications in the commit phase is m-1, and the number of communications in the reply phase is m. Therefore, the total number of communications is: f(m) = 1 + (m-1) + (m-1) + m = 4m-2; Step 4.3: The complexity of the PBFT consensus mechanism construction method based on reputation and game theory is O(m), which optimizes the number of nodes participating in the consensus. Considering the communication and coordination of all nodes in the entire network, the time complexity of master node selection is also related to the number of nodes in the network. However, since the complexity of the PBFT consensus mechanism construction method based on reputation and game theory is O(m), the complexity of master node selection in the PBFT consensus mechanism construction method based on reputation and game theory is also O(m).

[0026] To improve the security of the algorithm, the PBFT consensus mechanism based on reputation and game theory provided in this invention is used to resist security attacks in the blockchain system.

[0027] (1) Traditional blockchains may be vulnerable to Sybil attacks by malicious users, such as creating many Sybil nodes to manipulate the consensus process. To address this issue, the present invention sets timestamps and isinput attributes for nodes. When a Sybil attack occurs, the timestamp attribute can be used to detect abnormal nodes that flood in within a short period of time. The isinput attribute of these nodes can be set to 0, preventing them from participating in the consensus process. (2) Double-spending attacks are one of the common ways to attack blockchains. To resist double-spending attacks, the present invention involves nodes verifying and supervising each other. If a node is found to be engaging in double-spending, the reputation model will lower the reputation value of the malicious node and remove it, replacing it with another node. The supervising node will also be rewarded with an increased reputation value, thus reducing the number of malicious nodes engaging in double-spending attacks. This method can effectively prevent double-spending attacks and ensure the security of the blockchain. (3) In response to the characteristics of denial-of-service attacks, when a denial-of-service attack occurs, the attack is carried out on the port of the node. When the node detects that the number of connections exceeds the threshold, it performs denial-of-service attack defense, so that the node does not participate in the consensus. (4) Most Byzantine-based algorithms require that the number of Byzantine nodes in the network does not exceed 1 / 3. This algorithm also requires that the number of Byzantine nodes in the network does not exceed 1 / 3. Since the algorithm requires more than 2f+1 node responses before the next consensus can be reached, Byzantine attacks will not affect the final consensus result of the algorithm.

[0028] Finally, it should be noted that the above embodiments are merely illustrative and explanatory of the present invention, and are not intended to limit the present invention to the scope of the described embodiments. Furthermore, those skilled in the art will understand that the present invention is not limited to the above embodiments, and many more variations and modifications can be made based on the teachings of the present invention, all of which fall within the scope of protection claimed by the present invention.

Claims

1. A method for constructing a PBFT consensus mechanism based on reputation and game theory, characterized in that, The steps include the following: Step 1: Before consensus begins, initialize N nodes as nodes participating in block consensus. Then, the nodes score each other to obtain Votes. After that, the VDF verifiable delay function is used to calculate the reputation value of each node. Step 2: Sort the nodes in descending order of their reputation values ​​calculated using VDF. The theoretical reputation value R, previously calculated using game theory, is calculated using the following formula: ; The reputation value of a node. As an initial reward of reputation points, The credit value pledged. The reputation points awarded for block production. Rewards of reputation points will be given for reporting. Step 3: Divide all nodes into two parts according to the theoretical reputation value R. If a node's reputation value is much smaller than the theoretical reputation value R, remove the node from the consensus. Select the largest 2 / 3n nodes from the nodes with a reputation value greater than R, and select the largest 1 / 3n nodes from the nodes with a reputation value less than R, where n is the number of nodes with a reputation value greater than R. Step 4: The selected nodes can participate in the next round of consensus, and most of the nodes have high reputation scores, while a small number of nodes with low reputation scores are retained. As consensus progresses, the number of selected nodes decreases step by step, and the number of nodes participating in consensus becomes a constant, which reduces the complexity of PBFT. Step 5: Select the node with the highest reputation value from the replica nodes that have entered the consensus pool as the primary node. The primary node is used for block production consensus, collecting feedback information from nodes, verifying node reports in a timely manner, and organizing nodes to punish malicious nodes. In order to prevent the reputation score of the primary node from continuously increasing and to ensure that it does not serve as the primary node for a long time, when the reputation value of a node exceeds 100, it is reset to the initial value of 50 and re-enters the replica node pool to compete for the primary position.

2. The method for constructing a PBFT consensus mechanism based on reputation and game theory according to claim 1, characterized in that, Step 1 specifically includes the following: Step 1.1: A node's reputation value is represented by a Score, and the inter-node score is represented by Votes. Each node's initial reputation value is 50. If the reputation value exceeds 100, it will be reset to 50 and re-enter the consensus competition for the primary node. The inter-node score Votes is a reference for the reputation value Score. Each node scores each other at the end of each consensus round. Node replicas that have entered the consensus will also score nodes that have not entered the consensus, keeping all nodes in the block synchronized. Step 1.2: When a node replica that has entered consensus acts maliciously or resets its reputation value, causing a decrease in reputation value, the node with the highest reputation value among the nodes that have never entered consensus is selected to replace it. This part of the nodes is also the result of mutual scoring between nodes, and the probability of them being malicious nodes is very low. This is used to ensure that the node replicas participating in consensus are nodes with good reputation values. Step 1.3: At the start of each consensus round, regardless of whether the consensus is successful or not, you can obtain [something]. The credit score is used as a reward, and nodes participating in the consensus need to stake it. The node's reputation value serves as a participation fee; if the node reaches the correct consensus at the end of each consensus round, it will receive [a reward / benefits]. The reputation value is used as a block reward. After each round of consensus, the reputation value is calculated using a verifiable delay function via VDF.

3. The method for constructing a PBFT consensus mechanism based on reputation and game theory according to claim 2, characterized in that, In step 1, for two nodes A and B participating in the consensus, and the initial reputation value of nodes A and B is 50, the reputation value is calculated as follows using a verifiable delay function; Step 1.4: Nodes A and B will store their own public and private key pairs locally.<PK,SK> The hash value H(SK) of the private key SK and the delay parameter t are input into the initialization function SetUp to obtain a parameter pair.<ek,vk> The calculation formula for the initialization function SetUp is as follows: ; Step 1.5: Nodes A and B will score each other based on consensus. If node A performs well, it will receive... + The rating reward; if node B performs poorly, it will only receive a score reward. The rating reward will be adjusted, but if node B engages in malicious behavior, node B will also be penalized 2 points. The score is used as a penalty; therefore, the scores Votes of nodes A and B and the hash value H (pre_Block) of the most recent consensus-generated block are input into the Eval calculation function to obtain a random value y and a proof parameter Π; the threshold of the random value y is [0,1]. The random value y is the result obtained by inputting the hash of the previous block and the score into the Eval function. The random value y will be used as the input value in the Verify function to verify whether the final calculated Score value is correct; if it is correct, y is 1, otherwise it is 0. Therefore, the threshold of the random value y is [0,1]. Eval function calculation formula: ; Step 1.6: Input the scores Votes, H(pre_Block), random value y, and proof parameter Π into the verifiable delay function Verify to obtain the verifiable value Score; the verifiable delay function Verify is calculated as follows: ; Step 1.7: Score is the trusted reputation value of each node, where node A has a reputation value of 50+. + Node B's reputation score is 50+ .

4. The method for constructing a PBFT consensus mechanism based on reputation and game theory according to claim 3, characterized in that, Step 2 specifically includes the following: Step 2.1: Before consensus begins, any node participating in the consensus process, whether cooperating or betraying, can gain reputation points. Nodes will stake their reputation points. Used to verify blocks; if a block is successfully produced in the consensus process, the user receives a reputation value reward from the blockchain. The integrals are ordered from largest to smallest as follows: , , ; Step 2.2: If two nodes A and B in the consensus process choose to cooperate, then each of them will have a reputation value of [value missing]. - + If both A and B choose to betray, then they will each gain a smaller amount. If A chooses to cooperate while B chooses to betray, then A will gain less benefit. B will gain a larger profit. + Conversely, if A chooses to betray and B chooses to cooperate, then A will gain a greater benefit. + B will receive a smaller benefit. ; Step 2.3: Define a reward and punishment mechanism. For nodes that choose to cooperate in the consensus process, they will not only receive [benefits] after producing a block, but also... The reward for producing blocks, and the reward for reporting. For nodes that choose to betray, the blockchain will impose a penalty, deducting 2 reputation points. The integrals are ordered from largest to smallest as follows: , , , ; Step 2.4: After defining the reward and punishment mechanism, the optimal choice for cooperating nodes is to continue cooperating; while for betraying nodes, the optimal choice is to cooperate. This ensures the security of the blockchain system. At the same time, as new nodes join and consensus continues, the number of betraying nodes will decrease. Step 2.5: Based on the game theory model, the theoretical value of a node's reputation can be calculated; for a cooperating node, the optimal choice is to continue cooperating, and its reputation value is... + + + ; Step 2.6: For a betraying node, the optimal choice is to cooperate; its reputation value is... -2 + Regarding the point of betrayal, if you still do not choose to cooperate, the best option is to report the other party and receive the reward for reporting. His reputation score is -2 + If someone consistently betrays others and doesn't choose the optimal outcome, their reputation value will decrease. -2 Since the reputation value of each node changes continuously as consensus is reached, the theoretical reputation value calculated by the game theory model also changes continuously as consensus is reached, which can be used as a threshold to filter nodes.

5. The method for constructing a PBFT consensus mechanism based on reputation and game theory according to claim 4, characterized in that, Step 4 specifically includes the following: Step 4.1: Simplify the two pairwise interactions in the prepare and commit phases of the traditional PBFT algorithm into direct communication; Step 4.2: The communication process of the PBFT consensus mechanism based on reputation and game theory is as follows: the number of communications in the request phase is 1, the number of communications in the pre-prepare phase is m-1, the number of communications in the prepare phase is m-1, the number of communications in the commit phase is m-1, and the number of communications in the reply phase is m. Therefore, the total number of communications is: f(m) = 1 + (m-1) + (m-1) + m = 4m-2; Step 4.3: The complexity of the PBFT consensus mechanism construction method based on reputation and game theory is O(m), which optimizes the number of nodes participating in the consensus. Considering the communication and coordination of all nodes in the entire network, the time complexity of master node selection is also related to the number of nodes in the network. However, since the complexity of the PBFT consensus mechanism construction method based on reputation and game theory is O(m), the complexity of master node selection in the PBFT consensus mechanism construction method based on reputation and game theory is also O(m).

6. A system for constructing a PBFT consensus mechanism based on reputation and game theory, characterized in that, It includes the following units: reputation value calculation unit, theoretical reputation value calculation unit, sorting unit, node selection unit, and master node selection unit; The reputation value calculation unit is used to initialize N nodes as nodes participating in block consensus before consensus begins, then the nodes score each other to obtain Votes, and then use the VDF verifiable delay function to calculate the reputation value of each node. The theoretical reputation value calculation unit is used to sort the reputation values ​​of nodes calculated according to VDF in descending order. The theoretical reputation value R previously calculated by game theory is calculated using the following formula: ; The reputation value of a node. As an initial reward of reputation points, The credit value pledged. The reputation points awarded for block production. Rewards of reputation points will be given for reporting. The sorting unit is used to divide the sorting of all nodes into two parts according to the theoretical reputation value R. If there is a node whose reputation value is much less than the theoretical reputation value R, the node is directly removed from the consensus. The largest 2 / 3n nodes are selected from the nodes with a reputation value greater than R, and the largest 1 / 3n nodes are selected from the nodes with a reputation value less than R, where n is the number of nodes with a reputation value greater than R. The node selection unit is used to select nodes that can participate in the next round of consensus, and most of the nodes have high reputation values, while a small number of nodes with low reputation values ​​are retained. As the consensus process progresses, the number of selected nodes decreases step by step, and the number of nodes participating in the consensus becomes a constant, which reduces the complexity of PBFT. The primary node selection unit is used to select the node with the highest reputation value from the replica nodes that have entered the consensus process as the primary node. The primary node is used for block production consensus, collecting feedback information from nodes, verifying node reports in a timely manner, and organizing nodes to punish malicious nodes. In order to prevent the reputation score of the primary node from continuously increasing and to ensure that it does not serve as the primary node for a long time, when the reputation value of a node exceeds 100, it is reset to the initial value of 50 and re-enters the replica node pool to compete for the primary position.

7. The system for constructing a PBFT consensus mechanism based on reputation and game theory as described in claim 6, characterized in that, The reputation value calculation unit is specifically used to perform the following: Step 1.1: A node's reputation value is represented by a Score, and the inter-node score is represented by Votes. Each node's initial reputation value is 50. If the reputation value exceeds 100, it will be reset to 50 and re-enter the consensus competition for the primary node. The inter-node score Votes is a reference for the reputation value Score. Each node scores each other at the end of each consensus round. Node replicas that have entered the consensus will also score nodes that have not entered the consensus, keeping all nodes in the block synchronized. Step 1.2: When a node replica that has entered consensus acts maliciously or resets its reputation value, causing a decrease in reputation value, the node with the highest reputation value among the nodes that have never entered consensus is selected to replace it. This part of the nodes is also the result of mutual scoring between nodes, and the probability of them being malicious nodes is very low. This is used to ensure that the node replicas participating in consensus are nodes with good reputation values. Step 1.3: At the start of each consensus round, regardless of whether the consensus is successful or not, you can obtain [something]. The credit score is used as a reward, and nodes participating in the consensus need to stake it. The node's reputation value serves as a participation fee; if the node reaches the correct consensus at the end of each consensus round, it will receive [a reward / benefits]. The reputation value is used as a block reward. After each round of consensus, the reputation value is calculated using a verifiable delay function via VDF.

8. The system for constructing a PBFT consensus mechanism based on reputation and game theory as described in claim 7, characterized in that, For two nodes A and B participating in the consensus, and the initial reputation value of nodes A and B is 50, the reputation value is calculated as follows using a verifiable delay function; Step 1.4: Nodes A and B will store their own public and private key pairs locally.<PK,SK> The hash value H(SK) of the private key SK and the delay parameter t are input into the initialization function SetUp to obtain a parameter pair.<ek,vk> The calculation formula for the initialization function SetUp is as follows: ; Step 1.5: Nodes A and B will score each other based on consensus. If node A performs well, it will receive... + The rating reward; if node B performs poorly, it will only receive a score reward. The rating reward will be adjusted, but if node B engages in malicious behavior, node B will also be penalized 2 points. The score is used as a penalty; therefore, the scores Votes of nodes A and B and the hash value H (pre_Block) of the most recent consensus-generated block are input into the Eval calculation function to obtain a random value y and a proof parameter Π; the threshold of the random value y is [0,1]. The random value y is the result obtained by inputting the hash of the previous block and the score into the Eval function. The random value y will be used as the input value in the Verify function to verify whether the final calculated Score value is correct; if it is correct, y is 1, otherwise it is 0. Therefore, the threshold of the random value y is [0,1]. Eval function calculation formula: ; Step 1.6: Input the scores Votes, H(pre_Block), random value y, and proof parameter Π into the verifiable delay function Verify to obtain the verifiable value Score; the verifiable delay function Verify is calculated as follows: ; Step 1.7: Score is the trusted reputation value of each node, where node A has a reputation value of 50+. + Node B's reputation score is 50+ .

9. A system for constructing a PBFT consensus mechanism based on reputation and game theory as described in claim 8, characterized in that, The theoretical reputation value calculation unit is specifically used to perform the following: Step 2.1: Before consensus begins, any node participating in the consensus process, whether cooperating or betraying, can gain reputation points. Nodes will stake their reputation points. Used to verify blocks; if a block is successfully produced in the consensus process, the user receives a reputation value reward from the blockchain. The integrals are ordered from largest to smallest as follows: , , ; Step 2.2: If two nodes A and B in the consensus process choose to cooperate, then each of them will have a reputation value of [value missing]. - + If both A and B choose to betray, then they will each gain a smaller amount. If A chooses to cooperate while B chooses to betray, then A will gain less benefit. B will gain a larger profit. + Conversely, if A chooses to betray and B chooses to cooperate, then A will gain a greater benefit. + B will receive a smaller benefit. ; Step 2.3: Define a reward and punishment mechanism. For nodes that choose to cooperate in the consensus process, they will not only receive [benefits] after producing a block, but also... The reward for producing blocks, and the reward for reporting. For nodes that choose to betray, the blockchain will impose a penalty, deducting 2 reputation points. The integrals are ordered from largest to smallest as follows: , , , ; Step 2.4: After defining the reward and punishment mechanism, the optimal choice for cooperating nodes is to continue cooperating; while for betraying nodes, the optimal choice is to cooperate. This ensures the security of the blockchain system. At the same time, as new nodes join and consensus continues, the number of betraying nodes will decrease. Step 2.5: Based on the game theory model, the theoretical value of a node's reputation can be calculated; for a cooperating node, the optimal choice is to continue cooperating, and its reputation value is... + + + ; Step 2.6: For a betraying node, the optimal choice is to cooperate; its reputation value is... -2 + Regarding the point of betrayal, if you still do not choose to cooperate, the best option is to report the other party and receive the reward for reporting. His reputation score is -2 + If someone consistently betrays others and doesn't choose the optimal outcome, their reputation value will decrease. -2 Since the reputation value of each node changes continuously as consensus is reached, the theoretical reputation value calculated by the game theory model also changes continuously as consensus is reached, which can be used as a threshold to filter nodes.

10. The method for constructing a PBFT consensus mechanism based on reputation and game theory according to claim 9, characterized in that, The node selection unit is used to perform the following: Step 4.1: Simplify the two pairwise interactions in the prepare and commit phases of the traditional PBFT algorithm into direct communication; Step 4.2: The communication process of the PBFT consensus mechanism based on reputation and game theory is as follows: the number of communications in the request phase is 1, the number of communications in the pre-prepare phase is m-1, the number of communications in the prepare phase is m-1, the number of communications in the commit phase is m-1, and the number of communications in the reply phase is m. Therefore, the total number of communications is: f(m) = 1 + (m-1) + (m-1) + m = 4m-2; Step 4.3: The complexity of the PBFT consensus mechanism construction method based on reputation and game theory is O(m), which optimizes the number of nodes participating in the consensus. Considering the communication and coordination of all nodes in the entire network, the time complexity of master node selection is also related to the number of nodes in the network. However, since the complexity of the PBFT consensus mechanism construction method based on reputation and game theory is O(m), the complexity of master node selection in the PBFT consensus mechanism construction method based on reputation and game theory is also O(m).