Raft consensus method based on weighted PageRank and BLS threshold signature
By adopting the Raft consensus method of weighted PageRank and BLS threshold signatures in the alliance chain, the problem of difficult balance between the alliance chain consensus algorithm and Byzantine fault tolerance is solved, an efficient and secure consensus process is achieved, and the consensus performance of the alliance chain is improved.
Patent Information
- Application Number
- CN202411294441.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-14
- Publication Date
- 2024-12-27
AI Technical Summary
The existing alliance chain consensus algorithms are difficult to find a balance between efficiency and Byzantine fault tolerance, which limits the development of alliance chains.
Byzantine fault tolerance and efficient consensus is achieved by constructing a weighted directed graph to calculate the pr value of the node to elect leaders and using the BLS threshold signature for log replication.
Tests on the Hyper-Ledger platform show that high throughput and low consensus latency are achieved, and Byzantine nodes can be effectively tolerated, and the stability of leaders' elections is improved.
Smart Images

Figure CN119210730A_ABST
Abstract
Description
Technical Field
[0001] The present invention provides a Raft consensus method based on weighted PageRank and BLS threshold signature, belonging to the technical field of blockchain. Background Art
[0002] Since Satoshi Nakamoto proposed the concept of Bitcoin in 2008, digital currency and its underlying technology, blockchain, have triggered a revolution in the fields of socioeconomics and computer science. Blockchain technology, with its open, transparent, secure, reliable and tamper-proof characteristics, provides a new way of data management and transaction verification for decentralized distributed ledgers, and is widely used in finance, logistics, medical care and other fields.
[0003] According to the different degrees of decentralization, blockchain can be divided into three types: public chain, private chain and alliance chain. Among them, alliance chain has become an ideal choice for data interaction in many fields because its read and write permissions are jointly owned by multiple organizations or institutions. However, the existing consensus algorithm of alliance chain has the problem of difficult balance between efficiency and security, which limits the development of alliance chain.
[0004] Currently common consortium chain consensus algorithms include: Byzantine fault-tolerant algorithms, such as the PBFT algorithm, which can ensure that consensus can be successful when there are a certain number of Byzantine nodes in the system. However, since these algorithms need to identify and respond to Byzantine nodes and behaviors, they usually introduce additional communication overhead, resulting in reduced algorithm consensus efficiency. In contrast, non-Byzantine fault-tolerant algorithms, such as the Raft algorithm, have higher consensus efficiency but cannot tolerate Byzantine nodes.
[0005] In summary, an important problem in the current alliance chain is the lack of a consensus algorithm that has both high consensus efficiency and Byzantine fault tolerance. With the continuous development of blockchain technology and the growing demand for applications, designing a consensus algorithm that is both safe and efficient has become an urgent need for the development of alliance chains. Summary of the invention
[0006] In order to solve the problem that it is difficult to balance the consensus efficiency and Byzantine fault tolerance of the current consensus algorithms commonly used in alliance chains, the present invention proposes a Raft consensus method based on weighted PageRank and BLS threshold signature.
[0007] In order to solve the above technical problems, the technical solution adopted by the present invention is: a Raft consensus method based on weighted PageRank and BLS threshold signature, comprising the following steps:
[0008] S1: System initialization: Start each node of the consensus cluster and initialize the attributes of each node. Two new node attributes are added based on the original node attributes of the Raft algorithm, namely the node initial pr value and the public-private key pair (pk i ,sk i ), after each node is successfully started, it communicates through the heartbeat mechanism;
[0009] S2: Conduct leader election: traverse the communication status of all nodes, construct a weighted directed graph based on the communication status between nodes, calculate the pr value of each node through the weighted PageRank algorithm, and set a shorter election timeout for nodes with high pr values to make it easier for them to become leaders;
[0010] S3: Perform log replication: Perform log replication based on BLS threshold signature.
[0011] The specific process of leader election in step S2 is as follows:
[0012] a) Use key-value pairs to represent the communication between nodes and persist them during the consensus process;
[0013] b) Traverse all key-value pairs, build a directed graph based on the communication between nodes, and represent it with a determined transfer matrix M;
[0014] c) Use the weighted PageRank algorithm to calculate the pr value of each node, shorten the election timeout of nodes with high pr values, and conduct leader election.
[0015] The communication status between nodes is represented by key-value pairs, where the key is the source node and the target node, and the value is the number of successful communications between the source node and the target node.
[0016] Determine the matrix elements in the transfer matrix M as follows:
[0017]
[0018] In the above formula: Represents node v j The number of outgoing links.
[0019] In the consensus process, there are network partitions, malicious Byzantine nodes, and multiple successful communications between nodes, which will cause the matrix M to be improperly expressed, and then cause the PageRank algorithm to fail to calculate the node pr value. Therefore, the matrix M needs to be corrected for these problems. The expression of the corrected matrix M'' is as follows:
[0020]
[0021] In the above formula: β is the damping coefficient, N is the total number of consensus cluster nodes, e is the unit column matrix, and a is the vector required to correct the matrix M;
[0022] The modified matrix elements are expressed as:
[0023]
[0024] The steps for calculating the pr value of each node using the weighted PageRank algorithm are as follows:
[0025] 1) Initialization phase: Initialize the pr value of each node to 1 / N;
[0026] 2) Iteration stage: by determining the transfer matrix M'' and the column vector R0 composed of the initial pr values of each node, the column vector R composed of the final stable pr values of each node is iteratively calculated, and the formula R = M'' × R0 is used for iterative calculation;
[0027] 3) Election phase: During leader election, nodes with high PR values are assigned shorter election timeouts to ensure that they are elected leaders faster.
[0028] The specific steps of log replication based on BLS threshold signature in step S3 are as follows:
[0029] 1) Initialization of encryption system;
[0030] 2) Key generation;
[0031] 3) Signature;
[0032] 4) Verification: The leader verifies the full signature.
[0033] The steps to initialize the encryption system are as follows:
[0034] Define two multiplicative groups G1 and G2, with generators g1 and g2 respectively, and the order of both is a prime number p. Introduce a bilinear mapping e: G1×G2→G T , where G T is the target group, define a secure hash function H: {0, 1} * →G1, public parameter set (G1, G2, G T , e, g1, e2, p, h), h is the ratio of all points m and the order p of the elliptic curve;
[0035] The steps to generate the key are as follows:
[0036] Step 1: Generate the master public and private key pair (MSK, MPK) of the BLS threshold signature and generate the system master private key: MSK = x∈Z p , x is a random integer selected by the system, Z p Integer domain; generate the system master public key:
[0037] Step 2: Generate each node v i Public-private key pair Randomly select a Z p The t-1 order polynomial P on the matrix satisfies P(0)=MSK=x, and calculates x i =p(i), generating node v i The private key: Generate node v i The public key of:
[0038] Step 3: Publicly publish the master public key MSK and the public keys of all nodes.
[0039] The specific steps of signing are as follows:
[0040] Step 1: Client cluster sends <m,σ client >, where m is the request log, σ client is the client's signature on m;
[0041] Step 2: After receiving the client message, the leader signs the request log m: leader =sk leader H(m), and broadcast <m,σ client , σ leader >To all followers;
[0042] Step 3: Follower nodes pass e(σ client , g2) = e(H(m), pk client ) and e(σ leader , g2) = e(H(m), pk leader ) verifies two signatures, where e() is a bilinear mapping: G1×G2→G T , after verification, m is signed σ follower =sk follower H(m) and reply to the leader;
[0043] Step 4: The leader node receives the signature σ from the follower follower After that, verify the correctness of the signature: e(σ follower , g2) = e(H(m), pk folloer ), if the signature is correct, it is recorded. After collecting the correct signatures of t different followers, the user calculates the complete signature;
[0044] After the signature is completed, the leader verifies the complete signature through e(σ, g2) = e(H(m), MPK). If the equation holds, it is a correct threshold signature. The leader node can return the consensus result to the client. Otherwise, the verification fails. The leader re-collects the signatures of t new followers and then verifies.
[0045] The beneficial effects of the present invention over the prior art are as follows: compared with the currently common alliance chain consensus algorithms Raft algorithm, PBFT algorithm and some current improved algorithms of the Raft algorithm, through testing on the Hyper-Ledger platform, the throughput and consensus latency of the present invention are at a relatively high level, and Byzantine fault tolerance can be achieved. At the same time, the leader election stage is also more stable. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The present invention will be further described below in conjunction with the accompanying drawings:
[0047] Figure 1 is a flow chart of the method of the present invention;
[0048] Figure 2 Schematic diagram of leader election based on weighted PageRank algorithm;
[0049] Figure 3 Schematic diagram of log replication based on BLS threshold signature. DETAILED DESCRIPTION
[0050] The following will first explain the Raft algorithm and the terms involved to help you understand the subsequent solutions.
[0051] The Raft consensus algorithm was proposed by Ongaro and Ousterhout in 2013. It includes three relatively independent modules: leader election, log replication, and security. It solves the problems of the Paxos algorithm that are difficult to understand and implement.
[0052] In the Raft algorithm, nodes have three states: leader, follower, and candidate.
[0053] In the leader election phase, after the follower waits for a timeout, it changes its state to a candidate and requests votes from other nodes. When it receives votes from more than half of the nodes, it becomes the leader and maintains periodic heartbeats with the followers.
[0054] During the log replication phase, the leader broadcasts the request log sent by the client to all followers. The followers reply to the leader after receiving it. When the leader receives replies from more than half of the nodes in the cluster, it can apply the log and reply to the client.
[0055] In terms of security, the Raft algorithm uses a series of strategies to ensure that there is only one leader in the cluster, that the elected leader contains all submitted log entries, and that old log entries will not be resubmitted by the leader.
[0056] Although the Raft algorithm is widely used in distributed systems, its design focuses on non-Byzantine fault tolerance scenarios and may face the problem of split voting in the event of network partitions.
[0057] Therefore, the present invention proposes a Raft consensus method based on weighted PageRank and BLS threshold signature, which is improved on the basis of the Raft algorithm. The reasons for the present invention to improve the Raft algorithm are:
[0058] a) The Raft algorithm is simple and efficient, and its modification is easier to understand and implement;
[0059] b) In the alliance chain, although the security of the Raft algorithm is lower than that of the PBFT algorithm, its communication overhead is much smaller than that of the PBFT algorithm;
[0060] c) Compared with the PBFT algorithm, the Raft algorithm supports dynamic member changes and has better activity and scalability.
[0061] The improved Raft algorithm (PB-Raft algorithm for short) of the present invention includes improvements in leader election based on weighted PageRank algorithm and improvements in log replication based on BLS threshold signature; the improvements in leader election include building a weighted directed graph between nodes, calculating the pr value of each node, and shortening the election timeout time of nodes with high pr values; the improvements in log replication include distributing BLS public and private keys, aggregating BLS signatures, and BLS signature threshold verification; by testing the algorithm on the Hyper-Ledger Fabric platform, compared with the commonly used consensus algorithms of the current alliance chain, the present invention not only improves the consensus efficiency, but also enhances the security of the algorithm, providing new ideas and practical solutions for the design of the alliance chain consensus algorithm.
[0062] Specifically, Figure 1-3 As shown, the Raft consensus method based on weighted PageRank and BLS threshold signature proposed in the present invention includes the following steps:
[0063] S1: First, the system is initialized, each node is started and the attributes of each node are initialized. Two new node attributes are added based on the original node attributes of the Raft algorithm, namely the node initial pr value 1 / N and the public-private key pair (pk i ,sk i ), after each node is successfully started, they communicate through the heartbeat mechanism.
[0064] S2: At this point, there is no leader in the cluster, and a leader election is performed. The communication status of all nodes is traversed, and a weighted directed graph is constructed based on the communication status between nodes. The pr value of each node is calculated using the weighted PageRank algorithm, and a shorter election timeout is set for nodes with high pr values, making it easier for them to become leaders.
[0065] S3: After that, there is already a leader in the cluster, and the cluster waits for the client to send the request log. When the client sends the request log m and the client signature σ client , log replication is performed. The leader uses the private key sk leader Sign the client log m to get σ leader , and <m,σ client , σ leader >Broadcast to all followers, and the followers receive it with the client's public key pk client and the leader's public key pk leader Verify the request log m. After successful verification, sign the request log m to obtain σ follower And send it to the leader. When the leader successfully receives the signatures of t different followers, it performs threshold signature verification. After the verification is passed, the leader applies the log and notifies the follower, replies to the client that the consensus is successful, and the cluster continues to maintain heartbeat communication and wait for new client requests.
[0066] Table 1 below shows the symbolic parameters used in the method of the present invention.
[0067]
[0068] Table 1.
[0069] Under normal circumstances, the elected leader is usually a node with high activity. The leader can always maintain communication with followers through heartbeats to maintain the leader status, while correctly processing the request logs sent by the client. When an abnormal situation occurs, that is, when Byzantine behavior occurs, the algorithm will complete consensus through BLS threshold signatures.
[0070] There are two specific improvements:
[0071] (1) Leader election improvements, such as Figure 2 As shown, the specific process is as follows:
[0072] Step 1: Use key-value pairs to represent the communication between nodes and persist them during the consensus process. The key is the source node and the target node ([source node, target node]), and the value is the number of successful communications between the source node and the target node. For example, when node v1 successfully votes for node v2 once, the key-value pair [v1, v2]: 1 is stored.
[0073] Step 2: Traverse all key-value pairs, build a directed graph based on the communication between nodes, and represent it with a certain transfer matrix M. The rows and columns of the matrix M correspond to each node, and the matrix elements Represents node v j The number of outgoing links.
[0074] Because there are network partitions, malicious Byzantine nodes, and multiple successful communications between nodes during the consensus process, these problems will cause the matrix M to be improperly expressed, which will lead to the failure of the PageRank algorithm to calculate the node pr value, so the matrix M needs to be corrected to address these problems.
[0075] Question 1: In the Raft algorithm, due to the half-vote principle and the existence of network partition problems, some nodes may fail to send messages during the leader election process, making a column in the matrix M all zero, causing the node pr value to return to zero after iteration. Modify M to obtain M' so that the columns of M that are all zeros are modified to columns of non-zero equal value.
[0076] where a=[……,a i ,...](i=1,2,...,n),
[0077] Question 2: In the Raft algorithm, a Byzantine node may continuously send messages to itself, causing the pr value to shift toward itself, making its own pr value much greater than the pr value of other nodes, gaining an advantage in the leader election phase and affecting the consensus result. By setting the damping coefficient β (usually 0.85), the probability of the node conducting single-node communication is reduced. 1-β is used to indicate that the forced node has a smaller probability of communicating with other nodes, which is used to alleviate the situation where the pr value shifts toward the Byzantine node.
[0078] Question 3: In the Raft algorithm, the number of communications between nodes is different from the number of links between web pages. The former can be 1 or more times, while the latter can only be 1 or 0. Therefore, the matrix M' should be affected by the number of communications. M' should be corrected. The corrected matrix elements are The influence of the number of successful communications between nodes is added. In summary, the expression of the modified matrix M'' is:
[0079]
[0080] Step 3: Use the weighted PageRank algorithm to calculate the pr value of each node, shorten the election timeout of nodes with high pr values, and conduct leader election. The specific process of weighted PageRank algorithm calculation is as follows:
[0081] 1) Initialization phase: Initialize the pr value of each node to 1 / N.
[0082] 2) Iteration stage: by determining the transfer matrix M'' and the column vector R0 composed of the initial pr values of each node, the column vector R composed of the final stable pr values of each node is iteratively calculated using the formula R = M'' × R0.
[0083] 3) Election phase: During the leader election, nodes with high PR values are assigned shorter election timeouts to ensure that they are elected leaders faster. New global variables are added to record the communication status of each node and persist them in local files. When a node goes down, the persistent log can be restored as the standard for the next election.
[0084] (2) Log replication improvements, such as Figure 3 As shown, the specific process is as follows:
[0085] Threshold signature means that if more than t signers in a group of signers sign a message, the group's signature on the message can be obtained, and it is considered that the group has verified the message. The PB-Raft algorithm uses BLS signature to implement threshold signature, converting the original Raft algorithm log replication process into the BLS threshold signature and verification process, that is, when the leader receives the correct signatures of t followers, the complete signature can be calculated and verified. Threshold signature can effectively resist malicious attacks from Byzantine nodes.
[0086] The log replication process based on BLS threshold signature includes four parts: encryption system initialization, key generation, signature and verification. Encryption system initialization and key generation are performed during system initialization, and each log replication is signed and verified. The specific process is as follows:
[0087] 1) Encryption system initialization:
[0088] Define two multiplicative groups G1 and G2, with generators g1 and g2 respectively, and both orders are prime numbers p. Introduce a bilinear mapping e: G1×G2→G T , where G T is the target group. Define a secure hash function H: {0, 1} * →G1, public parameter set (G1, G2, G T , e, g1, g2, p, h), h is the ratio of all points m and the order p of the elliptic curve.
[0089] 2) Key generation:
[0090] Step 1: Generate the master public and private key pair (MSK, MPK) for BLS threshold signature. Generate the system master private key: MSK = x∈Z p , x is a random integer selected by the system, Z pInteger domain; generate the system master public key:
[0091] Step 2: Generate each node v i Public-private key pair Randomly select a Z p The t-1 order polynomial P on satisfies P(0)=MSK=x. Calculate x i =p(i), generating node v i The private key: Generate node v i The public key of:
[0092] Step 3: Publicly publish the master public key MSK and the public keys of all nodes.
[0093] 3) Signature
[0094] Step 1: Client cluster sends <m,σ client >, m is the request log, σ client is the client's signature on m.
[0095] Step 2: After receiving the client message, the leader signs the request log m: leader =sk leader H(m), and broadcast <m,σ client , σ leader >To all my followers.
[0096] Step 3: Follower nodes pass e(σ client , g2) = e(H(m), pk client ) and e(σ leader , g2) = e(H(m), pk leader ) verifies two signatures, where e() is a bilinear mapping: G1×G2→G T , after verification, m is signed σ follower =sk follower H(m) and reply to the leader.
[0097] Step 4: The leader node receives the signature σ from the follower follower After that, verify the correctness of the signature: e(σ follower , g2) = e(H(m), pk folloer ), if the signature is correct, it is recorded. After collecting the correct signatures of t different followers, the user calculates the complete signature: in It can be seen from the Lagrange difference formula that the complete signatures generated by any t followers are the same.
[0098] 4) Verification
[0099] The leader verifies the complete signature through e(σ, g2) = e(H(m), MPK). If the equation holds, it is a correct threshold signature, and the leader node can return the consensus result to the client. Otherwise, the verification fails, and the leader re-collects the signatures of t new followers for verification.
[0100] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A Raft consensus method based on weighted PageRank and BLS threshold signature, characterized by: The following steps are involved: S1: System initialization: Start each node of the consensus cluster and initialize the attributes of each node. Two new node attributes are added based on the original node attributes of the Raft algorithm, namely the node initial pr value and the public-private key pair (pk i ,sk i ), after each node is successfully started, it communicates through the heartbeat mechanism; S2: Conduct leader election: traverse the communication status of all nodes, construct a weighted directed graph based on the communication status between nodes, calculate the pr value of each node through the weighted PageRank algorithm, and set a shorter election timeout for nodes with high pr values to make it easier for them to become leaders; S3: Perform log replication: Perform log replication based on BLS threshold signature.
2. According to claim 1, a Raft consensus method based on weighted PageRank and BLS threshold signature is characterized in that: The specific process of leader election in step S2 is as follows: a) Use key-value pairs to represent the communication between nodes and persist them during the consensus process; b) Traverse all key-value pairs, build a directed graph based on the communication between nodes, and represent it with a determined transfer matrix M; c) Use the weighted PageRank algorithm to calculate the pr value of each node, shorten the election timeout of nodes with high pr values, and conduct leader election.
3. According to claim 2, a Raft consensus method based on weighted PageRank and BLS threshold signature is characterized in that: The communication status between nodes is represented by key-value pairs, where the key is the source node and the target node, and the value is the number of successful communications between the source node and the target node.
4. According to claim 3, a Raft consensus method based on weighted PageRank and BLS threshold signature is characterized in that: Determine the matrix elements in the transfer matrix M as follows: In the above formula: Represents node v j The number of outgoing links.
5. According to claim 4, a Raft consensus method based on weighted PageRank and BLS threshold signature is characterized in that: In the consensus process, there are network partitions, malicious Byzantine nodes, and multiple successful communications between nodes, which will cause the matrix M to be improperly expressed, and then cause the PageRank algorithm to fail to calculate the node pr value. Therefore, the matrix M needs to be corrected for these problems. The expression of the corrected matrix M'' is as follows: In the above formula: β is the damping coefficient, N is the total number of consensus cluster nodes, e is the unit column matrix, and a is the vector required to correct the matrix M; The modified matrix elements are expressed as:
6. According to claim 5, a Raft consensus method based on weighted PageRank and BLS threshold signature is characterized in that: The steps for calculating the pr value of each node using the weighted PageRank algorithm are as follows: 1) Initialization phase: Initialize the pr value of each node to 1 / N; 2) Iteration stage: by determining the transfer matrix M'' and the column vector R0 composed of the initial pr values of each node, the column vector R composed of the final stable pr values of each node is iteratively calculated, and the formula R = M'' × R0 is used for iterative calculation; 3) Election phase: During leader election, nodes with high PR values are assigned shorter election timeouts to ensure that they are elected leaders faster.
7. The Raft consensus method based on weighted PageRank and BLS threshold signature according to claim 1, characterized in that: The specific steps of log replication based on BLS threshold signature in step S3 are as follows: 1) Initialization of encryption system; 2) Key generation; 3) Signature; 4) Verification: The leader verifies the full signature.
8. The Raft consensus method based on weighted PageRank and BLS threshold signature according to claim 7 is characterized in that: The steps to initialize the encryption system are as follows: Define two multiplicative groups G1 and G2, with generators g1 and g2 respectively, and the order of both is a prime number p. Introduce a bilinear mapping e: G1×G2→G T , where G T is the target group, define a secure hash function H: {0, 1} * →G1, public parameter set (G1, G2, G T , e, g1, g2, p, h), h is the ratio of all points m and the order p of the elliptic curve.
9. A Raft consensus method based on weighted PageRank and BLS threshold signature according to claim 8, characterized in that: The steps to generate the key are as follows: Step 1: Generate the master public and private key pair (MSK, MPK) of the BLS threshold signature and generate the system master private key: MSK = x∈Z p , x is a random integer selected by the system, Z p Integer domain; generate the system master public key: Step 2: Generate each node v i Public-private key pair Randomly select a Z p The t-1 order polynomial P on the matrix satisfies P(0)=MSK=x, and calculates x i =p(i), generating node v i The private key: Generate node v i The public key of: Step 3: Publicly publish the master public key MSK and the public keys of all nodes.
10. According to claim 9, a Raft consensus method based on weighted PageRank and BLS threshold signature is characterized in that: The specific steps of signing are as follows: Step 1: Client cluster sends <m,σ client >, where m is the request log, σ client is the client's signature on m; Step 2: After receiving the client message, the leader signs the request log m: leader =sk leader H(m), and broadcast <m,σ client , σ leader >To all followers; Step 3: Follower nodes pass e(σ client , g2) = e(H(m), pk client ) and e(σ leader , g2) = e(H(m), pk leader ) verifies two signatures, where e() is a bilinear mapping: G1×G2→G T , after verification, m is signed σ follower =sk follower H(m) and reply to the leader; Step 4: The leader node receives the signature σ from the follower follower After that, verify the correctness of the signature: e(σ follower , g2) = e(H(m), pk follower ), if the signature is correct, it is recorded. After collecting the correct signatures of t different followers, the user calculates the complete signature; After the signature is completed, the leader verifies the complete signature through e(σ, g2) = e(H(m), MPK). If the equation holds, it is a correct threshold signature. The leader node can return the consensus result to the client. Otherwise, the verification fails. The leader re-collects the signatures of t new followers and then verifies.
Citation Information
Cited By
Threshold signature key reconstruction method and system
CN120415738A
Weighted threshold signature method and device supporting silent setting and conditional privacy
CN122496184A
