A Method for Generating Random Numbers for Hyperledger Fabric in Consortium Blockchain
By in the alliance chain hyper ledger system, each node communicates with other nodes during the transaction process, collects multiple random numbers for processing and calculation, forms a new entropy source and puts it into an entropy pool for entropy accumulation, the problem of limited sources of entropy sources of the random number generator is solved, and the quality of random numbers generation and system security are improved.
Patent Information
- Application Number
- CN202211046278.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-30
- Publication Date
- 2025-06-03
- Estimated Expiration
- 2042-08-30
AI Technical Summary
In the prior art, the source of the entropy source of the random number generator is limited, especially when the blockchain node is controlled by the attacker, it is difficult to ensure the quality of the random number generation.
By in the alliance chain hyper ledger system, each node communicates with other nodes during the transaction process, collects multiple random numbers for processing and calculation, forms a new entropy source and puts it into an entropy pool for entropy accumulation, thereby enriching the source of entropy source and improving the generation quality of random numbers.
This method enriches the source of entropy, improves the generation quality of random numbers, and enhances the security of the system. Especially when blockchain nodes are attacked, it can ensure the generation quality of random numbers.
Smart Images

Figure CN115484024B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical fields of blockchain and cryptography, and particularly relates to a random number generation method for a consortium blockchain hyperledger. Background Art
[0002] A consortium blockchain is a blockchain jointly managed by multiple institutions. Each organization or institution manages one or more nodes, and its data is only allowed to be read, written, and sent by different institutions within the system. Each node in the consortium blockchain usually has a corresponding entity organization, and can only join and exit the network after authorization. The institutions in the consortium blockchain form an alliance of interested parties to jointly maintain the healthy operation of the blockchain. Among them, Hyperledger introduces blockchain technology into the application scenario of a distributed consortium ledger and is one of the most famous consortium blockchain basic platform projects.
[0003] In the Hyperledger system, random numbers are widely used in random consensus mechanisms, key generation, and cryptographic operations. How to generate high-quality random numbers is very important for the security of the entire system. In practical applications, the random numbers used by Hyperledger can be generated by the system random function or a random number generator. For a random number generator, the entropy source is the source of randomness of the random number generator. How to add an entropy source to the random number generator in the correct way is very important for the generation of random numbers. Usually, the entropy source of the random number generator generally depends on the operating system of the blockchain node, such as system time, specific system interrupt events, disk status, human-computer interaction input events, etc. The entropy source is limited, especially when the blockchain node is controlled by an attacker, it is difficult to ensure the quality of random number generation. Summary of the Invention
[0004] Aiming at the problems existing in the prior art, the purpose of the present invention is to provide a random number generation method for a consortium blockchain. In each transaction process, a node will communicate with other nodes. During the communication process, each node participating in the transaction generates a random number and sends the random number to other nodes communicating with this node. The node that obtains the random number further calculates and generates a new random number by using the random number, and puts the new random number into the entropy pool as its own random number entropy source for entropy accumulation. There are many sources of entropy, such as system time, specific system interrupt events, disk status, human-computer interaction input events, etc.
[0005] In order to achieve the above object, the technical solution of the present invention is realized as follows:
[0006] A random number generation method for a consortium blockchain hyperledger, comprising:
[0007] During a certain step of conducting transactions and ledger updates in Hyperledger, the first type of node communicates with multiple second type of nodes and obtains random numbers from the multiple second type of nodes. Then, it processes and calculates using the N (N≥2) collected random numbers, and takes the processed value as an entropy source and puts it into the entropy pool of the first type of node for entropy accumulation. When the first type of node needs to generate a random number, it estimates the entropy of the entropy source in the entropy pool. When the estimated entropy value is greater than the set threshold (i.e., the entropy pool has collected sufficient entropy source data), the first type of node processes the data in the entropy pool to generate the random number it needs. There can be various entropy estimation methods, such as the "offline statistical entropy estimation method", and the threshold can be selected as 256 bits, that is, when the estimated entropy value is greater than 256 bits, it is considered that the entropy is sufficient and a random number can be generated.
[0008] Furthermore, the said step process can be the Proposal endorsement step. The first type of node is the Hyperledger client (applicant), and the second type of node is the endorsing peer, where the endorsing peer is a node selected from the peers in Hyperledger to endorse transactions. The process includes: when a transaction is generated, the applicant constructs a transaction proposal (proposal) and sends it to multiple endorsing peers that need to endorse it according to the endorsement policy. Each endorsing peer node independently executes the chaincode to simulate the transaction and determines whether to support the transaction proposal. Each endorsing peer additionally generates a random number r ea , and returns it to the applicant after signing it together with the judgment result of the proposal. The applicant obtains the random numbers (r ea1 ,…,r eaN ) from the information returned by multiple endorsing peers.
[0009] Further, the step process may be the ordering and packing block steps. During the ordering and packing block steps, the consensus ordering service (such as Raft ordering, Kafka ordering) both adopt the "leader and follower" mode. The ordering nodes are divided into a leader node and multiple follower nodes. Among them, the leader node is responsible for reading and writing data, and the follower node only reads data for data synchronization. In this step, the first type of node is the leader node, and the second type of node is the follower node and the applicant. The process includes: after the Proposal endorsement step, the applicant generates a transaction and an additional random number r al , and sends this random number and the transaction to the leader node after signing them. During the ordering process, the order nodes need to communicate and interact for data synchronization. When multiple follower nodes obtain synchronized data from the leader node, they generate the random number r fl and send r fl to the leader node. The leader node obtains the random numbers (r a1 , r fl1 , …, r flN-1 ) from the information sent by the applicant and the follower nodes.
[0010] Further, the step process may be the block submission and ledger update steps. The Hyperledger network consists of a group of peer nodes. This step needs to complete the ledger update on each peer. In this step, the first type of node is a certain peer among them, and the second type of node is the other peers except the first type of node. The process includes: after the block is packed and generated, the leader node of the ordering synchronizes the block to the peer nodes. Among them, not all peer nodes need to directly connect to the leader node. For example, a peer can use the Gossip protocol to cascade to other peers. A peer is elected as the leader peer in an organization, responsible for connecting to the leader node of the ordering and distributing the block data to other peer nodes. Each peer that receives the block data continues to select other peers to spread the data, and finally realizes the ledger update of all peers. When spreading the data, each peer generates a random number r pp, and send the random number and block data to the peer nodes that receive the message. Each peer node receives the block data and random numbers (r pp1 ,…,r ppN ) sent by multiple other peer nodes.
[0011] Furthermore, in the communication process of Hyperledger, the communication between the first type of nodes and the second type of nodes is TLS secure communication, ensuring that the transmission of random numbers will not be intercepted by other entities.
[0012] Furthermore, when the first type of nodes perform processing calculations using the collected random numbers, at least two of the random numbers are selected for calculation.
[0013] Furthermore, the methods for the first type of nodes to process the received random numbers to generate an entropy source include, but are not limited to, exclusive OR operation, addition operation, multiplication operation, etc.
[0014] Furthermore, the entropy source generated by the first type of nodes needs to undergo entropy estimation and health testing, and can be used as the source for random number generation only after meeting the entropy value requirements and health testing requirements. Entropy estimation can adopt the method of offline statistical entropy estimation, including, but not limited to, the entropy estimator based on the Markov predictor, to perform minimum entropy estimation on the entropy source. The collected minimum entropy value should meet the security requirements, such as taking 256 bits as the minimum entropy value benchmark.
[0015] Furthermore, when the first type of nodes accumulate entropy, an iterative compression function can be used in the entropy pool to increase the entropy rate, and the implementation methods of the entropy pool include, but are not limited to, circular shift registers.
[0016] Furthermore, when the first type of nodes generate their own random numbers, the data in the entropy pool is compressed and used as the input for random number generation. The compression function can use a key expansion function, including, but not limited to, the key expansion function based on the SM3 cryptographic hash algorithm.
[0017] A key generation method, characterized in that the consortium chain Hyperledger system generates a key based on the random numbers generated by the above method.
[0018] The advantages of the present invention are as follows:
[0019] The entropy source of the random number generator generally depends on the operating system of the blockchain node to provide, and the entropy source is limited. The present invention proposes a new method for generating an entropy source, enriching the entropy source and improving the quality of random number generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is a flowchart of a random number generation method for a consortium chain Hyperledger. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0021] The present invention will be further described in detail below with reference to the accompanying drawings. The examples given are only used to explain the present invention and are not intended to limit the scope of the present invention.
[0022] A random number generation method for the Hyperledger of the consortium blockchain. The random number generator collects the randomness of the system entropy source as the source of its randomness. The data of the system entropy source enters the entropy pool for entropy accumulation, waiting to collect sufficient entropy source data. After the data in the entropy pool is compressed by the expansion function, it is concatenated with the data of the system or hardware random number generator (optional) to be used as the input of the deterministic random number generator to generate a seed. The deterministic random number generator is initialized, and the iteration of the internal state and the necessary reseeding operations are started to generate the required number of random numbers. To ensure the security of the random number generator, it is necessary to perform entropy estimation on the entropy of the entropy source and perform necessary health tests on the state of the entropy source. Among them, in this random number generation method, the node also needs to put the value obtained by calculating the random number generated and sent by other nodes communicating with it during each transaction process into its own entropy pool for entropy accumulation.
[0023] The method flow of the present invention is as Figure 1 shown, and its steps include:
[0024] 1) When a transaction is generated, the client applicant constructs a transaction proposal and sends it to multiple endorsing peers that need to endorse it according to the endorsement policy. Each endorsing peer node independently executes the chaincode simulation transaction and determines whether to support the transaction proposal. Each endorsing peer generates a random number r ea , and signs this random number and the judgment result of the proposal and returns them to the applicant. The client applicant obtains the random numbers (r ea1 , …, r eaN ) from the information returned by multiple endorsing peers. Among them, the communication between the applicant and each endorsing peer is based on a TLS secure channel.
[0025] 2) The client applicant uses the N random numbers collected to calculate and uses the calculated r a as the entropy source for entropy estimation and health testing. An offline statistical entropy estimation method is adopted, such as using an entropy estimator based on a Markov predictor, to estimate the entropy of r aFor minimum entropy estimation, the minimum entropy value collected should meet the security requirements. For example, with 256 bits as the minimum entropy value benchmark, only when the calculated minimum entropy value is greater than 256 bits and passes the health test can it be collected as a valid entropy source and put into the applicant's entropy pool for entropy accumulation.
[0026] 3) After the Proposal endorsement step, the steps of sorting and packaging the block are carried out. The applicant verifies the endorsing peer signature, compares the proposal results returned by each node, and determines whether the proposal results are consistent and whether they are executed according to the specified endorsement policy. Based on the proposal endorsement results, the applicant generates a transaction and a random number r al , and sends this random number and the transaction to the leader node after signing them. During the sorting process, communication and interaction are required among the order nodes for data synchronization. When multiple follower nodes obtain synchronized data from the leader node, a random number r fl is generated and fl sent to the leader node. The leader node obtains the random numbers (r a1 , r fl1 , …, r flN-1 ) from the information sent by the applicant and the follower nodes. The communication between the applicant and the leader node, as well as between the leader node and the follower nodes, is based on a TLS-secured channel.
[0027] 4) The sorting master node, the leader node, calculates and uses the calculated r l as an entropy source for entropy estimation and health testing. An offline statistical entropy estimation method is adopted, such as using an entropy estimator based on a Markov predictor, to perform minimum entropy estimation on r o . For minimum entropy estimation, the minimum entropy value collected should meet the security requirements. For example, with 256 bits as the minimum entropy value benchmark, only when the calculated minimum entropy value is greater than 256 bits and passes the health test can it be collected as a valid entropy source and put into the leader node's entropy pool for entropy accumulation.
[0028] 5) After the block packaging is generated, the sorting master node, the leader node, synchronizes the block to the peer nodes. Among the peer nodes in an organization, one is the leader peer, which is responsible for connecting to the sorting master node, the leader node, and distributing the block data to other peer nodes. Each peer node that receives the block data continues to select other peers to spread the data, and finally realizes the ledger update of all peers. When spreading the data, each peer generates a random number r pp , and sends the random number and the block data to the peer node that receives the message. Each peer may receive the block data and random numbers (r pp1 , …, r ppN ) sent by multiple other peer nodes. The communication between peer nodes is based on a secure channel of TLS.
[0029] 6) Each peer calculates and uses the calculated r p as an entropy source for entropy estimation and health testing. An offline statistical entropy estimation method is adopted. For example, an entropy estimator based on a Markov predictor is used to perform the minimum entropy estimation on r p . The collected minimum entropy value should meet the security requirements. For example, taking 256 bits as the minimum entropy value benchmark, only when the calculated minimum entropy value is greater than 256 bits and passes the health test can it be collected as a valid entropy source and put into the peer entropy pool for entropy accumulation.
[0030] 7) In addition to the entropy source calculated using the randomly generated numbers collected as described above, other entropy sources of the node can come from system entropy sources, including the Hyperledger system time, specific system interruption events, etc.
[0031] 8) The node maintains its own random number entropy pool, which is implemented by a cyclic shift register. An iterative compression function can be used to increase the entropy rate during entropy accumulation.
[0032] 9) When the node generates a random number itself, the data in the entropy pool is compressed using a key expansion function of the cryptographic hashing algorithm based on SM3 and used as the input of a deterministic random number generator to generate the required random number.
[0033] Although specific embodiments of the present invention are disclosed for illustrative purposes, the purpose is to help understand the content of the present invention and implement it accordingly. Those skilled in the art can understand that: without departing from the spirit and scope of the present invention and the appended claims, various substitutions, changes, and modifications are possible. Therefore, the present invention should not be limited to the content disclosed in the best embodiments, and the scope of protection required by the present invention is defined by the scope of the claims.
Claims
1. A random number generation method for the Hyperledger of the consortium blockchain, characterized in that, For any step of conducting transactions and ledger updates in Hyperledger, the nodes that need to generate random numbers in this step are defined as the first type of nodes, and the other nodes that communicate with the first type of nodes in this step are defined as the second type of nodes; among them, the first type of nodes first obtain random numbers from multiple different second type of nodes respectively; then the first type of nodes select N random numbers from the currently obtained random numbers for processing and calculation, and use the processed value as an entropy source and put it into the entropy pool of the first type of nodes; when the first type of nodes need to generate random numbers, perform entropy estimation on the entropy source in the entropy pool, and when the estimated entropy value is greater than the set threshold, the first type of nodes perform entropy extraction on the entropy source in the entropy pool to obtain the random numbers required by the first type of nodes; among them, the step is the Proposal endorsement step; the first type of nodes are Hyperledger clients, and the second type of nodes are the nodes selected from the peer nodes of Hyperledger to endorse transactions; the method of selecting N random numbers is: when a transaction is generated, the Hyperledger client constructs a transaction proposal and sends it to multiple endorsing nodes that need to endorse it according to the endorsement policy, and each endorsing node independently executes the chain code simulation transaction and judges whether to support the transaction proposal; then each endorsing node generates a random number, and returns the random number and the judgment result of the transaction proposal to the Hyperledger client after signing them together; then the Hyperledger client obtains N random numbers (r ea1 , …, r eaN ), r eaN is the random number generated by the Nth endorsing node; N ≥ 2.
2. The method according to claim 1, characterized in that, The steps are the ordering and packaging block steps. The consensus ordering service adopts the "leader and follower” mode. The ordering nodes include the ordering primary node (leadernode) and multiple ordering follower nodes (follower node). Among them, the leadernode is responsible for reading and writing data, and the followernode is used to read data for data synchronization. The first type of node is the leadernode, and the second type of node is the follower node and the Hyperledger client. The method for selecting N random numbers is as follows: After the Proposal endorsement step ends, the Hyperledger client generates a transaction and a corresponding random number r al , and signs this random number r al and the transaction and then sends them to the leadernode. Then, data synchronization is carried out through communication interaction between the order nodes. When multiple follower nodes obtain synchronized data from the leadernode, they generate a random number r fl and send r fl to the leadernode. Then, the leadernode obtains N random numbers (r a1 , r fl1 , …, r flN-1 ) from the information sent by the Hyperledger client and the follower nodes. r flN-1 is the random number generated by the (N - 1)th follower node.
3. The method according to claim 1, characterized in that, The steps are block submission and ledger update steps; the first type of node is any peer node in the Hyperledger network that performs ledger updates, and the second type of node is other peer nodes in the Hyperledger network other than the first type of node; the method for selecting N random numbers is as follows: after the block data is packaged and generated, the sorting leader node synchronizes the block data to the peer nodes directly communicatively connected to it; each peer node that receives the block data generates a random number rpp, and spreads the random number rpp and the block data to other peer nodes communicatively connected to it; each peer node obtains N random numbers (r pp1 ,…,r ppN ) from the information sent by multiple other peer nodes received, where r ppN is the random number sent by the Nth other peer node received by the peer node.
4. The method according to any one of claims 1 to 3, characterized in that, TLS secure communication is adopted between the first type of nodes and the second type of nodes.
5. The method according to any one of claims 1 to 3, characterized in that, The methods for the first type of nodes to process the received random numbers to generate an entropy source include but are not limited to: exclusive OR operation, addition operation, multiplication operation.
6. The method according to any one of claims 1 to 3, characterized in that, The first type of nodes perform entropy estimation and health testing on the currently generated entropy source, and add it to the entropy pool as an entropy source after meeting the entropy value requirement and the health testing requirement.
7. The method according to any one of claims 1 to 3, characterized in that, The entropy pool uses an iterative compression function to increase the entropy rate; when the first type of nodes generate their own random numbers, the data in the entropy pool is compressed and used as the input for random number generation.
8. The method according to any one of claims 1 to 3, characterized in that, The implementation methods of the entropy pool include but are not limited to cyclic shift registers.
9. A key generation method, characterized in that, The consortium blockchain Hyperledger system generates a key based on the random number generated by the method described in claim 1.
Citation Information
Patent Citations
A method for generating random numbers in blockchain smart contracts
CN113853578A