Improved PBFT consensus method for energy block chain
Through the optimization of the PBFT consensus algorithm, the node evaluation mechanism and dynamic ingress and exit mechanism are adopted, combined with the verifiable random function VRF, the high overhead and malicious node problems of PBFT algorithm in distributed energy transactions are solved, and a more efficient and secure consensus process is achieved.
Patent Information
- Application Number
- CN202411691461.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-02-28
AI Technical Summary
Existing PBFT consensus algorithms have high communication and computing overhead in distributed energy transactions, especially when node sizes are expanded and malicious nodes exist, resulting in transaction delays and system performance degradation.
By optimizing the PBFT algorithm, the node evaluation mechanism is adopted to dynamically adjust the priority of node participation consensus, design the node dynamic entry and exit mechanism, and introduce a verifiable random function VRF to elect leaders to ensure system security and efficiency.
It reduces transaction delay in the consensus process, improves throughput, enhances the system's security and anti-malignant node capabilities, and mitigates the impact of DoS attacks.
Smart Images

Figure CN119544180A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of energy blockchain, and in particular to an improved PBFT consensus method for energy blockchain. Background Art
[0002] With the development of renewable energy technology and the advancement of energy structure transformation, distributed energy resources (DER) have gradually become an important part of the modern energy system. Distributed energy includes solar energy, wind energy, small hydropower generation and energy storage systems. These small energy units scattered on the user side can significantly improve energy efficiency, reduce carbon emissions, and enhance the flexibility of the energy system. In order to give full play to the advantages of distributed energy and realize its economic value, distributed energy trading has emerged. This trading model allows producers and consumers of distributed energy to directly trade energy in local networks or microgrids, building a more flexible and efficient energy market.
[0003] However, the current distributed energy trading system still faces many challenges. First, the traditional trading model relies on centralized power companies or platforms to record and settle transactions, resulting in high trust costs and prone to data opacity and information asymmetry. Second, due to the small, decentralized and high-frequency characteristics of distributed energy, traditional trading processes are difficult to process efficiently and have high transaction costs. In addition, the fairness and security of energy trading are also threatened, and the risks of single point failures and data tampering will affect the stability of the system and the trust of participants.
[0004] To solve these problems, blockchain technology, as a decentralized distributed ledger technology, has gradually entered the field of distributed energy trading. Its decentralization, immutability, transparency and smart contract functions can build an efficient, secure and reliable infrastructure for distributed energy trading. In order to overcome the limitations of traditional energy trading models and adapt to the decentralized and multi-agent collaborative characteristics of distributed energy networks, blockchain technology is introduced to improve transaction efficiency, transparency and trust.
[0005] The consensus algorithm is an important mechanism to ensure that multiple nodes reach consensus in a distributed system. The characteristics of distributed energy networks (multiple nodes, decentralization, dynamic changes) are highly consistent with the application scenarios of consensus algorithms. In order to achieve the decentralized goal of distributed energy transactions, blockchain uses its core technology, the consensus mechanism, to ensure the trust and consistency between multiple nodes in the network. The consensus mechanism is the key to the blockchain system. It defines how distributed nodes can reach consensus on transaction data without a centralized organization, thereby ensuring the security and integrity of the data. In distributed energy transactions, the introduction of the consensus mechanism is particularly important. Due to the large number of participants and their dispersed geographical locations, the traditional centralized verification model is difficult to adapt to decentralized trading scenarios. The consensus mechanism ensures that each energy transaction is verified and recorded by multiple nodes through distributed verification, thereby eliminating the reliance on a single trusted third party.
[0006] At present, there are various consensus mechanisms suitable for distributed energy transactions, such as Proof of Work (PoW), Proof of Stake (PoS), Delegated Proof of Stake (DPoS) and Practical Byzantine Fault Tolerance (PBFT). Different consensus mechanisms have different characteristics: PoW focuses on security but has high energy consumption, PoS and DPoS can significantly reduce energy consumption, and PBFT is more suitable for the efficient operation of small energy networks. The PBFT consensus algorithm is widely used in consortium chains for its advantages such as high efficiency, node participation in consensus, and strong fault tolerance, and is suitable for different distributed systems. Although the PBFT algorithm has the advantages of high efficiency, low energy consumption and resistance to Byzantine faults in distributed energy transactions, its application in actual distributed energy networks still faces many challenges. First, in order to achieve high performance and security, PBFT needs to rely on multiple rounds of message exchange, which leads to high communication and computing overhead. Especially in the consensus process, participating nodes need to send a large number of messages to each other to verify and confirm transactions, which makes the communication complexity of the system present O(N 2 ) growth characteristics. As the scale of network nodes expands, the significant increase in communication overhead will limit the throughput of the system and reduce transaction processing efficiency. In addition, when there are malicious nodes in the network, in order to ensure the security of transactions, the PBFT algorithm needs to perform additional communication verification, which will not only further increase the communication load, but also cause a significant increase in transaction delays, affecting the overall system performance. These problems are particularly prominent in distributed energy scenarios dominated by high-frequency small-amount transactions. Summary of the invention
[0007] In view of the problems existing in the prior art, the present invention provides an improved PBFT consensus method for energy blockchain.
[0008] The present invention is achieved by adopting the following technical solutions:
[0009] An improved PBFT consensus method for energy blockchain, characterized by the following steps:
[0010] S1: Optimize the PBFT algorithm based on the speed at which nodes participate in consensus and the credibility of the nodes;
[0011] S2: Divide nodes into four categories: consensus nodes participating in consensus, new nodes waiting for consensus, consensus nodes with slow consensus speed, and consensus nodes with improper behavior;
[0012] S3: Consensus nodes are selected based on the time it takes to respond to client requests and their credibility. To this end, consensus nodes will receive a comprehensive score after participating in the consensus to assess their priority in participating in the consensus.
[0013] S4: Improve the PBFT algorithm by dynamically adjusting the score mechanism, comprehensively evaluating node performance and credibility, optimizing the priority of nodes participating in consensus in real time, and ensuring that the most effective nodes are retained in the consensus set;
[0014] S5: In order to dynamically add or delete nodes during consensus, a node dynamic entry and exit mechanism is designed. The node dynamic entry and exit mechanism is a mechanism executed based on the node entering and exiting the protocol;
[0015] S6: New nodes joining the network are added to the new node set, and then the new nodes are added to the consensus nodes one by one to keep the fastest nodes and discard the slowest and malicious nodes;
[0016] S7: In order to verify that the user has been selected as the leader, a verifiable random function VRF is introduced to solve the problem that the selection of the master node is not random. The public key and private key of each node are set, and the comprehensive score data in step S3 is used as a security parameter to calculate the coefficient value to verify whether it is selected as the leader;
[0017] S8: Other nodes then use the VRF-Verify function to check whether the node in step S7 is selected as the leader.
[0018] Furthermore, the optimization of the PBFT algorithm in step S1 is to design a node evaluation mechanism based on performance and credibility, aiming to dynamically optimize the nodes participating in the consensus and improve the consensus efficiency.
[0019] Furthermore, in step S2, for the consensus node with improper behavior, when the consensus node leaves the network or the system reaches a consensus, a malicious node that sends an error message through the network is detected and discarded to prohibit it from participating in the consensus negotiation.
[0020] Furthermore, the comprehensive score S obtained after consensus of each node in step S3 is i :
[0021]
[0022] In the formula, A i Availability is used to evaluate the performance of a node. When a node in the network tries to access it, if it can be accessed normally, it means that the performance of the node is normal. If it cannot be connected to it, it means that there is a problem with the performance of the node and it will disappear.
[0023] C i The credibility is used to measure the correctness of the message transmitted by the node. The initial credibility value is set to 10, which is determined based on the assumed fairness of the node before there is no malicious behavior, that is, all nodes are initially credible. Each time an error message is detected, the credibility is reduced by 1. This design conforms to the principle of progressive punishment in distributed systems to prevent nodes from being misjudged due to a single anomaly. The threshold is set to 0. When the threshold is 0, the node has shown multiple abnormal behaviors and its credibility cannot be restored. A lower threshold may cause malicious nodes to interfere with the system for a long time. Once the credibility of a node reaches the threshold, the system determines that it has a problem and adds it to the set of malicious nodes, and it can no longer participate in consensus.
[0024] T i The response delay is the delay from when the node receives the pre-prepared message to when it sends a reply to the client. The client must accept the reply to get the response delay, so the indicator cannot be calculated before the client receives the message and sends a reply message. In addition, a malicious node can quickly send an incorrect reply to the client and get a reward, but when the node sends a message to the client and receives a reply, its credibility is reduced.
[0025] Furthermore, in step S4, after a round of consensus is completed, the consensus set will be updated in real time, and the network nodes with the highest score values will be retained in proportion. At least 4 nodes are required to reach a consensus.
[0026] Furthermore, in step S5, when a new node joins the consensus network, the node entry exit protocol is executed, and the newly joined node is in the set of nodes waiting to participate in the consensus, ready to participate in a new round of consensus; when a Byzantine node is deleted from the network due to malicious behavior, the node entry exit protocol will be executed, and the malicious node will be discarded and can no longer participate in the consensus. The node entry exit protocol consists of five stages:
[0027] Application phase: If a node wants to join or exit the network, it needs to first apply to the network and send an application message to the supervisory node;
[0028] Consent phase: After the supervisory node receives and approves the application, it broadcasts the consent message to all nodes in the network;
[0029] Confirmation phase: After receiving the consent message, the node verifies it. After the verification is correct, it broadcasts the confirmation message to the network nodes. When the supervisory node receives valid confirmation messages sent from other different nodes, it enters the network update phase;
[0030] Network update phase: The supervisory node recalculates the number of all nodes in the network and updates the view, and then packages the calculation results and the new view and broadcasts them to all network nodes;
[0031] Update completion phase: After receiving the network update message, all network nodes update local information, including the number of nodes and views, and then send an update completion message to the supervisory node.
[0032] Furthermore, in step S6, since the new node will not directly join the network, if a new node fails, it will not affect the consensus security, so the credibility of all newly added nodes will be gradually evaluated.
[0033] Furthermore, the coefficient value in step S7 is X; the calculation formula of the coefficient value X in the view numbered v is as follows:
[0034] X v =S i (v+block-number)%CN
[0035] In the formula, S i is the comprehensive score obtained in step S3, v is the view number, block-number is the number of blocks in the local ledger, and CN is the number of consensus nodes;
[0036] The VRF function returns two values: a hash value h and a proof ρ. Node i uses the hash value h as the input of the VRF-proof function to determine whether the node is a leader. The result of the VRF-proof function is:
[0037]
[0038] where ε(ε∈[0,1]) is the selection threshold, H 256 is the SHA-256 hash function, and len represents the length of the hash result.
[0039] Furthermore, in step S8, if node i in step S7 is selected as the leader, it packages the transaction into a new block and sends a pre-prepare message (including hash value h and proof ρ) to other nodes. After node j receives these messages, it uses the VRF-Verify function to check whether node i is selected as the leader:
[0040] Verify(X,h,ρ,pk i )&(H 256 (h) / 2 len )≤ε=1
[0041] In the formula, consensus node i generates a coefficient X and its public key pk when verifying the signature i ;
[0042] If the verification passes, node j will generate a prepare message and broadcast it to other nodes, otherwise, node j deletes this message.
[0043] The present invention proposes an improved PBFT consensus method for energy blockchain, which is an optimization algorithm EPBFT (Evaluation-based Practical Byzantine Fault Tolerance) based on the node evaluation mechanism. The nodes participating in the consensus are evaluated, and their performance and credibility are calculated to ensure that efficient consensus nodes are retained for the next round of consensus, which effectively reduces transaction delay and improves throughput; a node dynamic entry and exit mechanism is designed so that nodes can freely join and exit the consensus process; a random verifiable function VRF is added to effectively resist DoS attacks based on the node evaluation results; at the same time, when there are malicious nodes or behaviors in the consensus process, the EPBFT algorithm can quickly detect and discard them, ensuring system security and improving consensus efficiency.
[0044] Beneficial effects:
[0045] Compared with the prior art, the present invention has the following beneficial effects:
[0046] The present invention provides an improved PBFT consensus method for energy blockchain, and proposes an EPBFT algorithm, which is an improvement on the traditional PBFT consensus algorithm. The nodes of the system are divided into consensus nodes participating in the consensus, new nodes of the newly integrated network, slow nodes with slow speed and not participating in the consensus when needed, and finally malicious nodes, which are detected to be malicious and never participate in the consensus. In order to be able to classify the nodes, the speed, credibility and availability of the nodes are continuously evaluated, and scores are dynamically assigned to each node. At the same time, a node dynamic entry and exit mechanism is designed to solve the problem that the nodes of the PBFT algorithm cannot join or exit the consensus during operation. Finally, a random verifiable function VRF is introduced to elect the leader. The invented EPBFT algorithm greatly reduces the transaction delay in the consensus process and improves the throughput; when there are malicious nodes in the consensus process, the EPBFT algorithm has less transaction delay and communication volume than the traditional PBFT algorithm; and the EPBFT algorithm can mitigate DoS attacks, greatly improving the security of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 This is a diagram of a distributed energy transaction model in the present invention;
[0048] Figure 2 A flowchart of the node joining and exiting protocol in the present invention; DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with embodiments, which are intended to explain the present invention rather than to limit it.
[0050] Example:
[0051] like Figure 1 The figure shows a distributed energy trading model diagram, a small distributed energy network based on blockchain and smart contract technology. The system integrates the production end, trading platform, smart contract, energy storage facilities, charging piles, power sales companies, and consumer ends such as household users and industrial users of distributed energy such as photovoltaic and wind power to build a decentralized energy trading network.
[0052] In this model, photovoltaic and wind power, as the main sources of distributed energy, convert natural resources into electrical energy. If there is an oversupply of electricity, it can be stored in energy storage devices or uploaded to the market for trading through a trading platform. The trading platform uses smart contract technology to automatically match buyers and sellers, and complete energy price matching, payment settlement and power delivery according to preset rules, thereby reducing the participation of intermediaries and improving transaction efficiency.
[0053] Blockchain technology provides secure and reliable data support for this model. The information of each transaction is recorded in a distributed ledger, ensuring that the transaction process is transparent and the data cannot be tampered with, thereby enhancing the trust and reliability of the transaction.
[0054] Household users, industrial users and electric vehicle charging stations can purchase low-cost clean energy through the platform for daily life, production activities or transportation charging needs. At the same time, traditional power sales companies also serve as important participants, providing energy supply supplements and cooperating with distributed energy producers to form a fusion of traditional energy and clean energy. In this process, smart contracts ensure the automated execution of transaction agreements and reduce the complexity of manual operations, while blockchain records transaction information and provides security for all parties involved in the transaction.
[0055] (1) EPBFT algorithm based on node evaluation mechanism;
[0056] In energy blockchain applications, as the number of nodes increases, the amount of message exchange will increase significantly, resulting in decreased consensus efficiency and increased response delays. The EPBFT algorithm proposes a node evaluation mechanism based on performance and credibility, aiming to dynamically optimize node participation and improve consensus efficiency.
[0057] The nodes of the system are divided into consensus nodes participating in consensus, new nodes waiting for consensus, slow consensus nodes, and malicious nodes. Consensus nodes are selected based on the time it takes to respond to client requests and their credibility. For this purpose, the comprehensive score S of consensus node i is i It is used to evaluate the priority of participating in consensus. The calculation formula is:
[0058]
[0059] A i : Availability, used to evaluate the performance of a node. When a node in the network tries to access it, if it can be accessed normally, it means that the performance of the node is normal; if it cannot be connected to it, it means that there is a problem with the performance of the node and it will disappear;
[0060] C i : Credibility is used to measure the correctness of the message transmitted by the node. The initial value of the credibility is set to 10, which is determined based on the assumed fairness of the node before there is no malicious behavior, that is, the initial state of all nodes is credible; each time an error message is detected, the credibility is reduced by 1. This design conforms to the principle of progressive punishment in distributed systems to prevent nodes from being misjudged due to a single abnormality; the threshold is set to 0. When the threshold is 0, the node has shown multiple abnormal behaviors and its reputation cannot be restored, while a lower threshold may cause malicious nodes to interfere with the system for a long time; once the credibility of a node reaches the threshold, the system determines that it has a problem and adds it to the set of malicious nodes, and it can no longer participate in consensus;
[0061] T i : Response delay is the delay from when the node receives the pre-prepared message to when it sends a reply to the client. The client must accept the reply to get the response delay, so this indicator cannot be calculated before the client receives the message and sends a reply message. In addition, malicious nodes can quickly send wrong replies to the client and get rewards, but when the node sends a message to the client and receives a reply, its credibility is reduced.
[0062] The EPBFT algorithm comprehensively evaluates node performance and credibility through a dynamic adjustment of the scoring mechanism, optimizes the priority of nodes participating in the consensus in real time, and ensures that the most effective nodes are retained in the consensus set; through the above calculations, better results, shorter delays, reduced communication traffic and improved security can be obtained.
[0063] The score is adjusted dynamically, and the client recalculates the score each time it receives a reply, and updates it as it continues to receive replies from slower nodes. The client sends a notification when it receives a response and each time it gets a reply from a slower node, and the system updates the score. The network then updates the score and establishes a consensus set of nodes.
[0064] The scoring mechanism allows the number of nodes participating in the consensus to be reduced according to their score values. The consensus set is updated after each consensus is reached, retaining a certain proportion of the network nodes with the highest scores. At least 4 nodes are required to reach a consensus.
[0065] The scoring mechanism was tested on the entire node to see if it could detect and eliminate malicious nodes; one-third or one-quarter of the total nodes were also retained depending on the application needs and the level of trust between the nodes, because reducing the number of nodes can reduce the minimum number of faulty nodes to reach consensus; the other nodes were retained in the slow nodes that included their scores, so when nodes in the slow set are needed, the nodes with the highest scores will integrate the consensus set.
[0066] To track the behavior of a node over time, the score also takes into account the node's past behavior and is calculated as the average of the old score and the newly calculated value.
[0067] Assume that N is the total number of nodes in the system, and n is half of the total number of nodes, which constitute the consensus node set. In the pre-prepare phase, the master node sends a prepare message to all consensus nodes, a total of n-1 messages; in the prepare phase, each n-1 node sends a prepare message to all nodes, of which a total of n(n-1) messages have been sent; in the commit phase, all consensus nodes send a commit message to each node: n(n-1) messages are exchanged over the network, a total of (2n+1)(n-1) messages;
[0068] (2) Dynamic node entry and exit mechanism;
[0069] S25: Figure 2 The figure shows the node joining and exiting protocol flow chart. In order to dynamically join or delete nodes during consensus, a node dynamic entry and exit mechanism is designed. Nodes can freely join and exit the consensus network. During the whole process, there is no need to restart the blockchain network for a new round of consensus. The node dynamic entry and exit mechanism is designed to be executed based on the node entry and exit protocol. When a new node joins the consensus network, the node entry and exit protocol is executed, and the newly joined node is in the set of nodes waiting to participate in the consensus, ready to participate in the new round of consensus; when a Byzantine node is deleted from the network due to malicious behavior, the node entry and exit protocol will be executed, and the malicious node will be discarded and can no longer participate in the consensus.
[0070] If a node wants to join or leave the network, it needs to first apply to the network and send an application message to the supervisory node;
[0071] After the supervisory node receives and approves the application, it broadcasts the approval message to all nodes in the network;
[0072] After receiving the consent message, the node will verify it. After the verification is correct, it will broadcast the confirmation message to the network nodes. When the supervisory node receives valid confirmation messages sent from other different nodes, it will enter the network update phase;
[0073] The supervisory node recalculates the number of all nodes in the network and updates the view, then packages the calculation results and the new view and broadcasts them to all network nodes;
[0074] After receiving the network update message, all network nodes update their local information, including the number of nodes and views, and then send an update completion message to the supervisory node.
[0075] New nodes joining the network are added to the set of new nodes, adding them one by one to the consensus nodes to keep the fastest nodes and discard the slowest and malicious nodes; new nodes do not join the network directly, so if they fail, they will not affect the consensus security, and their honesty will be gradually evaluated.
[0076] The consensus node sends a prepare message to the master node instead of broadcasting it to other nodes. Similarly, the commit message is passed unidirectionally from the master node to the consensus node. The reason why the protocol can guarantee eventual consistency is that the master node will only broadcast the commit message after receiving the consistent prepare messages from all consensus nodes. Otherwise, the master node will not perform any operation and wait to start a new consensus.
[0077] (3) Random Verification Function VRF;
[0078] The selection of the master node (leader) of the consensus node is the beginning of each round of consensus process. It aims to designate a master node to propose a new block to the secondary node. The key challenge of the PBFT algorithm is that the selection of the master node is not random, that is, the selected leader does not know that he will be selected, so the selection result must be kept unpredictable.
[0079] A Verifiable Random Function (VRF) is a pseudo-random function with verification capability, used in cryptographic schemes to map inputs to verifiable pseudo-random outputs. A hash function can map inputs of arbitrary length to outputs of fixed length.
[0080] VRF effectively combines hash functions and digital signatures that meet uniqueness requirements, and is unpredictable and verifiable. VRF uses the private key of the node as input and then verifies the lottery result through the public key corresponding to the private key.
[0081] In addition to the random number, the output of VRF also contains a zero-knowledge proof for verifying the random value, that is, the output can be verified without knowing the private key, and even without being able to find the private key. Therefore, the VRF function is suitable for selecting leaders and defending against DoS attacks.
[0082] To prove that the user has been elected as a leader, each consensus node i is given a public key pk i and the matching private key sk i ; Consensus node i generates a coefficient X and its private key sk when verifying the signature i As the input of the VRF function, the coefficient X is publicly known to other nodes in each view but cannot be controlled. The view number v increases after each consensus.
[0083] In order to avoid selecting the same consensus node every time, a constantly updated security parameter is needed to help the node generate different random numbers in each election. Therefore, the comprehensive score S of a node is selected. i as a safety parameter.
[0084] The coefficient X in view number v is calculated as follows:
[0085] X v =S i (v+block-number)%CN
[0086] Among them, block-number is the number of blocks in the local ledger, and CN is the number of consensus nodes.
[0087] The VRF function returns two values: the hash value h and the proof ρ. Node i uses the hash value h as the input of the VRF-proof function to determine whether the node is a leader. The result of the VRF-proof function is:
[0088]
[0089] where ε(ε∈[0,1]) is the selection threshold, H 256 is the SHA-256 hash function, and len represents the length of the hash result.
[0090] If node i is selected as the leader, it packs the transaction into a new block and sends a pre-prepare message (including hash value h and proof ρ) to other nodes. After node j receives these messages, it uses the VRF-Verify function to check whether node i is selected as the leader:
[0091] Verify(X,h,ρ,pk i )&(H 256 (h) / 2 len)≤ε=1
[0092] In the formula, consensus node i generates a coefficient X and its public key pk when verifying the signature i ;
[0093] If the verification passes, node j will generate a prepare message and broadcast it to other nodes, otherwise, node j deletes this message.
[0094] (4) Safety analysis;
[0095] In order to verify the security of the EPBFT algorithm in the consensus process, theoretical formulas and analysis are used to prove that the algorithm can maintain the stability and security of the system in a complex environment from four aspects: fault tolerance, defense against malicious nodes, election randomness, and defense against DoS attacks. Based on this model, EPBFT enhances fault tolerance through a dynamic node evaluation mechanism. The improvement lies in node classification and dynamic adjustment, which further optimizes the selection efficiency of nodes participating in the consensus.
[0096] Analysis of fault tolerance;
[0097] The basic fault-tolerance model of the PBFT algorithm requires that the number of nodes participating in the consensus in the network N≥3f+1, where f represents the maximum number of faulty nodes (including malicious nodes) that the system can tolerate. Based on this model, EPBFT enhances fault tolerance through a dynamic node evaluation mechanism. Its improvement lies in node classification and dynamic adjustment, which further optimizes the efficiency of selecting nodes participating in the consensus. Malicious nodes are detected and isolated so that the number of nodes actually participating in the consensus N' satisfies:
[0098] N'≥3f'+1,f'<f
[0099] Among them, f' represents the number of remaining faulty nodes after malicious nodes are removed. Since dynamic evaluation can detect most malicious nodes and remove f remove ,have:
[0100] f'=ff remove ,f remove ≈f×P detect
[0101] Among them, P detect is the detection probability of malicious nodes, which can be close to 100%, so EPBFT can significantly improve fault tolerance in most cases.
[0102] Communication analysis to defend against malicious nodes;
[0103] The communication complexity of the three phases of the consensus process (pre-preparation, preparation, and submission) is O(N 2), when malicious nodes are not isolated, the communication overhead increases significantly with the increase of f, resulting in a decrease in system performance. The EPBFT algorithm reduces the number of nodes actually participating in the consensus N' through dynamic evaluation and node entry and exit mechanisms, and the communication complexity is reduced to:
[0104] O((N') 2 ),N'=Nf remove
[0105] In P detect In the case of higher remove →f, the communication complexity of the system is significantly reduced compared to PBFT, thereby reducing the interference caused by malicious nodes.
[0106] Proof of randomness for masternode election;
[0107] EPBFT introduces Verifiable Random Function (VRF) for random election of master nodes. Its core goal is to ensure the unpredictability of master nodes and the fairness of the election process. The election of master nodes meets the following two conditions:
[0108] Unpredictability: In VRF, the generation of the hash value h is based on the node’s public key pk i and private key sk i , the randomness comes from the following formula:
[0109] h=VRF(sk i ,input)
[0110] VRF_Verify(pk i ,h)
[0111] Due to the uniqueness and unpredictability of the private key, the generation process of the hash value h is secure and random, and malicious nodes cannot predict the result in advance;
[0112] Fairness: VRF election is based on the node credibility score S i , the probability P of each node being selected as the primary node i satisfy:
[0113]
[0114] Among them, S i It is the node score, which reflects the reliability of the node's historical behavior and the superiority of its current performance. This design ensures the priority of high-scoring nodes while avoiding the potential risks of long-term fixation of the master node.
[0115] To defend against DoS attacks;
[0116] The core goal of DoS attacks is to paralyze the system by sending a large number of invalid requests through malicious nodes. EPBFT uses dynamic node evaluation and malicious node removal mechanisms to update node scores after each round of consensus. Nodes below the credibility threshold are immediately isolated and cannot continue to participate in consensus. After malicious nodes are removed, the communication complexity of the consensus network is reduced, and normal nodes can reach consensus in a shorter time, reducing the probability of a successful attack.
[0117] Theoretical analysis shows that the attack success rate P attack satisfy:
[0118]
[0119] As f' decreases, P attack will gradually approach 0.
[0120] In summary, EPBFT has demonstrated excellent performance in fault tolerance, communication efficiency, randomness, and anti-attack capabilities. In particular, it outperforms the traditional PBFT algorithm in dealing with malicious nodes and improving system reliability, ensuring the safe operation of the system and providing a solid guarantee for its application in high-security scenarios such as energy blockchain.
Claims
1. An improved PBFT consensus method for energy blockchain, characterized in that: The following steps are involved: S1: Optimize the PBFT algorithm based on the speed at which nodes participate in consensus and the credibility of the nodes; S2: Divide nodes into four categories: consensus nodes participating in consensus, new nodes waiting for consensus, consensus nodes with slow consensus speed, and consensus nodes with improper behavior; S3: Consensus nodes are selected based on the time it takes to respond to client requests and their credibility. To this end, consensus nodes will receive a comprehensive score after participating in the consensus to assess their priority in participating in the consensus. S4: Improve the PBFT algorithm by dynamically adjusting the score mechanism, comprehensively evaluating node performance and credibility, optimizing the priority of nodes participating in consensus in real time, and ensuring that the most effective nodes are retained in the consensus set; S5: In order to dynamically add or delete nodes during consensus, a node dynamic entry and exit mechanism is designed. The node dynamic entry and exit mechanism is a mechanism executed based on the node entering and exiting the protocol; S6: New nodes joining the network are added to the new node set, and then the new nodes are added to the consensus nodes one by one to keep the fastest nodes and discard the slowest and malicious nodes; S7: In order to verify that the user has been selected as the leader, a verifiable random function VRF is introduced to solve the problem that the selection of the master node is not random. The public key and private key of each node are set, and the comprehensive score data in step S3 is used as a security parameter to calculate the coefficient value to verify whether it is selected as the leader; S8: Other nodes then use the VRF-Verify function to check whether the node in step S7 is selected as the leader.
2. An improved PBFT consensus method for energy blockchain as described in claim 1, characterized in that: The optimization of the PBFT algorithm in step S1 is to design a node evaluation mechanism based on performance and credibility, aiming to dynamically optimize the nodes participating in the consensus and improve the consensus efficiency.
3. An improved PBFT consensus method for energy blockchain as described in claim 1, characterized in that: In step S2, for the consensus node with improper behavior, when the consensus node leaves the network or the system reaches a consensus, a malicious node that sends an error message through the network is detected and discarded to prohibit it from participating in the consensus negotiation.
4. An improved PBFT consensus method for energy blockchain as described in claim 1, characterized in that: The comprehensive score S obtained after consensus of each node in step S3 i : In the formula, A i Availability is used to evaluate the performance of a node. When a node in the network tries to access it, if it can be accessed normally, it means that the performance of the node is normal. If it cannot be connected to it, it means that there is a problem with the performance of the node and it will disappear. C i The credibility is used to measure the correctness of the message transmitted by the node. The initial credibility value is set to 10, which is determined based on the assumed fairness of the node before there is no malicious behavior, that is, all nodes are initially credible. Each time an error message is detected, the credibility is reduced by 1. This design conforms to the principle of progressive punishment in distributed systems to prevent nodes from being misjudged due to a single anomaly. The threshold is set to 0. When the threshold is 0, the node has shown multiple abnormal behaviors and its credibility cannot be restored. A lower threshold may cause malicious nodes to interfere with the system for a long time. Once the credibility of a node reaches the threshold, the system determines that it has a problem and adds it to the set of malicious nodes, and it can no longer participate in consensus. T i The response delay is the delay from when the node receives the pre-prepared message to when it sends a reply to the client. The client must accept the reply to get the response delay, so the indicator cannot be calculated before the client receives the message and sends a reply message. In addition, a malicious node can quickly send an incorrect reply to the client and get a reward, but when the node sends a message to the client and receives a reply, its credibility is reduced.
5. An improved PBFT consensus method for energy blockchain as described in claim 1, characterized in that: In step S4, when a round of consensus is completed, the consensus set will be updated in real time, and the network nodes with the highest score values will be retained in proportion. At least 4 nodes are required to reach a consensus.
6. An improved PBFT consensus method for energy blockchain as described in claim 1, characterized in that: In step S5, when a new node joins the consensus network, the node entry exit protocol is executed, and the newly joined node is in the set of nodes waiting to participate in the consensus, ready to participate in a new round of consensus; when a Byzantine node is deleted from the network due to malicious behavior, the node entry exit protocol will be executed, and the malicious node will be discarded and can no longer participate in the consensus. The node entry exit protocol consists of five stages: Application phase: If a node wants to join or exit the network, it needs to first apply to the network and send an application message to the supervisory node; Consent phase: After the supervisory node receives and approves the application, it broadcasts the consent message to all nodes in the network; Confirmation phase: After receiving the consent message, the node verifies it. After the verification is correct, it broadcasts the confirmation message to the network nodes. When the supervisory node receives valid confirmation messages sent from other different nodes, it enters the network update phase; Network update phase: The supervisory node recalculates the number of all nodes in the network and updates the view, and then packages the calculation results and the new view and broadcasts them to all network nodes; Update completion phase: After receiving the network update message, all network nodes update local information, including the number of nodes and views, and then send an update completion message to the supervisory node.
7. An improved PBFT consensus method for energy blockchain as described in claim 1, characterized in that: In step S6, since the new node will not directly join the network, if a new node fails, it will not affect the consensus security, so the credibility of all newly added nodes will be gradually evaluated.
8. An improved PBFT consensus method for energy blockchain as described in claim 1, characterized in that: The coefficient value in step S7 is X, and the calculation formula of the coefficient value X in the view numbered v is as follows: X v =S i (v+block-number)%CN In the formula, S i is the comprehensive score obtained in step S3, v is the view number, block-number is the number of blocks in the local ledger, and CN is the number of consensus nodes; The VRF function returns two values: a hash value h and a proof ρ. Node i uses the hash value h as the input of the VRF-proof function to determine whether the node is a leader. The result of the VRF-proof function is: where ε(ε∈[0,1]) is the selection threshold, H 256 is the SHA-256 hash function, and len represents the length of the hash result.
9. An improved PBFT consensus method for energy blockchain as described in claim 1, characterized in that: In step S8, if node i in step S7 is selected as the leader, it packs the transaction into a new block and sends a pre-prepare message (including hash value h and proof ρ) to other nodes. After node j receives these messages, it uses the VRF-Verify function to check whether node i is selected as the leader: Verify(X,h,ρ,pk i )&(H 256 (h) / 2 len )≤ε=1 In the formula, consensus node i generates a coefficient X and its public key pk when verifying the signature i ; If the verification passes, node j will generate a prepare message and broadcast it to other nodes, otherwise, node j deletes the message.
Citation Information
Cited By
Block chain-driven data link credible evidence storage method and system
CN120528650A
Vehicle transportation data storage method and system based on block chain
CN120675694A