Leader Election Method and Data Transaction Method in the Off-chain Multi-person Channel of Blockchain

Through the node scoring mechanism and Algorand election strategy, combined with the obfuscation protection mechanism, poor stability and information leakage caused by leader elections in the multi-person payment channel under the blockchain chain are solved, and the node's campaign enthusiasm and the security of the election process are improved.

CN116566993BActive Publication Date: 2025-07-22INST OF COMPUTING TECH CHINESE ACAD OF SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310523736.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2022-12-12
Filing Date
2023-05-10
Publication Date
2025-07-22
Estimated Expiration
2043-05-10

AI Technical Summary

Technical Problem

The leader's election mechanism in the multi-person payment channel under the blockchain chain leads to poor long-term stability and increased rollback transaction volume, and the early exposure of the election results brings the risk of information leakage, which cannot fully mobilize the enthusiasm of nodes.

Method used

A node scoring mechanism is introduced to measure the advantages and disadvantages of nodes fairly through preset scoring methods. Combined with Algorand election strategy and obfuscation protection mechanism, leaders are periodically elected, and new leaders are elected using unbiased random numbers to avoid information leakage.

Benefits of technology

It improves the long-term stability of multi-person payment channels, enhances the campaign enthusiasm of nodes, and prevents information leakage through obfuscation protection mechanisms, ensuring the security and privacy of the election process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116566993B_ABST
    Figure CN116566993B_ABST
Patent Text Reader

Abstract

The present invention proposes a leader election method (Eleder algorithm) in a multi - person off - chain channel of a blockchain. A node scoring mechanism calculates the importance score of ordinary nodes by comprehensively analyzing various indicators of ordinary nodes. The election strategy mechanism that uses Algorand to convert the importance score into importance shares ensures the enthusiasm of ordinary nodes while electing high - quality leaders. At the same time, a confusion protection mechanism is designed where the current leader acts as a confounder, avoiding the premature disclosure of the new leader and playing a role in privacy protection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain, specifically, to the field of blockchain throughput, and more specifically, to the technology of leader election in the off-chain expansion solution of blockchain throughput technology, that is, a method for leader election in an off-chain multi-person channel of blockchain and a data trading method. Background Art

[0002] Blockchain technology emerged in 2008. With the continuous expansion of application fields, its characteristics of decentralization, security, and immutability bring convenience to more and more people at the level of Internet value exchange. Blockchain can overcome the problems of trust dependence and trust monopoly in the centralized model by establishing a point-to-point trust relationship between network nodes. However, in the current application of blockchain technology, there is a problem of insufficient data processing capacity in the blockchain system (even if there are successful cases in the application of blockchain, they are only limited to the application of low-frequency transaction scenarios), which restricts its large-scale and industrial development. Therefore, it is necessary to improve the application ability of blockchain and enhance the transaction performance of blockchain (that is, to increase the throughput of blockchain). To increase the throughput of blockchain, the current expansion solutions are mainly divided into on-chain expansion and off-chain expansion (such as the off-chain expansion technology mentioned in reference [1]). On-chain expansion starts from two aspects: the structure and protocol of the blockchain. Specifically, in terms of structure, the system structure of the blockchain is continuously improved; in terms of protocol, mainly some relatively mature underlying protocols are transformed. The solution to increase the throughput of blockchain through on-chain expansion not only has a relatively high technical barrier, but also the increase in throughput is limited, and there is also a situation of hard fork in the blockchain after the throughput is increased. Off-chain expansion is to increase the throughput of the entire blockchain system by setting some high-frequency and real-time point-to-point operations outside the chain without changing the basic protocol (underlying protocol) of the blockchain and the original trust assumption. In this way, off-chain expansion provides a horizontal expansion direction for the blockchain (for example, the blockchain expansion technology mentioned in reference [2]).

[0003] In the off-chain scaling solution of the blockchain, the method of sampling payment channels is one of the off-chain scaling solutions. The payment channel completes the payment operation of asset transfer and conducts transactions in a way with faster transaction speed and lower transaction fees. Payment channels can be divided into two-party payment channels and multi-party payment channels according to the number of nodes in the payment channel. In a two-party payment channel, there is a certain transaction range and a fixed transaction direction. When non-directly connected nodes conduct transactions, both parties can complete the transaction by establishing a new channel or by forwarding through an intermediate node (a node on the chain). When interacting with the system on the blockchain after completing the transaction by establishing a new channel in a two-party payment channel, the overall overhead is very large; when using an intermediate node (a node on the chain) for forwarding in a two-party payment channel, due to limitations such as network topology, the fund capacity on the path, and the shortest path algorithm, it will have a great impact on the transaction efficiency and cost of the network, and there are also problems such as channel congestion and channel imbalance. In a multi-party payment channel, there are multiple nodes, and the nodes can directly trade with each other to achieve the free flow of funds. Among them, when a node joins a multi-party payment channel in a transaction, n unidirectional connections will be formed. Compared with the method of a two-party payment channel (when a node is in a transaction, only one unidirectional connection is established in a two-party channel), it is equivalent to increasing the network connectivity by n times. Therefore, in current research, the multi-party payment channel is the main solution to improve the transaction performance of the blockchain. However, the multi-party payment channel also introduces the problem of double-spending of funds. To solve the double-spending problem, in the multi-party payment channel, the method of using the leader node as the off-chain center of the blockchain is generally adopted, and certain consensus strategies and candidate node supervision strategies are used to solve the problem of double-spending of funds.

[0004] According to whether the center (leader node, sometimes also called the leader) in the off-chain multi-person payment channel of the blockchain is fixed or not, the off-chain multi-person payment channel of the blockchain can be divided into two types: one is the off-chain multi-person payment channel of the blockchain based on a fixed leader; the other is the off-chain multi-person payment channel of the blockchain based on a variable leader. In the solution of the off-chain multi-person payment channel of the blockchain based on a fixed leader, during the establishment, update, processing, and closing processes of the entire payment channel, the leader node remains unchanged and is responsible for handling all transactions within the channel. Representative solutions include the Nocust solution provided in reference [3] and the Gnocchi solution provided in reference [4]. In the Nocust solution, the leader is fixed. The leader submits the transaction vouchers within a certain period of time to the on-chain system at regular intervals, and global consensus is achieved through the consensus mechanism of the blockchain, which has characteristics such as openness and transparency. However, the Nocust solution requires the leader to interact frequently with the on-chain system, resulting in relatively low consensus efficiency. In the Gnocchi solution, there is no need for frequent interaction with the on-chain system. Instead, the leader broadcasts the verified transactions to all nodes within the multi-person payment channel at regular intervals. This solution of the Gnocchi solution actually does not achieve channel consensus and there is a security risk of double spending. The representative solution in the solution of the off-chain multi-person payment channel of the blockchain based on a variable leader is the Garou solution provided in reference [5], which is an improvement on the Gnocchi solution: within each consensus cycle, a leader is randomly selected, and a two-phase consensus is initiated in the channel. Only when each node within the channel receives the signatures of all nodes within the payment channel agreeing to the state update is it considered that consensus has been reached. The Garou solution does not interact frequently with the on-chain system, has relatively less overhead, and strong consensus can better maintain the consistency of the off-chain state and has better security performance.

[0005] However, the off-chain multi-person payment channel of the blockchain belongs to the consensus-based multi-person channel, which is an off-chain leader-based multi-person channel and is not completely decentralized. Moreover, due to the problems in the election mechanism of the leader election method in the off-chain multi-person channel of the blockchain, it will lead to poor long-term stability of the multi-person payment channel, an increase in the rollback transaction volume, and even a decrease in throughput (it has been shown through the research in reference [6]); it will also be unfavorable to the ecology of the entire channel and cannot fully mobilize the enthusiasm of the nodes; and the early disclosure of the election results in the election mechanism will bring the risk of information leakage.

[0006] The references are as follows:

[0007] [1] Wang Hui, Wang Licheng, Bai Xue, Liu Qinghua, Shen Xiaoying. Research on Key Technologies of Blockchain Privacy Protection and Scalability [J]. Journal of Xidian University, 2020, 47(05): 28-39. DOI: 10.19665 / j.issn1001-2400.2020.05.005.

[0008] [2] Li Yang, Men Jinbao, Yu Han, Wang Sining, Fan Jingang, Guo Yanlai. Research Review on Blockchain Scalability Technologies [J]. Electric Power Information and Communication Technology, 2020, 18(06): 1-9. DOI: 10.16543 / j.2095-641x.electric.power.ict.2020.06.001.

[0009] [3] Khalil R, Gervais A, Felley G. NOCUST-A Non-Custodial 2nd-Layer Financial Intermediary [J]. IACR Cryptol.ePrint Arch., 2018, 2018: 642.

[0010] [4] Ge Zhonghui, Zhang Yi, Long Yu, Liu Zhen, Liu Zhiqiang, Gu Dawu. A Multi-Person Off-Chain Payment Scheme Supporting High Concurrency [J]. Chinese Journal of Computers, 2021, 44(01): 132-146.

[0011] [5] Ye Y, Ren Z, Luo X, et al. Garou: An Efficient and Secure Off-Blockchain Multi-Party Payment Hub [J]. IEEE Transactions on Network and Service Management, 2021, 18(4): 4450-4461.

[0012] [6] Niu Binghui. Research on Rebalancing Strategies of Off-Chain Payments in Blockchain [D]. Tianjin University, 2019. DOI: 10.27356 / d.cnki.gtjdu.2019.000989.

[0013] [7] Zhang Ao, Bai Xiaoying. Research and Practice Review on Blockchain Privacy Protection [J]. Journal of Software, 2020, 31(05): 1406-1434. DOI: 10.13328 / j.cnki.jos.005967.

[0014] [8] Yuncong Zhang. Research on Efficient and Scalable Blockchain Privacy Protection Technology [D]. Shanghai Jiao Tong University, 2019. DOI: 10.27307 / d.cnki.gsjtu.2019.003618. Summary of the Invention

[0015] Therefore, the object of the present invention is to overcome the defects of the above-mentioned prior art and provide a leader election method and a data trading method in a multi-person off-chain channel of a blockchain.

[0016] The object of the present invention is achieved by the following technical solutions:

[0017] According to a first aspect of the present invention, there is provided a method for leader election in a multi-party off-chain channel of a blockchain. The multi-party channel includes multiple nodes. In each consensus period, one node is the leader node and the other nodes are ordinary nodes. The method is used to select the leader node for the next consensus period in each consensus period through the following steps: S1. The leader node of the current consensus period scores each ordinary node based on multiple election-related metrics corresponding to the ordinary nodes and the weights corresponding to the metrics according to a preset scoring method to obtain the importance score of the ordinary node, and broadcasts it to all ordinary nodes, and broadcasts the multiple election-related metrics corresponding to the ordinary nodes, the weights corresponding to the metrics, and the importance score; S2. The ordinary node calculates the to-be-verified score of the other ordinary node based on the multiple election-related metrics corresponding to the other ordinary nodes and the weights corresponding to the metrics according to the preset scoring method. When the to-be-verified scores of all other ordinary nodes are consistent with the importance score, the ordinary node generates an importance score hash value and an importance score proof of work based on its pre-set importance score random seed and its private key, and generates an importance share for the ordinary node to be elected as the leader node based on its importance score hash value, a preset election probability factor, and the importance scores of all ordinary nodes according to a preset importance share generation method, and broadcasts the pre-set importance score random seed of the ordinary node, the importance share corresponding to the ordinary node, the importance score hash value, and the importance score proof of work for verification of the importance share corresponding to the ordinary node; S3. When the importance share corresponding to the ordinary node passes the verification, the ordinary node generates an election random seed of a preset length, and generates candidate hash values equal in number to the importance share corresponding to the ordinary node based on its corresponding importance share, balance, and private key, and sends the candidate hash values and the election random seed of the preset length to the leader node of the current consensus period; S4. The leader node of the current consensus period performs a quantity consistency verification based on the importance share corresponding to each ordinary node and all candidate hash values; when the quantity consistency verification of all ordinary nodes passes, the leader node of the current consensus period generates a judgment hash value based on its private key and the election random seeds of all ordinary nodes according to a preset judgment hash value generation method, and selects the leader node for the next consensus period based on the judgment hash value and all candidate hash values of all ordinary nodes according to a preset election rule; S5. The leader node of the current consensus period transfers information to the leader node of the next consensus period determined in step S4.

[0018] In some embodiments of the present invention, the multiple metrics related to the election of the ordinary node include: the proportion of the locked fund balance of the ordinary node in the locked fund balance of all nodes in the multi - person channel, the proportion of the outgoing transaction quantity of the ordinary node in the outgoing transaction quantity of all nodes in the multi - person channel, the proportion of the incoming transaction quantity of the ordinary node in the incoming transaction quantity of all nodes in the multi - person channel, and the proportion of the number of valid transactions signed when the ordinary node served as the leader node before the current consensus cycle in the number of all valid transactions in the multi - person channel.

[0019] In some embodiments of the present invention, in the step S1, the preset scoring method is as follows: S11. Calculate the initial importance score of the ordinary node based on multiple metrics related to the election of the ordinary node and the weights corresponding to the metrics in the following manner:

[0020]

[0021] Wherein, represents the initial importance score of the ordinary node i in the r - th consensus cycle, α represents the first weight, represents the proportion of the locked fund balance of the ordinary node i in the locked fund balance of all nodes in the multi - person channel, balance i represents the fund balance of the ordinary node i in the (r - 1) - th consensus cycle, ∑balance i represents the sum of the fund balances of all nodes in the multi - person channel in the (r - 1) - th consensus cycle, β represents the second weight, represents the proportion of the outgoing transaction quantity of the ordinary node i in the outgoing transaction quantity of all nodes in the multi - person channel, outTransactionNum i represents the outgoing transaction quantity of the ordinary node i in a preset number of consensus cycles before the r - th consensus cycle, ∑outTransactionNum i represents the sum of the outgoing transaction quantities of all nodes in the multi - person channel in a preset number of consensus cycles before the r - th consensus cycle, γ represents the third weight, represents the proportion of the incoming transaction quantity of the ordinary node i in the incoming transaction quantity of all nodes in the multi - person channel, inTransactionNum i represents the incoming transaction quantity of the ordinary node i in a preset number of consensus cycles before the r - th consensus cycle, ∑inTransactionNum i represents the sum of the incoming transaction quantities of all nodes in the multi - person channel in a preset number of consensus cycles before the r - th consensus cycle, δ represents the fourth weight, represents the proportion of the number of valid transactions signed when the ordinary node i served as the leader node before the current consensus cycle in the number of all valid transactions in the multi - person channel, singedTransactionNum irepresents the number of valid transactions signed by the ordinary node i when serving as the leader node in the r - th consensus cycle, ∑signedTransactionNum i represents the sum of all valid transaction numbers before the r - th consensus cycle in the multi - person channel; S12. Normalize the initial importance scores of all ordinary nodes to obtain the importance scores of each ordinary node represented by the normalized values.

[0022] In some embodiments of the present invention, in the step S12, the following rules are used to normalize the initial importance scores of all ordinary nodes:

[0023]

[0024] where, w tmp_i represents the intermediate representation value corresponding to the ordinary node i in the importance score normalization, represents a coefficient greater than zero, w i represents the initial importance score of the ordinary node i, represents the mean of the initial importance scores of all nodes, w max represents the maximum value among the initial importance scores of all nodes, w min represents the minimum value among the initial importance scores of all nodes, w new_i represents the importance score of the ordinary node i, min(w tmp_i ) represents the minimum value among the intermediate representation values corresponding to all nodes.

[0025] In some embodiments of the present invention, in the step S2, the ordinary node uses the VRF function to generate an importance score hash value and an importance score proof - of - work based on its preset importance score random seed and its own private key.

[0026] In some embodiments of the present invention, the preset importance share generation method is as follows: perform a rounding operation on the importance score of the ordinary node to determine the importance score of the ordinary node selected as the leader node; accumulate the importance scores of all ordinary nodes selected as the leader nodes to obtain the total importance score, and determine the probability of being selected as the leader node corresponding to the unit importance score based on the ratio of the preset election probability factor and the total importance score; based on the probability of being selected as the leader node corresponding to the unit importance score, divide the probability interval into multiple probability sub - intervals in the following manner:

[0027]

[0028] where,

[0029]

[0030]

[0031] Among them, I j represents the j-th probability sub-interval, and j represents the upper limit number of times that the ordinary node i is selected as the leader node in the probability sub-interval and represents the sum of the probabilities that the ordinary node i is selected as the leader node from 1 time to j times, represents the probability that the ordinary node i is selected n times when the importance score is p represents the probability of being selected as the leader node corresponding to the unit importance score, τ represents the preset election probability factor, and W represents the total importance score; the hash value of the importance score of the ordinary node is calculated by using the VRF function based on the importance score random seed of the ordinary node and the private key of the ordinary node, and the importance score random number of the ordinary node is calculated based on the hash value of the importance score by the following rules: When, p represents the probability of being selected as the leader node corresponding to the unit importance score, τ represents the preset election probability factor, and W represents the total importance score; the hash value of the importance score of the ordinary node is calculated by using the VRF function based on the importance score random seed of the ordinary node and the private key of the ordinary node, and the importance score random number of the ordinary node is calculated based on the hash value of the importance score by the following rules:

[0032]

[0033] wherein, k1 is the importance score random number, hash1 represents the hash value of the importance score, and hashlen1 represents the length of the hash value of the importance score; and the upper limit number of times that the ordinary node corresponding to the probability sub-interval to which the importance score random number of the ordinary node belongs is selected as the leader is used as the importance share of the ordinary node.

[0034] In some embodiments of the present invention, in the step S2, each ordinary node verifies the importance shares corresponding to other ordinary nodes through the following steps: using the VRF function to generate the hash value of the score to be verified of the other ordinary node based on the preset importance score random seed, importance score proof of work, and public key of each other ordinary node; performing consistency verification on the hash value of the score to be verified and the hash value of the importance score of each other ordinary node, and when all verifications pass, generating the share to be verified of the other ordinary node based on the hash value of the importance score of each other ordinary node, the preset election probability factor, and the importance scores of all ordinary nodes according to the preset importance share generation method; performing consistency verification on the share to be verified and the importance share of each ordinary node, and when all ordinary nodes pass the verification, the verification of the importance share corresponding to the ordinary node passes.

[0035] In some embodiments of the present invention, in the step S3, the candidate hash values with the same number of importance shares corresponding to the ordinary nodes are generated through the following steps: S31. Based on the importance share and the fund balance corresponding to the ordinary node, the following rule is adopted to generate the importance share random seeds with the same number as the importance shares for this ordinary node:

[0036] {seed1, seed2......seed m}

[0037] seed m =balance i +m;

[0038] Wherein, seed m represents the m-th importance share random seed of the ordinary node i, balance i represents the fund balance of the ordinary node i, and m represents the importance share of the ordinary node i; S32. The VRF function is used to calculate the candidate hash values with the same number as the importance shares corresponding to this ordinary node based on all the importance share random seeds obtained in step S31 and the private key of the ordinary node.

[0039] In some embodiments of the present invention, in the step S4, the preset method for generating the judgment hash value is: performing an exclusive OR operation on the election random seeds of all ordinary nodes to obtain the total random seed; using the VRF function to calculate the judgment hash value based on the total random seed and the private key of the leader node in the current consensus period.

[0040] In some embodiments of the present invention, in the step S4, the preset election rule is: calculating the first unbiased random number based on the judgment hash value according to the following rule:

[0041]

[0042] Wherein, k2 represents the first unbiased random number, hash2 represents the judgment hash value, and hashlen2 represents the length of the judgment hash value; generating the second unbiased random number based on the first unbiased random number and the quantity sum of the candidate hash values generated by all ordinary nodes according to the following rule:

[0043] T=k2×N

[0044] N=∑N i

[0045] Wherein, T represents the second unbiased random number, k2 represents the first unbiased random number, N represents the quantity sum of the candidate hash values generated by all ordinary nodes, N idenote the number of candidate hash values of the ordinary node i; sort the candidate hash values of all ordinary nodes from small to large, and use the second unbiased random number as the election flag, and determine the ordinary node corresponding to the candidate hash value at the sorting position indicated by the election flag as the leader node in the next consensus period.

[0046] In some embodiments of the present invention, in the step S3, when generating candidate hash values corresponding to ordinary nodes, candidate proof-of-work corresponding to the candidate hash values is also generated; in the step S4, when the leader node of the current consensus period generates a judgment hash value, judgment proof-of-work corresponding to the judgment hash value is also generated; the method further includes: S6. Verify the leader node of the next consensus period generated.

[0047] In some embodiments of the present invention, the step S6 includes: S61. The leader node of the current consensus period broadcasts the election random seeds of all ordinary nodes, the candidate hash value of the leader node of the next consensus period at the sorting position indicated by the election flag, the judgment hash value of the leader node of the current consensus period, and the judgment proof-of-work corresponding to the judgment hash value; S62. Each ordinary node verifies the leader node selection process of the next consensus period based on the public key of the leader node of the current consensus period, the election random seeds of all ordinary nodes, and the candidate hash value of the leader node of the next consensus period at the sorting position indicated by the election flag; S63. When the leader node selection process verification of all ordinary nodes for the next consensus period passes, the leader node of the next consensus period or the leader node of the current consensus period broadcasts the candidate proof-of-work corresponding to the candidate hash value of the leader node of the next consensus period at the sorting position indicated by the election flag and the importance share random seed used to calculate the candidate proof-of-work; S64. The ordinary node uses the VRF function to calculate the first candidate hash value to be verified of the leader node of the next consensus period at the sorting position indicated by the election flag based on the public key of the leader node of the next consensus period, the candidate proof-of-work corresponding to the candidate hash value of the leader node of the next consensus period at the sorting position indicated by the election flag, and the importance share random seed used to calculate the candidate proof-of-work, and performs hash value consistency verification on the first candidate hash value to be verified and the candidate hash value of the leader node of the next consensus period at the sorting position indicated by the election flag; S65. When the hash value consistency verification of the candidate hash values to be verified generated by all ordinary nodes and the candidate hash value of the leader node of the next consensus period at the sorting position indicated by the election flag passes, the leader node election verification of the next consensus period passes.

[0048] In some embodiments of the present invention, step S62 includes: Each ordinary node generates a to-be-verified judgment hash value by using a preset judgment hash value generation method based on the proof-of-work corresponding to the judgment hash value, the public key of the leader node in the current consensus period, and the election random seeds of all ordinary nodes, and performs a hash value consistency verification on the to-be-verified judgment hash value and the judgment hash value; when the hash value consistency verification passes, the ordinary node generates a second to-be-verified candidate hash value at the sorting position of the leader node in the next consensus period based on the judgment hash value and the candidate hash values of all ordinary nodes according to a preset election rule, and performs a hash random number consistency verification on the second to-be-verified candidate hash value and the candidate hash at the sorting position of the leader node in the next consensus period; when the hash random number consistency verification passes, the process of selecting the leader node in the next consensus period of this ordinary node is verified to pass.

[0049] According to a first aspect of the present invention, a data transaction method, the method includes: generating a leader node in a multi-person channel off-chain of a blockchain in each consensus period by using the method of the first aspect of the present invention, the multi-person channel includes multiple nodes, and in each consensus period, one node is the leader node and the other nodes are ordinary nodes; when there is a leader node, payment channels are established between ordinary nodes in the multi-person channel through the leader node to complete transactions.

[0050] Compared with the prior art, the advantages of the present invention are as follows: In the leader election method (sometimes also called the Eleder algorithm) in the multi-person channel off-chain of the blockchain proposed by the present invention, a node scoring mechanism is introduced, and ordinary nodes are scored according to a preset scoring method, which can fairly measure the advantages and disadvantages of nodes; the Eleder algorithm is designed to introduce the Algorand election strategy in the periodic election process, and determines the election probability of each ordinary node according to the score of the ordinary node (which can be reflected by the importance share of the ordinary node), so that each ordinary node has a certain probability of being elected, ensuring the enthusiasm of each ordinary node; the Eleder algorithm also includes a set of confusion protection mechanism, which uses the old leader to generate an unbiased random number (which can be reflected by the judgment hash value, etc.) to elect a new leader (for the current consensus period, the new leader is also called the leader node in the next consensus period), and performs information transfer between leader nodes after the new leader is elected, avoiding the information leakage risk problem caused by the premature disclosure of the new leader. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] The embodiments of the present invention will be further described below with reference to the accompanying drawings, where:

[0052] Figure 1Schematic diagram of the interaction process of a leader election method in a multi - person off - chain channel of a blockchain according to an embodiment of the present invention;

[0053] Figure 2 Schematic diagram of the process of generating a candidate hash value in a leader election method in a multi - person off - chain channel of a blockchain according to an embodiment of the present invention;

[0054] Figure 3 Schematic diagram of the process of a leader generating an unbiased random number to elect a new leader in a leader election method in a multi - person off - chain channel of a blockchain according to an embodiment of the present invention;

[0055] Figure 4 Schematic diagram of the process of verifying that a leader acts as a mixer to generate an unbiased random number in a leader election method in a multi - person off - chain channel of a blockchain according to an embodiment of the present invention;

[0056] Figure 5 Schematic diagram of the leader election process in a multi - person off - chain channel of a blockchain according to an embodiment of the present invention under a mixing protection mechanism. Detailed implementation manners

[0057] In order to make the objectives, technical solutions and advantages of the present invention more clear and understandable, the present invention will be further described in detail below through specific embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0058] As mentioned in the background art, due to the problems of the election mechanism in the leader election method in the multi - person off - chain channel of the blockchain, it will lead to poor long - term stability of the multi - person payment channel, an increase in the rollback transaction volume, and even a decrease in throughput; it is also not conducive to the ecology of the entire channel and cannot fully mobilize the enthusiasm of ordinary nodes; and the early disclosure of the election results in the election mechanism will bring the risk of information leakage. To solve the problems brought by the election mechanism in the leader election method, the inventors of the present invention have studied the existing technology to find a solution.

[0059] In the embodiments of the present invention, the problems existing in the leader election algorithm are mainly explored by taking three schemes, namely, the Nocust scheme, the Gnocchi scheme and the Garou scheme mentioned in the background art as examples. The exploration process of the existing technology will be described in detail below.

[0060] First, the similarities and differences of these three schemes are summarized, and the similarities and differences of the three schemes are shown in Table 1.

[0061] Table 1 Similarities and differences of consensus - based multi - person channels

[0062]

[0063] Secondly, summarize the problems existing in the leader election algorithm in the above scheme in combination with Table 1. It can be seen from Table 1 that the problems existing in the leader election algorithm in the prior art can be summarized as the problem of node quality optimization, the problem of campaign enthusiasm, and the problem of early disclosure of election results. The following conducts a detailed analysis of these problems.

[0064] First, consider the problem of node quality optimization. The leader is the core of the entire multi-party payment channel and almost undertakes all transaction processing tasks of the entire channel. If the leader node crashes or maliciously destroys the ecology within the multi-party channel, the operation of the entire channel will be greatly affected, and even the entire channel will collapse and become unavailable. For example, both the Nocust scheme and the Gnocchi scheme use a fixed leader. However, selecting a fixed centralized node as the leader introduces an overly strong trust assumption for a certain node. If this node is attacked or suffers a single-point failure, it will cause the channel to be unavailable. The Garou scheme randomly elects leaders periodically. Completely randomly electing leaders can alleviate the problem of a fixed leader, but it does not consider the quality differences of nodes, which will lead to poor long-term stability of the channel, an increase in rollback transaction volumes, and even a decrease in throughput.

[0065] Second, consider the problem of campaign enthusiasm. None of the existing multi-party payment channel schemes consider the enthusiasm of ordinary nodes when electing leaders. The fixed leader scheme only considers the quality of the leader and thus selects the node with the best conditions. However, under the same conditions, ordinary nodes (this ordinary node is also called a candidate node) have no chance to serve as leaders. Concentrating all power on one node like this will cause the campaign enthusiasm of ordinary nodes to be lost, which will further lead to the loss of enthusiasm of the elected leader because it will always be the leader and there is no need to continue to improve the quality of serving the entire channel. This is not conducive to the ecology of the entire channel and cannot fully mobilize the enthusiasm of ordinary nodes. Although the Garou scheme that uses a random leader election algorithm alleviates the problem of a fixed leader, it also does not consider the enthusiasm of ordinary nodes to campaign for leadership. Whether each ordinary node in the channel is selected is completely random, and their probabilities of being selected are the same. This leads to ordinary nodes who want to become leaders not taking the initiative to improve their metrics. Therefore, a purely random election method cannot also improve the enthusiasm of ordinary nodes.

[0066] Third, the problem of early disclosure of election results. This problem occurs during the leader election process: after a new leader is elected, their identity is made public within the channel, and then the old leader needs to send relevant transaction information (such as ledger information) within the channel to the new leader. However, after the identity of the new leader is disclosed, the information channel between the old and new leaders is easily attacked by malicious nodes, thus stealing the privacy information of transactions (as shown by the research in reference [7] in the background art). The current multi-person payment channel solution addresses this problem through early information backup, that is, all nodes back up the channel ledger. In this way, after the identity of the new leader is disclosed, the new leader already has the ledger information and there is no need to insecurely transfer ledger data between the old and new leaders. However, the off-chain multi-person payment channel is different from the blockchain itself and is a relatively centralized off-chain solution. The transparency of transaction information in it is easily exploited by malicious nodes, that is, it only requires less computing power to complete a forgery attack, ultimately resulting in the ledger being tampered with. Therefore, backing up the information of transactions that are not suitable for backup at all nodes brings another big problem - information leakage (as shown by the research in reference [8] in the background art).

[0067] After exploring the problems existing in the above leader election algorithm, in order to better solve the problems of the leader election algorithm discovered during the exploration, the embodiments of the present invention provide a leader (sometimes the leader is also called the leader node) election method in a new off-chain multi-person channel of a blockchain (the multi-person channel includes multiple nodes, and in each consensus period, one node is the leader node and the other nodes are ordinary nodes) (abbreviated as the Eleder algorithm, and in subsequent embodiments, the Eleder algorithm is used to refer to the present invention for convenience of description). A set of node scoring mechanisms is introduced in the Eleder algorithm of the embodiments of the present invention to measure the quality of nodes according to some indicators of the nodes, so as to solve the problems of poor long-term stability of the channel, increased rollback transaction volume, and decreased throughput caused by the failure to consider the quality differences of nodes; the Eleder algorithm also introduces the Algorand election strategy in the periodic election process, determines the election probability of each node according to the score of the node, so that each node has a certain probability of being elected, and solves the problem of campaign enthusiasm; the Eleder algorithm also includes a set of confusion protection mechanisms, uses the unbiased random numbers generated by the leader node in the current consensus period to elect a new leader (in this process, the data can only be available and visible, but cannot be changed, and the generation of intermediate data is pre-specified, and the leader only needs to execute, and at the same time, all nodes can verify the whole process, achieving the effect of using in advance and verifying afterwards), and transfers information after electing a new leader to prevent the risk of information leakage caused by the premature disclosure of the election result.Specifically, the node scoring mechanism scores each ordinary node (ordinary nodes are relative to the leader) according to the performance of the ordinary nodes in the channel, that is, according to some metrics and in accordance with a preset scoring method to obtain the importance score of the ordinary node; in the election strategy, each ordinary node verifies the importance score based on the received normalized parameter and the score. After the importance score verification passes, using the Algorand election algorithm, based on the common seed seed (pre-set importance score random seed), private key, and score of the entire channel, it calculates its own importance share. The hash value and proof value generated during this process can be used for the entire channel nodes to verify the process of calculating the importance share. The ordinary node will generate a corresponding number (the number of importance shares) of verifiable candidate hash values according to the importance share and VRF; in the obfuscation protection mechanism, the previous leader (sometimes also called the old leader or the current leader node or the leader node of the current consensus period) collects the hash values generated by the candidate leaders, uses a verifiable random function (such as the VRF function) to generate an unbiased random number, and selects the next leader (sometimes also called the new leader or the leader node of the next consensus period) according to the unbiased random number. After selecting the next leader, the previous leader discloses the proof and the selected hash value during the process of generating the unbiased random number to confirm the next leader. After the next leader completes the information transfer, the remaining ordinary nodes can also learn the identity of the new leader and conduct verification. In the whole process, the importance share calculation process uses the importance share calculation method of Algorand, and the generated candidate hash values and unbiased random numbers are all verifiable. The entire process of the obfuscation protection mechanism is transparent and all nodes can verify it, achieving pre-use and post-verification. Any problems can be raised at any time during the verification process and enter the arbitration stage. The Eleder algorithm proposed in the embodiments of the present invention is a brand-new multi-person channel leader election method, which ensures the quality and fairness of the leader: by using the scoring mechanism and the Algorand election strategy, it can comprehensively consider the situation of the nodes and fairly elect high-quality leaders; it ensures the security of the entire leader election process and the privacy of information; by using the old leader as an obfuscator to generate an unbiased random number to elect the new leader, it can avoid the new leader being prematurely exposed and complete the information transfer, and at the same time the whole process can also be verified to ensure security. In addition, during the election process, using the VRF function as a verifiable random function can make the candidate set obtained by each cycle election have unpredictable randomness, and the election result can be independently verified by other ordinary nodes. Among them, the VRF function can convert a random seed seed into a hash value hash and a proof value proof. The hash value hash is a hash value of hashlen length, which is jointly generated by the random seed seed and the private key sk of the node.The proof value proof, the seed, and the public key pk of the node can be used to prove that the hash value hash is indeed generated by the VRF function.

[0068] To better illustrate the implementation process of the embodiments of the present invention, the embodiments of the present invention will be described below from the perspective of the interaction process between the current leader and ordinary nodes. As Figure 1 shown, a leader election method in a multi-party off-chain channel of a blockchain includes Figure 1 the process steps indicated by labels 1-10 in, where: 1. The current leader scores each ordinary node according to the scoring system to obtain the importance score of each ordinary node; 2. The current leader broadcasts the importance score of each ordinary node and the processing parameters for calculating the importance score of each ordinary node to each ordinary node; 3. Each ordinary node verifies the importance scores of other ordinary nodes. When the importance score verification passes, it calculates the importance share using Algorand based on the importance score, etc.; 4. Broadcast the importance share of the ordinary node, that is, each ordinary node broadcasts its own processed data such as calculating the importance share to other nodes, and verifies the importance share. For an ordinary node, when the importance share of the ordinary node passes the verification, it generates an election random seed of a preset length, and generates candidate hash values with the same number as the importance share corresponding to the ordinary node; 5. Each ordinary node sends the election random seed of the preset length it generates, and the candidate hash value to the current leader; 6. The current leader verifies the candidate hash of each ordinary node, and elects a new leader using the current leader as a mixer based on the candidate hash values and election random seeds of all ordinary nodes, etc.; 7. The current leader and the new leader complete the information transfer; 8. The data required to verify the new leader is transmitted to each ordinary node for verifying the new leader; 9. Each ordinary node receives the data required to verify the new leader and conducts the verification of the new leader; 10. The new leader passes the verification and reaches a consensus. It should be noted that each ordinary node can be configured to generate a random seed, and this configuration process is well-known to those skilled in the art and will not be elaborated here. The setting of the preset length of the election random seed when the importance share of the ordinary node passes the verification is to process according to the same rules when electing a new leader later.

[0069] According to an embodiment of the present invention, a leader election method in a multi - person off - chain channel of a blockchain is provided. The method is used to select a leader node in the next consensus period in each consensus period through the following steps: S1. The leader node of the current consensus period scores the ordinary node according to a plurality of election - related metrics corresponding to the ordinary node and the weights corresponding to the metrics according to a preset scoring method to obtain the importance score of the ordinary node and broadcasts it to other ordinary nodes, and broadcasts the plurality of election - related metrics corresponding to the ordinary node, the weights corresponding to the metrics, and the importance score; S2. The ordinary node calculates the to - be - verified score of the other ordinary node according to a plurality of election - related metrics corresponding to the other ordinary node and the weights corresponding to the metrics according to a preset scoring method. When the to - be - verified scores of all other ordinary nodes are consistent with the importance scores, based on its pre - set importance score random seed and its own private key, it generates an importance score hash value and an importance score proof - of - work, and generates an importance share for the ordinary node to be elected as the leader node according to a preset importance share generation method based on its importance score hash value, a preset election probability factor, and the importance scores of all ordinary nodes, and broadcasts the pre - set importance score random seed of the ordinary node, the importance share corresponding to the ordinary node, the importance score hash value, and the importance score proof - of - work to verify the importance share corresponding to the ordinary node; S3. When the importance share corresponding to the ordinary node passes the verification, it generates an election random seed of a preset length, and generates a candidate hash value equal to the number of importance shares corresponding to the ordinary node based on its corresponding importance share, fund balance, and private key, and sends the candidate hash value and the election random seed of the preset length to the leader node of the current consensus period; S4. The leader node of the current consensus period performs a quantity consistency verification based on the importance share corresponding to each ordinary node and all candidate hash values; when all ordinary node quantity consistency verifications pass, the leader node of the current consensus period generates a judgment hash value according to a preset judgment hash value generation method based on its own private key and the election random seeds of all ordinary nodes, and selects the leader node of the next consensus period according to a preset election rule based on the judgment hash value and all candidate hash values of all ordinary nodes; S5. The leader node of the current consensus period transfers information with the leader node of the next consensus period determined in step S4; and, in step S3, when generating a candidate hash value corresponding to an ordinary node, it also generates a candidate proof - of - work corresponding to the candidate hash value; in step S4, when the leader node of the current consensus period generates a judgment hash value, it also generates a judgment proof - of - work corresponding to the judgment hash value; The method further includes: S6. Verifying the leader node of the generated next consensus period.According to an embodiment of the present invention, an ordinary node uses the VRF function to generate an importance score hash value and an importance score proof of work based on its preset importance score random seed and its possessed private key. It should be noted that in the embodiment of the present invention, the verification by the ordinary node in step S2 that the to-be-verified scores of all other ordinary nodes are consistent with the importance scores (for the verification effect, it is also called the importance score verification of the ordinary node), and the importance share verification of the ordinary node in step S3 are placed before the leader node of the current consensus period elects the leader node of the next consensus period (at this time, the leader node of the next consensus period is not verified). Based on solving the problems of node quality optimization, election enthusiasm, and early disclosure of election results, the election efficiency of the new leader (sometimes also called the leader node of the next consensus period) can be improved. In addition, the entire process of the leader election method in the embodiment of the present invention can also be verified by all nodes. Placing the information transfer between the old leader (the old leader is sometimes also called the leader node of the current consensus period) and the new leader (the leader node of the next consensus period) before the new leader verification process can prevent the risk of information leakage caused by the early disclosure of the election result.

[0070] To better illustrate a leader election method in a blockchain off-chain multi-person channel provided by the present invention, the following will explain the technical solutions in the embodiments of the present invention by dividing into a node scoring mechanism, an election strategy mechanism, and a confusion protection mechanism, and in combination with the accompanying drawings.

[0071] I. Node Scoring Mechanism

[0072] To measure the quality of ordinary nodes (this node is also called an ordinary node relative to the leader) in a multi-person payment channel, the embodiment of the present invention proposes a set of scoring systems (also called a preset scoring method), comprehensively considering various indicators of ordinary nodes to score ordinary nodes to obtain the importance scores of ordinary nodes. This importance score is positively correlated with the probability of an ordinary node being elected: the higher the importance score, the higher the probability that an ordinary node is elected as the leader (for the current consensus period, this leader is also called the leader node of the next consensus period); the lower the importance score, the lower the probability that an ordinary node is elected as the leader. To comprehensively consider the situation of ordinary nodes (selecting indicators that promote the quality of ordinary nodes), the embodiment of the present invention considers four indicators (positively promoting the quality of ordinary nodes), namely, the balance ratio, the outgoing transaction number ratio, the incoming transaction number ratio, and the contribution ratio of ordinary nodes, as well as the weights corresponding to the four indicators, to score ordinary nodes.

[0073] According to an embodiment of the present invention, multiple metrics related to the election of ordinary nodes include: the proportion of the locked fund balance of an ordinary node in the total locked fund balance of all nodes in a multi-party channel (also simply referred to as the balance proportion of the ordinary node), the proportion of the outgoing transaction quantity of an ordinary node in the total outgoing transaction quantity in the multi-party channel (also simply referred to as the outgoing transaction proportion of the ordinary node), the proportion of the incoming transaction quantity of an ordinary node in the total incoming transaction quantity in the multi-party channel (also simply referred to as the incoming transaction proportion of the ordinary node), and the proportion of the number of valid transactions signed by an ordinary node when it served as the leader node before the current consensus period in the total number of valid transactions in the multi-party channel (also simply referred to as the contribution proportion of the ordinary node). It should be noted that for the balance used in the balance proportion of the ordinary node, the balance of the ordinary node is a positive metric, that is, the more balance the ordinary node has in the payment channel for people, the lower the likelihood of misbehavior is considered (because once the leader misbehaves, the funds in the channel will be deducted, and misbehavior itself is unprofitable in the channel, with losses greater than income, thus restricting misbehavior). For the outgoing transaction of the node used in the proportion of the outgoing transaction quantity of the ordinary node and the incoming transaction used in the proportion of the incoming transaction quantity of the node, if at least one of the outgoing transaction quantity and the incoming transaction quantity of the ordinary node is larger, it represents that the ordinary node is active in transaction behavior in the channel, indicating a high transaction demand. If this ordinary node is elected as the leader, it can reduce the processing overhead of some transactions. Among them, for a node to initiate a transaction to another node, the outgoing transaction quantity of the node is incremented by 1; each time a node accepts a transaction, the incoming transaction quantity is incremented by 1. For the number of signed valid transactions used in the contribution proportion of the ordinary node, it is also a positive metric. The value of the contribution proportion of the ordinary node represents the historical situation of the corresponding node in the multi-party payment channel. The number of correct transactions (also known as valid transactions) signed by the ordinary node, the larger the number, the more valid signatures the ordinary node has and the greater the contribution.

[0074] According to an embodiment of the present invention, the importance score of each ordinary node is scored according to the following preset scoring method: S11. Calculate the initial importance score of the ordinary node based on multiple metrics related to the election of the ordinary node and the weights corresponding to the metrics in the following manner:

[0075]

[0076] Among them, represents the initial importance score of ordinary node i in the r-th round of the consensus period, α represents the first weight, represents the proportion of the locked fund balance of ordinary node i in the total locked fund balance of all nodes in the multi-party channel, balance i represents the fund balance of ordinary node i in the (r - 1)-th round of the consensus period, ∑balance irepresents the sum of the fund balances of all nodes in the entire multi - person channel during the (r - 1)-th consensus cycle, and β represents the second weight. represents the proportion of the outgoing transaction quantity of the ordinary node i in all the outgoing transaction quantities within the multi - person channel, outTransactionNum i represents the outgoing transaction quantity of the ordinary node i within multiple preset consensus cycles before the r - th consensus cycle, ∑outTransactionNum i represents the sum of all the outgoing transaction quantities within multiple preset consensus cycles before the r - th consensus cycle in the multi - person channel, and γ represents the third weight. represents the proportion of the incoming transaction quantity of the ordinary node i in all the incoming transaction quantities within the multi - person channel, inTransactionNum i represents the quantity of incoming transactions of the ordinary node i within multiple preset consensus cycles before the r - th consensus cycle, ∑inTransactionNum i represents the sum of all the incoming transaction quantities within multiple preset consensus cycles before the r - th consensus cycle in the multi - person channel, and δ represents the fourth weight. represents the proportion of the number of valid transactions signed when the ordinary node i served as the leader node before the current consensus cycle in all the valid transactions within the multi - person channel, singedTransactionNum i represents the number of valid transactions signed by the ordinary node i when it served as the leader node before the r - th consensus cycle, ∑signedTransactionNum i represents the sum of all the valid transaction quantities in the multi - person channel before the r - th consensus cycle; S12. Normalize the initial importance scores of all ordinary nodes to obtain the importance scores of each ordinary node represented by the normalized values.

[0077] It should be noted that the initial importance scores of each ordinary node that can be calculated through formula (1) (in order to better illustrate the normalization process, the initial importance scores are used to represent the importance scores before normalization) can be used in the subsequent leader election process. To be more conducive to the fairness of the election and reduce the variance of the importance scores between different nodes (the quantity gap between the initial importance scores is very large), based on obtaining the initial importance scores, it is selected to normalize the initial importance scores and control the variance of the importance scores within a certain range, which is beneficial to the election. According to an embodiment of the present invention, the following rules are used to normalize the initial importance scores of all ordinary nodes:

[0078]

[0079] where, w tmp_iDenotes the intermediate representation value corresponding to the ordinary node i in the importance score normalization. Denotes a coefficient greater than zero, w i Denotes the initial importance score of the ordinary node i. Denotes the mean of the initial importance scores of all nodes, w max Denotes the maximum value among the initial importance scores of all nodes, w min Denotes the minimum value among the initial importance scores of all nodes, w new_i Denotes the importance score of the ordinary node i, min(w tmp_i ) Denotes the minimum value among the intermediate representation values corresponding to all nodes.

[0080] Among them, the variance value of the importance scores between ordinary nodes can be determined by the coefficient To decide, the coefficient Is a constant greater than 0. By changing the coefficient The value of can control the variance of the importance scores of all nodes within a certain range. Finally, the minimum value in the importance scores can be added to the importance score values of all nodes, so that the importance scores of all nodes will become positive values, which is beneficial to subsequent processing. It can be seen that through the above normalization process, the variance of the importance scores between ordinary nodes can be controlled within a certain range, and the original score ranking situation will not be changed. The ordinary nodes with high scores are still high after adjustment, and the ordinary nodes with low scores are still low after adjustment. After such normalization, controlling the variance of the importance scores of ordinary nodes within a certain range can make the scoring system more reasonable and reduce the influence of subjectivity.

[0081] According to an embodiment of the present invention, the weights α, β, γ, δ are preferably 5, 2, 2, 8 in sequence; the coefficient The value range of is [0.02, 40], and the value step is 0.02.

[0082] II. Election strategy mechanism

[0083] After defining the importance score, a cryptographic random election strategy based on the importance score is proposed in the Eleder algorithm for electing candidate leaders. This strategy is based on the election algorithm of Algorand [9]. Each ordinary node i has a corresponding importance score w i , and the probability of being selected as a candidate leader (i.e., a new leader) is positively correlated with . The following details the election strategy mechanism from calculating the importance share using Algorand and generating candidate hash values according to the importance share.

[0084] 1. Calculate the importance share using Algorand

[0085] After each ordinary node receives the importance score sent by the leader, it will further determine its own election probability through the Algorand election algorithm. Specifically, each ordinary node i has a corresponding importance score w i , and its probability of being selected as the leader is positively correlated with . According to an embodiment of the present invention, the importance share of the ordinary node is generated by a preset importance share generation method, and the preset importance share generation method is: performing a rounding operation on the importance score of the ordinary node to determine the importance score of the ordinary node selected as the leader node; accumulating the importance scores of all ordinary nodes selected as the leader nodes to obtain the total importance score, and determining the probability of being selected as the leader node corresponding to the unit importance score based on the ratio of the preset election probability factor to the total importance score; based on the probability of being selected as the leader node corresponding to the unit importance score, dividing the probability interval into multiple probability sub-intervals in the following manner:

[0086]

[0087] wherein,

[0088]

[0089]

[0090] wherein, I j represents the jth probability sub-interval, j represents the upper limit number of times that the ordinary node i is selected as the leader node in the probability sub-interval , represents the sum of the probabilities that the ordinary node i is selected as the leader node 1 time to j times, represents the probability that the ordinary node i is selected n times when the importance score is , p represents the probability of being selected as the leader node corresponding to the unit importance score, τ represents the preset election probability factor, and W represents the total importance score; calculating the importance score hash value of the ordinary node by using the VRF function based on the importance score random seed and the private key of the ordinary node, and calculating the importance score random number of the ordinary node based on the importance score hash value by using the following rules:

[0091]

[0092] Among them, k1 is a random number of importance scores, hash1 represents the hash value of the importance score, and hashlen1 represents the length of the hash value of the importance score; the upper limit of the number of times the ordinary node corresponding to the probability sub-interval to which the random number of importance scores belongs is selected as the leader is used as the importance share of the ordinary node.

[0093] It should be noted that the election probability of an ordinary node is positively correlated with its own importance score. For better understanding, through analogy with a similar probability problem, it is intuitively explained as follows: In this algorithm, the ordinary node i has an importance score w i , which can be regarded as the ordinary node i having w i coins, and all nodes have a total of W = ∑w i coins. Assuming that the probability of a single coin being selected is Then obviously, when the ordinary node i has w i coins, the probability of being selected n times is And

[0094]

[0095] . We divide the probability interval [0, 1) into probability sub-intervals, and the length of the th interval is which represents the probability that the ordinary node i is selected j times. Then the jth probability sub-interval I j can be expressed as:

[0096]

[0097] Then a random number within the probability interval [0, 1) falling into the jth interval is equivalent to the probability that the ordinary node i is selected j times when holding w i coins, and the return value j of the algorithm is the number of times of being selected. In this algorithm, as long as j > 0, it can be considered that the ordinary node is elected as the candidate leader, that is, it is selected at least once. Theoretically, the proportion of candidate nodes being elected can be reduced by increasing the threshold of j, but in fact, all adjustments to j can be achieved by adjusting p, and the adjustment of p is continuous while the adjustment of j is discontinuous.

[0098] To better reflect the calculation process of the importance share, the following is the pseudocode of the Algorand election strategy algorithm (Algorithm 1):

[0099]

[0100] It should be noted that after calculating its own importance share, an ordinary node can immediately verify the importance shares of other ordinary nodes, or it can be verified after a new leader is elected. Verifying the importance share is necessary because the importance share directly determines the number of candidate hashes generated by an ordinary node and affects the probability of being elected. Verifying the importance share of an ordinary node includes two parts. The first part is the verification of VRF. Using the public key of the ordinary node, the seed used by VRF, and the hash value and proof value generated by VRF, the result of VRF can be verified. The second part is the verification of the binomial distribution. By verifying VRF, it can be ensured that the hash value is fixed, and thus the random number generated by the hash value is also fixed. Then, according to the importance score of the ordinary node and the probability of the binomial distribution event occurring (the probability of being elected as the leader node corresponding to the unit importance score), it can be verified whether the importance share of the ordinary node is correct. According to an embodiment of the present invention, each ordinary node verifies the importance share corresponding to other ordinary nodes through the following steps: generating a hash value of the score to be verified of the other ordinary node by using the VRF function based on the preset importance score random seed, the importance score proof of work, and the public key of each other ordinary node; performing consistency verification on the hash value of the score to be verified and the hash value of the importance score of each other ordinary node. When all verifications (VRF verification) pass, generating the share to be verified of the other ordinary node based on the hash value of the importance score of each other ordinary node, the preset election probability factor, and the importance scores of all ordinary nodes according to the preset importance share generation method; performing consistency verification on the share to be verified and the importance share of each ordinary node. When all ordinary nodes pass the verification (binomial distribution verification), the verification of the importance share corresponding to the ordinary node passes.

[0101] To better reflect the importance share calculation process in the importance share verification process, the following is the pseudo-code of the Algorand election strategy verification algorithm (Algorithm 2):

[0102]

[0103]

[0104] 2. Generate candidate hash values according to the importance share

[0105] As Figure 2As shown, when considering the efficiency of the election of the new leader, it is preferable to verify the importance shares of ordinary nodes after the ordinary nodes calculate their own importance shares. When the importance share verification of an ordinary node passes, the ordinary node calls the local importance share calculation interface (using the VRF function) according to the importance score to obtain its own importance share. Each ordinary node broadcasts its own importance share and processing parameters for importance share verification. After the importance share verification of all ordinary nodes passes, each node calculates a series of candidate hashes according to the importance shares, etc. (that is, after the ordinary node obtains its own importance share, it will generate candidate hashes with the same number as the importance shares). These candidate hashes will be sent to the current leader to participate in the election of the next round of leader (new leader). According to an embodiment of the present invention, the following steps are used for candidate hash values with the same number of importance shares corresponding to ordinary nodes: S31. Based on the importance share and the balance of funds corresponding to the ordinary node, the following rule is used to generate the importance share random seeds of the ordinary node with the same number as the importance shares:

[0106] {seed1, seed2......seed m}

[0107] seed m = balance i + m;

[0108] Wherein, seed m represents the m-th importance share random seed of ordinary node i, balance i represents the balance of funds of ordinary node i, and m represents the importance share of ordinary node i; S32. Use the VRF function to calculate the candidate hash values with the same number as the importance shares corresponding to the ordinary node based on all the importance share random seeds obtained in step S31 and the private key of the ordinary node.

[0109] It should be noted that when generating the candidate hash value corresponding to the ordinary node, a candidate proof of work corresponding to the candidate hash value is also generated.

[0110] To better reflect the calculation process of the candidate hash value, the following is the pseudocode of the algorithm (algorithm 3) for generating the candidate hash value (the hash value participating in the candidate):

[0111]

[0112] It should be noted that in algorithm 3, steps 7 and 8 are for the operation of transmitting the generated candidate hash and candidate proof of work.

[0113] As can be seen from Algorithm 3, ordinary nodes mainly generate candidate hash values and related proof values (candidate proof-of-work) through the VRF algorithm. Since the importance shares of each ordinary node are different, in the process of generating candidate hash values, the method adopted is that each ordinary node generates its own seed value. The Eleder algorithm provides a method, that is, using the balance of the ordinary node, adding the current loop count each time as a seed value, and jointly using it with the private key of the ordinary node to generate the corresponding candidate hash value and proof value (candidate proof-of-work). When the candidate hash value participates in the election, because the random number is an unbiased random number and the ordinary node does not know the candidate hash value situation of other ordinary nodes, the selection of the candidate hash value is unpredictable. Ordinary nodes do not need to specifically generate candidate hash values with characteristics. The method of adding the balance and the current loop count is simple and easy to use on the one hand. It is very easy for ordinary nodes to calculate the seed, calculate the VRF, and it is very easy for other ordinary nodes to verify. On the other hand, it ensures fairness. Each ordinary node generates candidate hash values using the same rule, ensuring fairness among ordinary nodes.

[0114] After the ordinary node generates the candidate hash value, similarly, other ordinary nodes can also verify this process to ensure that the hash value generated by the ordinary node is not forged. In the process of verifying the candidate hash, the VRF verification process is mainly used. There are two verification parts for candidate hash value verification. The first part is the measurement of quantity. An ordinary node will have a set of candidate hash values and will verify whether the length of this set of candidate hash values (that is, the number of candidate hash values) is equal to the importance share of the ordinary node. Only if they are equal will subsequent verification be carried out; The second part is the measurement of specific information. Since the balance of the ordinary node is fixed during leader election, the seed value when the ordinary node executes the VRF algorithm is fixed, and the generated hash value and proof value (candidate proof-of-work) are fixed. According to the characteristics of VRF, when the hash value or proof value (candidate proof-of-work) is incorrect, it cannot pass the verification, thus ensuring the certainty of the hash value and proof value (candidate proof-of-work) and ensuring the certainty of the candidate hash.

[0115] Of course, the verification process of the second part of the candidate hash value verification is carried out after electing a new leader and after the current leader transfers information, which can prevent the leader from leaking in advance. The candidate hash value of each ordinary node is only known to that node and the leader before the election result is announced. In this way, all nodes in the channel know what the elected candidate hash is, but do not know the attribution. After the old and new leaders transfer information, the new leader will announce its own hash value and proof value (the hash value and proof value here are the hash value and proof value determined during the subsequent election process to determine the new leader). Only after passing the verification can the leader function be exercised.

[0116] Generally speaking, this section (election strategy mechanism) includes two parts. The first part is that each ordinary node determines its own importance share through its own importance score (that is, uses Algorand to calculate the importance share). Through the analysis of relevant calculation and verification algorithms, it can be known that this process can ensure quality while ensuring fairness, and with the guarantee of the verification algorithm, it can ensure security; the second part is to generate candidate hash values using the importance shares of ordinary nodes (that is, generate candidate hash values according to the importance shares). This paper gives the relevant algorithms for generating candidate hash values. Each ordinary node can obtain the candidate hash value by correctly executing this algorithm. At the same time, the security of this process is guaranteed through the verification algorithm to ensure that fraud can be detected.

[0117] III. Confusion protection mechanism

[0118] After the current leader collects the candidate hash values sent by all nodes, it will use an unbiased random number to select a new leader. This process uses the leader as a confuser to elect a new leader.

[0119] Since this part is mainly the responsibility of the current leader, to prevent fraud, the embodiments of the present invention design an algorithm to make the leader only available and visible to the data during this process, but not modifiable. Moreover, the generation of intermediate data is pre-specified (preset evaluation hash value generation method, preset election rules, etc.). The leader only needs to execute, and at the same time, all nodes in the whole process can also verify, achieving the effect of using in advance and verifying afterwards. In this way, other ordinary nodes will also recognize the whole process, reach a consensus, and then elect a new leader. According to an embodiment of the present invention, the leader node of the current consensus period performs a quantity consistency verification based on the importance share corresponding to each ordinary node and all candidate hash values; when the quantity consistency verification of all ordinary nodes passes, the leader node of the current consensus period generates an evaluation hash value and the corresponding evaluation proof of work based on its own private key, the election random seeds of all ordinary nodes according to the preset evaluation hash value generation method, and selects the leader node of the next consensus period based on the evaluation hash value and the candidate hash values of all ordinary nodes according to the preset election rules; the leader node of the current consensus period transfers information to the determined leader node of the next consensus period; and verifies the generated leader node of the next consensus period. It should be noted that the leader node of the current consensus period performs a quantity consistency verification based on the importance share corresponding to each ordinary node and all candidate hash values, that is, the verification of the first part of the candidate hash value verification, which can prevent ordinary nodes from increasing the number of candidate hash values in order to improve their probability of being elected. This also ensures the fairness of electing a new leader. In addition, performing the verification of the first part of the candidate hash value verification at this time can improve the efficiency of the election.

[0120] According to an embodiment of the present invention, the preset evaluation hash value generation method is: performing an exclusive OR operation on the election random seeds of all ordinary nodes to obtain a total random seed; using the VRF function to calculate the evaluation hash value based on the total random seed and the private key of the leader node of the current consensus period.

[0121] According to an embodiment of the present invention, the preset election rule is: calculating a first unbiased random number based on the evaluation hash value using the following rule:

[0122]

[0123] where k2 represents the first unbiased random number, hash2 represents the evaluation hash value, and hashlen2 represents the length of the evaluation hash value; generating a second unbiased random number based on the first unbiased random number and the quantity sum of the candidate hash values generated by all ordinary nodes using the following rule:

[0124] T = k2 × N

[0125] N = ∑N i

[0126] Among them, T represents the second unbiased random number, k2 represents the first unbiased random number, N represents the sum of the number of candidate hash values generated by all ordinary nodes, and N i represents the number of candidate hash values of ordinary node i; sort the candidate hash values of all ordinary nodes from smallest to largest, and use the second unbiased random number as the election flag, and determine the ordinary node corresponding to the candidate hash value at the sorting position indicated by the election flag as the leader node of the next consensus period.

[0127] According to an embodiment of the present invention, the leader node of the next consensus period generated is verified through the following steps: S61. The leader node of the current consensus period broadcasts the election random seeds of all ordinary nodes, the candidate hash value of the leader node of the next consensus period at the sorting position indicated by the election flag, the judgment hash value of the leader node of the current consensus period, and the judgment proof of work corresponding to the judgment hash value; S62. Each ordinary node verifies the selection process of the leader node of the next consensus period based on the public key of the leader node of the current consensus period, the election random seeds of all ordinary nodes, and the candidate hash value of the leader node of the next consensus period at the sorting position indicated by the election flag; S63. When the verification of the selection process of the leader node of the next consensus period by all ordinary nodes passes, the leader node of the next consensus period or the leader node of the current consensus period broadcasts the candidate proof of work corresponding to the candidate hash value of the leader node of the next consensus period at the sorting position indicated by the election flag and the importance share random seeds used to calculate the candidate proof of work; S64. The ordinary node uses the VRF function to calculate the first candidate hash value to be verified of the leader node of the next consensus period at the sorting position indicated by the election flag based on the public key of the leader node of the next consensus period, the judgment proof of work corresponding to the candidate hash value of the leader node of the next consensus period at the sorting position indicated by the election flag, and the importance share random seeds used to calculate the candidate proof of work, and verifies the hash value consistency between the first candidate hash value to be verified and the candidate hash value of the leader node of the next consensus period at the sorting position indicated by the election flag; S65. When the hash value consistency verification between the candidate hash values to be verified generated by all ordinary nodes and the candidate hash value of the leader node of the next consensus period at the sorting position indicated by the election flag passes, the verification of the leader node of the next consensus period passes. It should be noted that when the leader node of the current consensus period broadcasts the candidate proof of work corresponding to the candidate hash value of the leader node of the next consensus period at the sorting position indicated by the election flag and the importance share random seeds used to calculate the candidate proof of work, the leader node of the next consensus period first sends the candidate proof of work corresponding to the candidate hash value of the leader node of the next consensus period at the sorting position indicated by the election flag and the importance share random seeds used to calculate the candidate proof of work to the leader node of the current consensus period, and then the leader node of the current consensus period broadcasts them.

[0128] To better understand the obfuscation protection mechanism, the following mainly elaborates in detail two parts: the leader generates an unbiased random number to elect a leader, and verifies that the leader acts as an obfuscator to generate an unbiased random number (wherein, steps S61, as well as steps S63, S64, and S65 in the verification step for the leader node of the next consensus period are not elaborated in detail), and then the obfuscation protection mechanism is described as a whole in combination with the flowchart.

[0129] After executing step S61, according to an embodiment of the present invention, step S62 includes: each ordinary node generates a to-be-verified judgment hash value by using a preset judgment hash value generation method based on the judgment proof-of-work corresponding to the judgment hash value, the public key of the leader node of the current consensus period, and the election random seeds of all ordinary nodes, and performs a hash value consistency verification on the to-be-verified judgment hash value and the judgment hash value; when the hash value consistency verification passes, the ordinary node generates a second to-be-verified candidate hash value at the sorting position indicated by the election flag for the leader node of the next consensus period based on the judgment hash value and the candidate hash values of all ordinary nodes according to the preset election rules, and performs a hash random number consistency verification on the second to-be-verified candidate hash value and the candidate hash at the sorting position indicated by the election flag for the leader node of the next consensus period; when the hash random number consistency verification passes, the selection process of the leader node of the next consensus period for this ordinary node passes.

[0130] As Figure 3 shown, the VRF algorithm is mainly used here to generate an unbiased random number. The VRF algorithm here is run by the current leader, that is, the current leader acts as an obfuscator. VRF has two inputs and two outputs. One input is the total seed value (i.e., the total random seed, shown as "total seed value" in the appendix Figure 3 ), and the other input is the private key of the current leader (shown as "leader private key" in the appendix Figure 3 ), one output is the judgment hash value (shown as "hash2" in the appendix Figure 3 ), and the other output is the judgment proof-of-work ( Figure 3(shown as the "Proof value" in the Chinese text), in order to prevent the current leader from controlling the election, this total seed value is crucial. The value of this parameter must be ensured to be uncontrollable by the leader and unknown in advance. Otherwise, the leader may manipulate the election. In the embodiments of the present invention, this total seed value is generated by all ordinary nodes participating in the election. Specifically, when an ordinary node in the channel sends a candidate hash to the leader, it will also send its own seed value (this seed value is the election random seed of a preset length, such as a 32-bit binary number). This sent seed value is determined by the ordinary node itself and is not controlled by others. After receiving the seed values of all ordinary nodes, the leader will perform an exclusive OR operation. The total seed value is obtained by performing an exclusive OR operation on all seed values. In this way, the seed value input to the VRF is not controlled by the leader or individual ordinary nodes. It is a random number generated jointly by all ordinary nodes, which can ensure that the generation of the unbiased random number is not controlled and is secure. Another parameter is the private key of the leader, which is only known to the leader himself and can be verified by the public key of the leader in the future, which is known to all ordinary nodes. Therefore, in the part where the leader acts as a scrambler, all ordinary nodes jointly generate the seed value, which can ensure that this part is not controlled by the leader or other ordinary nodes and ensure security.

[0131] In addition, after obtaining the hash value and proof value using the VRF, as Figure 3 shown, a random number (i.e., the first unbiased random number) between [0, 1) can be obtained by calculating and is denoted as k2. According to the properties of the VRF, it can be proved that this random number is an unbiased random number, and the generated values are random and discrete between [0, 1), and each value has the same probability. At the same time, the current leader counts the total number N of candidate hash values collected (i.e., N represents the sum of the candidate hash values generated by all ordinary nodes), and an unbiased random number T (i.e., the second unbiased random number, and when T contains a decimal, it is rounded to an integer) within the range of [0, N) is obtained by k2 × N. The generation of this random number T is equiprobable and equidistant, corresponding to N candidate hash values. Then the current leader arranges the N candidate hash values in ascending order, and the ordinary node corresponding to the k × N-th hash value is the next leader (for example, N = 100, k2 = 0.5, then T = 100 × 0.5 = 50, and at this time, the ordinary node corresponding to the 50th candidate hash value in the sorting is the next leader). After that, the current leader and this ordinary node perform information transfer. During the information transfer process, other ordinary nodes in the channel do not know the hash value selected by the leader because the ordinary nodes do not know all the candidate hash value situations.

[0132] In order to better reflect the calculation process of the current leader generating an unbiased random number to elect a new leader, the following is the pseudo code of the algorithm (Algorithm 4) for the current leader to generate an unbiased random number to elect a new leader:

[0133]

[0134]

[0135]

[0136] The following is an explanation of the part where all nodes in the channel verify the election process after the new leader is elected, and the leader acts as a confuser. The following is an example of an ordinary node verifying the election process. Figure 4 As shown in Figure 1, the VRF algorithm is used here to generate unbiased random numbers for verification. The VRF algorithm here is run by each ordinary node. VRF-Verify has three inputs and one output. The first input is the total seed value (i.e. the total random seed, Figure 4 The second input is the public key of the current leader (see Figure 4 The third input is the proof of work corresponding to the judgment hash value generated during the election ( Figure 4 The output is the verification hash value, i.e. the hash value to be verified (see Figure 4 The total seed value is the seed value used by the current leader to broadcast its own calculation of the total seed value (the seed value is the election random seed of a preset length, such as a 32-bit binary number). After receiving the seed value, the ordinary node will perform an XOR operation to obtain the total seed value. The ordinary node verifies the hash value consistency through the to-be-verified judgment hash value hash2′ and the judgment hash value hash2. If they are consistent, the hash value consistency verification of the to-be-verified judgment hash value generated by the ordinary node and the judgment hash value is passed, that is, the judgment hash value verification is passed. After the judgment hash value verification is passed during the election process, Figure 4 As shown, each ordinary node arranges the N candidate hash values used by the current leader in the election process from small to large, and calculates Compare k2' with k2 for consistency. When k2' is consistent with k2, the hash random number consistency verification passes. When the hash random number consistency verification passes, calculate T' = k2' × N (when T' contains a decimal, round it to the nearest integer), and obtain hash2' at the k2' × N position in the sorting. Compare the hash2' at the k2' × N position with the hash2' at the k2 × N position. If they are consistent, the verification of the leader node selection process for the next consensus period of the ordinary node passes.

[0137] When the verification of the leader node selection process for the next consensus period of all ordinary nodes passes (i.e., the consensus verification passes), continue to execute the verifications in steps S63, S64, and S65. It should be noted that in steps S63, S64, and S65, mainly the candidate hash values at the sorting positions indicated by the election flag for the leader node of the next consensus period are verified to ensure that the candidate hash values are generated by the new leader. Here, no detailed description will be given. The following will explain the confusion protection mechanism in combination with the flowchart.

[0138] As Figure 5 shown, the current leader (sometimes also referred to as the leader node of the current consensus period) collects the candidate hash values and the seed values sent by each ordinary node. The leader node of the current consensus period performs a quantity consistency verification based on the importance share corresponding to each ordinary node and all candidate hash values (i.e., Figure 5 "the current leader verifies the candidate hash values of each ordinary node" in Figure 5 ); when the quantity consistency verification of all ordinary nodes passes (i.e., Figure 5("transfer of information between the current leader and the new leader"); verify the leader node of the next consensus period generated. Verifying the leader node of the next consensus period generated includes: transmitting the data required to verify the new leader to each ordinary node, verifying whether the VRF verification passes (i.e., verifying whether the leader node selection process of the next consensus period of all ordinary nodes passes), verifying whether the K*Nth candidate hash in the selection ranking matches the candidate proof of work (i.e., verifying whether the hash value consistency verification of the candidate hash values to be verified generated by all ordinary nodes and the candidate hash value at the ranking position indicated by the election flag of the leader node of the next consensus period passes), etc. If the VRF verification fails, it indicates that the new leader is not accepted and arbitration will be proposed; when the VRF verification passes, it will verify whether the K*Nth candidate hash in the selection ranking matches the candidate proof of work. If the verification that the K*Nth candidate hash in the selection ranking matches the candidate proof of work passes, the entire election process verification passes and the new leader is recognized; if the verification that the K*Nth candidate hash in the selection ranking matches the candidate proof of work fails, it indicates that the new leader is not accepted and arbitration will be proposed.

[0139] In summary, in the Eleder algorithm, there are a total of three mechanisms (node scoring mechanism, election strategy mechanism, confusion protection mechanism) and four processes (the process of calculating the importance score according to the indicators of ordinary nodes, the process of converting the importance score into importance shares using the Algorand election algorithm, the process of generating the corresponding number of candidate hash values using the importance shares and sending them to the leader to participate in the election, the process of the current leader using an unbiased random number to elect a new leader). Each process has corresponding implementation and verification algorithms. It can play corresponding roles according to the requirements of relevant algorithms, and the verification algorithms can ensure the security of each process, thereby ensuring the security and effectiveness of the entire election process.

[0140] In addition, an embodiment of the present invention further provides a data trading method, and the method includes: generating a leader node in the off-chain multi-person channel of the blockchain in each consensus period using the leader election method in the off-chain multi-person channel of the blockchain described above. The multi-person channel includes multiple nodes. In each consensus period, one node is the leader node and the other nodes are ordinary nodes; when there is a leader node, payment channels are established between ordinary nodes in the multi-person channel through the leader node to complete transactions.

[0141] It should be noted that although the above steps are described in a specific order, it does not mean that the steps must be executed in the above specific order. In fact, some of these steps can be executed concurrently or even the order can be changed as long as the required functions can be achieved.

[0142] The present invention may be a system, a method, and / or a computer program product. The computer program product may include a computer-readable storage medium having thereon computer-readable program instructions for causing a processor to implement various aspects of the present invention.

[0143] A computer-readable storage medium may be a tangible device that retains and stores instructions for use by an instruction execution device. A computer-readable storage medium may include, for example, but is not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium would include the following: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disc (DVD), a memory stick, a floppy disk, a mechanically encoded device such as a punch card or raised structures in grooves having instructions stored thereon, and any suitable combination of the foregoing.

[0144] The embodiments of the present invention have been described above. The above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art in the field of the present technology without departing from the scope and spirit of the described embodiments. The selection of the terms used herein is intended to best explain the principles of the embodiments, the practical application, or the improvement of the technology in the market, or to enable other ordinary skilled persons in the field of the present technology to understand the embodiments disclosed herein.

Claims

1. A method for leader election in a multi - person off - chain channel of a blockchain. The multi - person channel includes multiple nodes. In each consensus cycle, one node is the leader node and the other nodes are ordinary nodes. It is characterized in that, The method is used to select the leader node in the next consensus period in each consensus period through the following steps: S1. The leader node of the current consensus period scores the ordinary node according to a preset scoring method based on multiple election-related metrics corresponding to the ordinary node and the weights corresponding to the metrics to obtain the importance score of the ordinary node, and broadcasts it to other ordinary nodes. The leader node also broadcasts multiple election-related metrics corresponding to the ordinary node, the weights corresponding to the metrics, and the importance score. S2. The ordinary node calculates the to-be-verified score of the other ordinary node according to a preset scoring method based on multiple election-related metrics corresponding to the other ordinary node and the weights corresponding to the metrics. When the to-be-verified scores of all other ordinary nodes are consistent with the importance scores, the ordinary node generates an importance score hash value and an importance score proof of work based on its preset importance score random seed and its private key. In addition, based on its importance score hash value, a preset election probability factor, and the importance scores of all ordinary nodes, the ordinary node generates an importance share for the ordinary node to be selected as the leader node according to a preset importance share generation method, and broadcasts the preset importance score random seed of the ordinary node, the importance share corresponding to the ordinary node, the importance score hash value, and the importance score proof of work to verify the importance share corresponding to the ordinary node. S3. When the importance share corresponding to the ordinary node passes the verification, the ordinary node generates an election random seed with a preset length, and generates candidate hash values equal in number to the importance share corresponding to the ordinary node based on its corresponding importance share, fund balance, and private key, and sends the candidate hash values and the election random seed with a preset length to the leader node of the current consensus period. S4. The leader node of the current consensus period performs a quantity consistency verification based on the importance share corresponding to each ordinary node and all candidate hash values. When all ordinary nodes pass the quantity consistency verification, the leader node of the current consensus period generates a judgment hash value according to a preset judgment hash value generation method based on its private key and the election random seeds of all ordinary nodes, and selects the leader node of the next consensus period according to a preset election rule based on the judgment hash value and the candidate hash values of all ordinary nodes. S5. The leader node of the current consensus period transfers information to the leader node of the next consensus period determined in step S4.

2. The method according to claim 1, wherein The multiple metrics related to the election of the ordinary node include: the proportion of the locked fund balance of the ordinary node in the locked fund balances of all nodes in the multi-person channel, the proportion of the outgoing transaction quantity of the ordinary node in all outgoing transaction quantities in the multi-person channel, the proportion of the incoming transaction quantity of the ordinary node in all incoming transaction quantities in the multi-person channel, and the proportion of the number of valid transactions signed when the ordinary node served as the leader node before the current consensus period in all valid transactions in the multi-person channel.

3. The method according to claim 2, characterized in that, In step S1, the preset scoring method is: S11. Calculate the initial importance score of the ordinary node according to the following method based on multiple indicators related to the election of the ordinary node and the weights corresponding to the indicators: Among them, represents the initial importance score of the ordinary node i in the r - th round of the consensus cycle, and α represents the first weight, represents the proportion of the locked fund balance of the ordinary node i in the total locked fund balance of all nodes in the multi - person channel, and balance i represents the fund balance of the ordinary node i in the (r - 1) - th round of the consensus cycle, and ∑balance i represents the sum of the fund balances of all nodes in the multi - person channel in the (r - 1) - th round of the consensus cycle, and β represents the second weight, represents the proportion of the outgoing transaction quantity of the ordinary node i in the total outgoing transaction quantity in the multi - person channel, and outTransactionNum i represents the outgoing transaction quantity of the ordinary node i in multiple preset consensus cycles before the r - th round of the consensus cycle, and ∑outTransactionNum i represents the sum of the outgoing transaction quantities of all nodes in the multi - person channel in multiple preset consensus cycles before the r - th round of the consensus cycle, and γ represents the third weight, represents the proportion of the incoming transaction quantity of the ordinary node i in the total incoming transaction quantity in the multi - person channel, and inTransactionNum i represents the incoming transaction quantity of the ordinary node i in multiple preset consensus cycles before the r - th round of the consensus cycle, and ∑outTransactionNum i represents the sum of the incoming transaction quantities of all nodes in the multi - person channel in multiple preset consensus cycles before the r - th round of the consensus cycle, and δ represents the fourth weight, represents the proportion of the number of valid transactions signed by the ordinary node i when it served as the leader node before the current consensus cycle in the total number of valid transactions in the multi - person channel, and sigedTransactionNum i represents the number of valid transactions signed by the ordinary node i when it served as the leader node in the r - th round of the consensus cycle, and ∑outTransactionNum i represents the sum of all valid transaction quantities in the multi - person channel before the r - th round of the consensus cycle; S12. Normalize the initial importance scores of all ordinary nodes to obtain the importance scores of each ordinary node represented by the normalized values.

4. The method according to claim 3, characterized in that, In step S12, the following rules are used to normalize the initial importance scores of all ordinary nodes: where, w tmp_i represents the intermediate representation value corresponding to the ordinary node i in the importance score normalization, represents a coefficient greater than zero, w i represents the initial importance score of the ordinary node i, represents the mean of the initial importance scores of all nodes, w max represents the maximum value among the initial importance scores of all nodes, w min represents the minimum value among the initial importance scores of all nodes, w new_i represents the importance score of the ordinary node i, min(w tmp_i ) represents the minimum value among the intermediate representation values corresponding to all nodes.

5. The method according to claim 4, characterized in that, In step S2, the ordinary node uses the VRF function to generate an importance score hash value and an importance score proof of work based on its preset importance score random seed and its private key.

6. The method according to claim 5, wherein In step S2, the preset method for generating importance shares is as follows: Perform a rounding operation on the importance score of the ordinary node to determine the importance score of the ordinary node selected as the leader node; Accumulate the importance scores of all ordinary nodes selected as the leader node to obtain the total importance score, and determine the probability of being selected as the leader node corresponding to the unit importance score based on the ratio of the preset election probability factor and the total importance score; Based on the probability of being selected as the leader node corresponding to the unit importance score, divide the probability interval into multiple probability sub-intervals according to the following method: Among them, Among them, I j represents the j-th probability sub-interval, and j represents the upper limit of the number of times that the ordinary node i is selected as the leader node in the probability sub-interval The number of times selected as the leader node, represents the sum of the probabilities that the ordinary node i is selected as the leader node from 1 time to j times, represents that the ordinary node i is selected n times when the importance score is p represents the probability of being selected as the leader node corresponding to the unit importance score, τ represents the preset election probability factor, and W represents the total importance score; Calculate the importance score hash value of the ordinary node using the VRF function based on the importance score random seed of the ordinary node and the private key of the ordinary node, and calculate the importance score random number of the ordinary node using the following rules based on the importance score hash value: Where k1 is the importance score random number, hash1 represents the importance score hash value, and hashlen1 represents the length of the importance score hash value; Take the upper limit number of times that the ordinary node corresponding to the probability sub-interval to which the importance score random number of the ordinary node belongs is selected as the leader as the importance share of the ordinary node.

7. The method according to claim 6, wherein In step S2, each ordinary node verifies the importance shares corresponding to other ordinary nodes through the following steps: Use the VRF function to generate a hash value of the score to be verified for the other ordinary node based on the preset importance score random seed, importance score proof of work, and public key of each other ordinary node; Perform a consistency verification on the hash value of the score to be verified and the importance score hash value of each other ordinary node. When all verifications pass, generate the share to be verified for the other ordinary node based on the importance score hash value of each other ordinary node, the preset election probability factor, and the importance scores of all ordinary nodes according to the preset method for generating importance shares; Perform a consistency verification on the share to be verified and the importance share of each ordinary node. When all ordinary nodes pass the verification, the verification of the importance share corresponding to the ordinary node passes.

8. The method according to any one of claims 1-7, characterized in that In step S3, generate candidate hash values with the same number of importance shares corresponding to the ordinary node through the following steps: S31. Generate importance share random seeds with the same number as the importance shares of the ordinary node based on the importance share corresponding to the ordinary node and the balance of funds according to the following rules: {seed1, seed2......seed m} seed m = balance i + m; Among them, seed m represents the random seed of the m-th importance share of the ordinary node i, and balance i represents the fund balance of the ordinary node i, and m represents the importance share of the ordinary node i; S32. Use the VRF function to calculate candidate hash values with the same number of importance shares corresponding to the ordinary node based on all the importance share random seeds and the private key of the ordinary node obtained in step S31.

9. The method according to any one of claims 1-7, characterized in that, In step S4, the preset method for generating the judgment hash value is as follows: Perform an exclusive OR operation on the election random seeds of all ordinary nodes to obtain the total random seed; Use the VRF function to calculate the judgment hash value based on the total random seed and the private key of the leader node in the current consensus period.

10. The method according to any one of claims 1-7, characterized in that In step S4, the preset election rule is as follows: Calculate the first unbiased random number based on the judgment hash value using the following rule: where k2 represents the first unbiased random number, hash2 represents the judgment hash value, and hashlen2 represents the length of the judgment hash value; Generate the second unbiased random number based on the first unbiased random number and the number of candidate hash values generated by all ordinary nodes using the following rule: Tk2×N N = ∑N i Among them, T represents the second unbiased random number, k2 represents the first unbiased random number, N represents the sum of the number of candidate hash values generated by all ordinary nodes, and N i represents the number of candidate hash values of ordinary node i; Sort the candidate hash values of all ordinary nodes from smallest to largest, and use the second unbiased random number as the election flag. Determine the ordinary node corresponding to the candidate hash value at the sorting position indicated by the election flag as the leader node for the next consensus period.

11. The method according to claim 10, wherein In step S3, when generating candidate hash values corresponding to ordinary nodes, candidate proof-of-work corresponding to the candidate hash values is also generated; In step S4, when the leader node in the current consensus period generates the judgment hash value, judgment proof-of-work corresponding to the judgment hash value is also generated; The method further includes: S6. Verify the leader node for the next consensus period generated.

12. The method according to claim 11, wherein Step S6 includes: S61. The leader node in the current consensus period broadcasts all the election random seeds of ordinary nodes, the candidate hash value of the leader node for the next consensus period at the sorting position indicated by the election flag, and the judgment hash value and the judgment proof-of-work corresponding to the judgment hash value of the leader node in the current consensus period; S62. Each ordinary node verifies the selection process of the leader node for the next consensus period based on the public key of the leader node in the current consensus period, all the election random seeds of ordinary nodes, and the candidate hash value of the leader node for the next consensus period at the sorting position indicated by the election flag; S63. When the verification of the selection process of the leader node for the next consensus period by all ordinary nodes passes, the leader node for the next consensus period or the leader node in the current consensus period broadcasts the candidate proof-of-work corresponding to the candidate hash value of the leader node for the next consensus period at the sorting position indicated by the election flag and the importance share random seeds used to calculate the candidate proof-of-work; S64. An ordinary node uses the VRF function to calculate the first candidate hash value to be verified at the sorting position indicated by the election flag for the leader node in the next consensus period based on the public key of the leader node in the next consensus period, the judged proof of work corresponding to the candidate hash value at the sorting position indicated by the election flag for the leader node in the next consensus period, and the random seed of the importance share used to calculate the candidate proof of work, and verifies the hash value consistency between the first candidate hash value to be verified and the candidate hash value at the sorting position indicated by the election flag for the leader node in the next consensus period; S65. When the hash value consistency verification between the candidate hash values to be verified generated by all ordinary nodes and the candidate hash value at the sorting position indicated by the election flag for the leader node in the next consensus period all passes, the leader node election verification for the next consensus period passes.

13. The method according to claim 12, characterized in that Step S62 includes: Each ordinary node generates a candidate judged hash value to be verified by using a preset candidate judged hash value generation method based on the judged proof of work corresponding to the judged hash value, the public key of the leader node in the current consensus period, and the election random seeds of all ordinary nodes, and verifies the hash value consistency between the candidate judged hash value to be verified and the judged hash value; when the hash value consistency verification passes, the ordinary node generates a second candidate hash value to be verified at the sorting position indicated by the election flag for the leader node in the next consensus period based on the judged hash value and the candidate hash values of all ordinary nodes according to the preset election rules, and verifies the hash random number consistency between the second candidate hash value to be verified and the candidate hash at the sorting position indicated by the election flag for the leader node in the next consensus period; when the hash random number consistency verification passes, the process of selecting the leader node for the next consensus period of this ordinary node passes.

14. A data trading method, characterized in that, The method includes: In each consensus period, the method as described in any one of claims 1-13 is used to generate a leader node in the multi-party channel off-chain of the blockchain. The multi-party channel includes multiple nodes. In each consensus period, one node is the leader node and the other nodes are ordinary nodes; When there is a leader node, payment channels are established between ordinary nodes in the multi-party channel through the leader node to complete transactions.

15. A computer-readable storage medium, characterized in that, A computer program is stored thereon, and the computer program can be executed by a processor to implement the steps of the method as described in any one of claims 1 to 14.

16. An electronic device, characterized in that, It includes: One or more processors; A storage device for storing one or more programs, which when executed by the one or more processors, cause the electronic device to implement the steps of the method as described in any one of claims 1 to 14.

Citation Information

Patent Citations

  • Priority-based block chain consensus method and system in Internet of Vehicles

    CN114189522A

  • Block chain performance optimization method based on pre-verification and reputation management

    CN114428977A