Generation method and device of random number in block chain and block chain link point

文档序号:467469 发布日期:2021-12-31 浏览:21次 中文

阅读说明:本技术 一种区块链中随机数的生成方法、装置及区块链节点 (Generation method and device of random number in block chain and block chain link point ) 是由 黄昊天 于 2021-12-07 设计创作,主要内容包括:本发明提供一种区块链中随机数的生成方法、装置及区块链节点,涉及区块链技术领域。该方法包括:根据存储的区块信息以及所述区块链网络中节点的数量生成第一随机因子并广播所述第一随机因子;获取所述区块链网络中的至少一个第二节点在接收到所述第一随机因子之后生成的第二随机因子;根据所述第一随机因子以及所述第二随机因子,生成第一随机数。本发明的方案,区块链网络中每个参与节点的权利都相同,通过各个节点自身的状态信息和群组共有信息独立产生各自的随机因子,并且根据所有参与节点的随机因子生成随机数,提高了随机数生成方法的随机性、公平性和安全性。解决了随机数生成方法的随机性和公平性不足的问题。(The invention provides a method and a device for generating random numbers in a block chain and block chain link points, and relates to the technical field of block chains. The method comprises the following steps: generating a first random factor according to the stored block information and the number of nodes in the block chain network and broadcasting the first random factor; acquiring a second random factor generated by at least one second node in the block chain network after receiving the first random factor; and generating a first random number according to the first random factor and the second random factor. According to the scheme, the rights of each participating node in the block chain network are the same, the random factors are independently generated through the self state information and the group common information of each node, and random numbers are generated according to the random factors of all participating nodes, so that the randomness, the fairness and the safety of the random number generation method are improved. The problem that the randomness and the fairness of the random number generation method are insufficient is solved.)

1. A method for generating a random number in a block chain is applied to a first node in a block chain network, and is characterized by comprising the following steps:

generating a first random factor according to the stored block information and the number of nodes in the block chain network and broadcasting the first random factor;

acquiring a second random factor generated by at least one second node in the block chain network after receiving the first random factor;

generating a first random number according to the first random factor and the second random factor;

wherein the first random number is a random number associated with a generating node, and the generating node is a node that generates an identity certificate of the first node.

2. The method of claim 1, wherein before generating the random factor according to the first block information and the number of nodes in the block chain network, the method further comprises:

connecting with at least one second node to generate the block chain network;

and initiating an identity certificate request to the blockchain network.

3. The method according to claim 1, wherein the generating the first random number comprises:

verifying the second random factor;

and after the second random factor passes verification, generating the first random number according to the first random factor and the second random factor.

4. The method of generating random numbers in a block chain according to claim 1, further comprising:

performing modulo calculation on the first random number to obtain a node number of the generation node;

and acquiring the identity certificate according to the node number.

5. The method according to claim 4, wherein before performing the modulo calculation on the first random number, the method further comprises:

broadcasting the first random number;

receiving a second random number generated by the second node;

verifying the first random number and the second random number;

wherein the second random number is generated according to the first random factor and the second random factor.

6. The method for generating random numbers in a block chain according to claim 5, wherein the obtaining the identity certificate according to the node number includes:

if the node number of the generating node is the same as the node number of the first node, generating the identity certificate;

and if the node number of the generating node is different from the node number of the first node, acquiring the identity certificate generated by the generating node.

7. The method according to claim 5, wherein the block number of the generating node is included in the forwarding information of the identity certificate.

8. A method for generating a random number in a block chain is applied to a target second node in a block chain network, and is characterized by comprising the following steps:

after receiving a first random factor broadcasted by a first node, generating a second random factor according to the stored block information and the number of nodes in the block chain network; generating a second random number according to the second random factor and a target random factor; the target random factor comprises the first random factor or the first random factor and a third random factor broadcast by a third node;

wherein the third node is a node in the blockchain network other than the first node and the second target node; the second random number is a random number associated with a generating node, the generating node being a node that generates an identity certificate of the first node.

9. The method according to claim 8, wherein the generating the second random number comprises:

verifying the first random factor;

and after the first random factor passes verification, generating the second random number according to the first random factor and the target random factor.

10. The method of generating random numbers in a block chain according to claim 8, further comprising:

performing modulo calculation on the second random number to obtain a node number of the generation node;

and if the node number of the generating node is the same as the node number of the second node, generating the identity certificate.

11. The method of claim 10, wherein before performing the modulo calculation on the second random number, the method further comprises:

broadcasting the second random number;

receiving a first random number generated by the first node;

verifying the first random number and the second random number;

wherein the first random number is generated according to the first random factor and the second random factor.

12. An apparatus for generating a random number in a block chain, applied to a first node in a block chain network, comprising:

a first generating module, configured to generate a first random factor according to the stored block information and the number of nodes in the blockchain network and broadcast the first random factor;

a first obtaining module, configured to obtain a second random factor generated by at least one second node in the blockchain network after receiving the first random factor;

a second generating module, configured to generate a first random number according to the first random factor and the second random factor;

wherein the first random number is a random number associated with a generating node, and the generating node is a node that generates an identity certificate of the first node.

13. The apparatus for generating random numbers in block chains according to claim 12, wherein said apparatus further comprises:

the connection module is used for connecting with at least one second node to generate the block chain network;

an initiating module, configured to initiate an identity certificate request to the blockchain network.

14. The apparatus for generating random numbers in block chains according to claim 12, wherein the generating module is further configured to:

verifying the second random factor;

and after the second random factor passes verification, generating the first random number according to the first random factor and the second random factor.

15. The apparatus for generating random numbers in block chains according to claim 12, wherein said apparatus further comprises:

the first calculation module is used for carrying out modular calculation on the first random number to obtain the node number of the generation node;

and the second acquisition module is used for acquiring the identity certificate according to the node number.

16. The apparatus for generating random numbers in block chains according to claim 15, wherein the first computing module is further configured to:

broadcasting the first random number;

receiving a second random number generated by the second node;

verifying the first random number and the second random number;

wherein the second random number is generated according to the first random factor and the second random factor.

17. The apparatus for generating random numbers in block chains according to claim 15, wherein the second obtaining module is further configured to:

if the node number of the generating node is the same as the node number of the first node, generating the identity certificate;

and if the node number of the generating node is different from the node number of the first node, acquiring the identity certificate generated by the generating node.

18. An apparatus for generating a random number in a block chain, applied to a target second node in a block chain network, comprising:

a third generating module, configured to generate a second random factor according to the stored block information and the number of nodes in the block chain network after receiving the first random factor broadcasted by the first node;

a fourth generating module, configured to generate a second random number according to the second random factor and the target random factor; the target random factor comprises the first random factor or the first random factor and a third random factor broadcast by a third node;

wherein the third node is a node in the blockchain network other than the first node and the second target node; the second random number is a random number associated with a generating node, the generating node being a node that generates an identity certificate of the first node.

19. The apparatus for generating random numbers in block chains according to claim 18, wherein the fourth generating module is further configured to:

verifying the first random factor;

and after the first random factor passes verification, generating the second random number according to the first random factor and the target random factor.

20. The apparatus for generating random numbers in block chains according to claim 18, wherein said apparatus further comprises:

the second calculation module is used for performing modulo calculation on the second random number to obtain the node number of the generation node;

a fifth generating module, configured to generate the identity certificate if the node number of the generating node is the same as the node number of the second node.

21. The apparatus of claim 20, wherein the second computing module is further configured to:

broadcasting the second random number;

receiving a first random number generated by the first node;

verifying the first random number and the second random number;

wherein the first random number is generated according to the first random factor and the second random factor.

22. A block link node, wherein the block link node is a first node, comprising: a first transceiver and a first processor;

the first processor is configured to generate a first random factor according to the stored block information and the number of nodes in the blockchain network;

the first transceiver is configured to broadcast the first random factor;

acquiring a second random factor generated by at least one second node in the block chain network after receiving the first random factor;

the first processor is further configured to generate a first random number according to the first random factor and the second random factor;

wherein the first random number is a random number associated with a generating node, and the generating node is a node that generates an identity certificate of the first node.

23. A block link node, wherein the block link node is a second node, comprising: a second transceiver and a second processor;

the second transceiver is used for receiving the first random factor broadcasted by the first node;

the second processor is configured to generate a second random factor according to the stored block information and the number of nodes in the block chain network after receiving the first random factor broadcasted by the first node;

generating a second random number according to the second random factor and a target random factor; the target random factor comprises the first random factor or the first random factor and a third random factor broadcast by a third node;

wherein the third node is a node in the blockchain network other than the first node and the second target node; the second random number is a random number associated with a generating node, the generating node being a node that generates an identity certificate of the first node.

24. A terminal device, comprising: a transceiver, a processor, a memory, and a program or instructions stored on the memory and executable on the processor; wherein the processor, when executing the program or instructions, implements a method for generating random numbers in a block chain according to any one of claims 1 to 7, or implements a method for generating random numbers in a block chain according to any one of claims 8 to 11.

25. A readable storage medium on which a program or instructions are stored, which program or instructions, when executed by a processor, carry out the steps in the method for generating random numbers in a block chain according to any one of claims 1 to 7, or carry out the method for generating random numbers in a block chain according to any one of claims 8 to 11.

Technical Field

The present invention relates to the field of block chain technologies, and in particular, to a method and an apparatus for generating a random number in a block chain, and a terminal device.

Background

The most common admission identity information authentication means in the block chain technology is a node certificate issued to admission through an identity authentication CA center. The random number is used as an important factor in the certificate authentication process, and the randomness and the fairness of the random number directly influence the decentralized degree of the block chain.

The current random number generation method generally comprises the following steps: having a trusted third party provide a random number for a contract; presetting a random number in advance for a plurality of nodes participating in the process, then submitting the hash value of the random number to a block chain, broadcasting own random number by each party after all the nodes are submitted, and combining the respective random numbers to generate a final random number; public information on the chain is used, such as hash values, time stamps, difficulty coefficients, etc. of the blocks are used as a source of random numbers. However, each random number generation method has insufficient randomness and fairness, and the block chain can not be decentralized.

Disclosure of Invention

The invention aims to provide a method and a device for generating random numbers in a block chain and a block chain link point, which are used for solving the problems that the randomness and the fairness of the random number generation method in the related technology are insufficient, and the decentralization of the block chain cannot be realized.

To achieve the above object, an embodiment of the present invention provides a method for generating a random number in a block chain, which is applied to a first node in a block chain network, and includes:

generating a first random factor according to the stored block information and the number of nodes in the block chain network and broadcasting the first random factor;

acquiring a second random factor generated by at least one second node in the block chain network after receiving the first random factor;

generating a first random number according to the first random factor and the second random factor;

wherein the first random number is a random number associated with a generating node, and the generating node is a node that generates an identity certificate of the first node.

Further, before generating the random factor according to the first block information and the number of nodes in the blockchain network, the method further includes:

connecting with at least one second node to generate the block chain network;

and initiating an identity certificate request to the blockchain network.

Further, the generating the first random number includes:

verifying the second random factor;

and after the second random factor passes verification, generating the first random number according to the first random factor and the second random factor.

Further, the method further comprises:

performing modulo calculation on the first random number to obtain a node number of the generation node;

and acquiring the identity certificate according to the node number.

Further, before performing the modulo calculation on the first random number, the method further includes:

broadcasting the first random number;

receiving a second random number generated by the second node;

verifying the first random number and the second random number;

wherein the second random number is generated according to the first random factor and the second random factor.

Further, the obtaining the identity certificate according to the node number includes:

if the node number of the generating node is the same as the node number of the first node, generating the identity certificate;

and if the node number of the generating node is different from the node number of the first node, acquiring the identity certificate generated by the generating node.

Further, the forwarding information of the identity certificate includes a block number of the generating node.

To achieve the above object, an embodiment of the present invention further provides a method for generating a random number in a block chain, which is applied to a target second node in a block chain network, and includes:

after receiving a first random factor broadcasted by a first node, generating a second random factor according to the stored block information and the number of nodes in the block chain network;

generating a second random number according to the second random factor and a target random factor, wherein the target random factor comprises the first random factor or the first random factor and a third random factor broadcasted by a third node;

wherein the third node is a node in the blockchain network other than the first node and the second target node; the second random number is a random number associated with a generating node, the generating node being a node that generates an identity certificate of the first node.

Further, the generating the second random number includes:

verifying the first random factor;

and after the first random factor passes verification, generating the second random number according to the first random factor and the target random factor.

Further, the method further comprises:

performing modulo calculation on the second random number to obtain a node number of the generation node;

and if the node number of the generating node is the same as the node number of the second node, generating the identity certificate.

Further, before performing the modulo calculation on the second random number, the method further includes:

broadcasting the second random number;

receiving a first random number generated by the first node;

verifying the first random number and the second random number;

wherein the first random number is generated according to the first random factor and the second random factor.

To achieve the above object, an embodiment of the present invention further provides an apparatus for generating a random number in a block chain, which is applied to a first node in a block chain network, and includes:

a first generating module, configured to generate a first random factor according to the stored block information and the number of nodes in the blockchain network and broadcast the first random factor;

a first obtaining module, configured to obtain a second random factor generated by at least one second node in the blockchain network after receiving the first random factor;

a second generating module, configured to generate a first random number according to the first random factor and the second random factor;

wherein the first random number is a random number associated with a generating node, and the generating node is a node that generates an identity certificate of the first node.

Further, the apparatus further comprises:

the connection module is used for connecting with at least one second node to generate the block chain network;

an initiating module, configured to initiate an identity certificate request to the blockchain network.

Further, the generating module is further configured to:

verifying the second random factor;

and after the second random factor passes verification, generating the first random number according to the first random factor and the second random factor.

Further, the apparatus further comprises:

the first calculation module is used for carrying out modular calculation on the first random number to obtain the node number of the generation node;

and the second acquisition module is used for acquiring the identity certificate according to the node number.

The first computing module is further configured to:

broadcasting the first random number;

receiving a second random number generated by the second node;

verifying the first random number and the second random number;

wherein the second random number is generated according to the first random factor and the second random factor.

Further, the second obtaining module is further configured to:

if the node number of the generating node is the same as the node number of the first node, generating the identity certificate;

and if the node number of the generating node is different from the node number of the first node, acquiring the identity certificate generated by the generating node.

To achieve the above object, an embodiment of the present invention further provides an apparatus for generating a random number in a block chain, which is applied to a target second node in a block chain network, and includes:

a third generating module, configured to generate a second random factor according to the stored block information and the number of nodes in the block chain network after receiving the first random factor broadcasted by the first node;

a fourth generating module, configured to generate a second random number according to the second random factor and the target random factor; the target random factor comprises the first random factor or the first random factor and a third random factor broadcast by a third node;

wherein the third node is a node in the blockchain network other than the first node and the second target node; the second random number is a random number associated with a generating node, the generating node being a node that generates an identity certificate of the first node.

Further, the fourth generating module is further configured to:

verifying the first random factor;

and after the first random factor passes verification, generating the second random number according to the first random factor and the target random factor.

Further, the apparatus further comprises:

the second calculation module is used for performing modulo calculation on the second random number to obtain the node number of the generation node;

a fifth generating module, configured to generate the identity certificate if the node number of the generating node is the same as the node number of the second node.

Further, the second calculation module is further configured to:

broadcasting the second random number;

receiving a first random number generated by the first node;

verifying the first random number and the second random number;

wherein the first random number is generated according to the first random factor and the second random factor.

To achieve the above object, an embodiment of the present invention further provides a block link point, including: a first transceiver and a first processor;

the first processor is configured to generate a first random factor according to the stored block information and the number of nodes in the blockchain network;

the first transceiver is configured to broadcast the first random factor;

acquiring a second random factor generated by at least one second node in the block chain network after receiving the first random factor;

the first processor is further configured to generate a first random number according to the first random factor and the second random factor;

wherein the first random number is a random number associated with a generating node, and the generating node is a node that generates an identity certificate of the first node.

To achieve the above object, an embodiment of the present invention further provides a block link point, including: a second transceiver and a second processor;

the second transceiver is used for receiving the first random factor broadcasted by the first node;

the second processor is configured to generate a second random factor according to the stored block information and the number of nodes in the block chain network after receiving the first random factor broadcasted by the first node;

generating a second random number according to the second random factor and a target random factor; the target random factor comprises the first random factor or the first random factor and a third random factor broadcast by a third node;

wherein the third node is a node in the blockchain network other than the first node and the second target node; the second random number is a random number associated with a generating node, the generating node being a node that generates an identity certificate of the first node.

To achieve the above object, an embodiment of the present invention provides a terminal device, including a transceiver, a processor, a memory, and a program or instructions stored in the memory and executable on the processor; the processor, when executing the program or instructions, implements the method of generating random numbers in a block chain as described above.

To achieve the above object, an embodiment of the present invention provides a readable storage medium on which a program or instructions are stored, which when executed by a processor implement the steps in the method for generating random numbers in a block chain as described above.

The technical scheme of the invention has the following beneficial effects:

according to the method for generating the random number in the block chain, a first node generates a first random factor according to the block information stored in the first node and the number of nodes in the block chain network, and broadcasts the first random factor; and generating a first random number according to the first random factor and the received second random factor generated by the second node. According to the method for generating the random number in the block chain, the right of each participating node in the block chain network is the same, the random factors are independently generated through the state information of each node and the group common information, and the random number is generated according to the random factors of all participating nodes, so that the randomness, the fairness and the safety of the method for generating the random number are improved.

Drawings

Fig. 1 is a flowchart illustrating a method for generating a random number in a block chain of a first node in a block chain network according to an embodiment of the present invention;

fig. 2 is a schematic diagram of a method for generating a random number in a block chain by taking a first node as an identity certificate application node as an example according to an embodiment of the present invention;

fig. 3 is a flowchart illustrating a method for generating a random number in a block chain of a target second node applied to a block chain network according to an embodiment of the present invention;

fig. 4 is a schematic diagram of an apparatus for generating a random number in a block chain of a first node in a block chain network according to an embodiment of the present invention;

fig. 5 is a schematic diagram of an apparatus for generating a random number in a block chain of a target second node in a block chain network according to an embodiment of the present invention;

fig. 6 is a schematic structural diagram of a terminal device according to an embodiment of the present invention.

Detailed Description

In order to make the technical problems, technical solutions and advantages of the present invention more apparent, the following detailed description is given with reference to the accompanying drawings and specific embodiments.

It should be appreciated that reference throughout this specification to "one embodiment" or "an embodiment" means that a particular feature, structure or characteristic described in connection with the embodiment is included in at least one embodiment of the present invention. Thus, the appearances of the phrases "in one embodiment" or "in an embodiment" in various places throughout this specification are not necessarily all referring to the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

In various embodiments of the present invention, it should be understood that the sequence numbers of the following processes do not mean the execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.

In addition, the terms "system" and "network" are often used interchangeably herein.

In the embodiments provided herein, it should be understood that "B corresponding to a" means that B is associated with a from which B can be determined. It should also be understood that determining B from a does not mean determining B from a alone, but may also be determined from a and/or other information.

As shown in fig. 1, an embodiment of the present invention provides a method for generating a random number in a block chain, which is applied to a first node in a block chain network, and includes:

step 101, generating a first random factor according to the stored block information and the number of nodes in the block chain network and broadcasting the first random factor;

step 102, acquiring a second random factor generated by at least one second node in the block chain network after receiving the first random factor;

103, generating a first random number according to the first random factor and the second random factor;

wherein the first random number is a random number associated with a generating node, and the generating node is a node that generates an identity certificate of the first node.

It should be noted that the first node is a node that initiates a certificate request in a blockchain network, and the second node is a node in the blockchain network except the first node.

Optionally, the block information includes only a block number.

According to the method for generating the random number in the block chain, a first node generates a first random factor according to the block information stored in the first node and the number of nodes in the block chain network, and broadcasts the first random factor; and generating a first random number according to the first random factor and the received second random factor generated by the second node. According to the method for generating the random number in the block chain, the right of each participating node in the block chain network is the same, the random factors are independently generated through the state information of each node and the group common information, and the random number is generated according to the random factors of all participating nodes, so that the randomness, the fairness and the safety of the method for generating the random number are improved.

Optionally, before generating the random factor according to the first block information and the number of nodes in the blockchain network, the method further includes:

connecting with at least one second node to generate the block chain network;

and initiating an identity certificate request to the blockchain network.

In an embodiment of the present invention, a plurality of initial nodes are directly connected to form a network, and each initial node issues an identity certificate request to the network to obtain a respective identity certificate. It should be noted that a node to be subsequently added to the network only needs to initiate a certificate request to the initial node that has obtained the identity certificate.

According to the method for generating the random number in the block chain, the identity certificate is generated after the initial nodes are networked, and the random factors related to the generation of the identity certificate are generated by each node according to the information of the node, so that the safety and the reliability of the identity certificate are improved.

Optionally, the generating the first random number includes:

verifying the second random factor;

and after the second random factor passes verification, generating the first random number according to the first random factor and the second random factor.

Optionally, the first node verifies the second random factor according to the stored block information, and verifies the signature through the verified second random factor.

Optionally, the first random number and the second random number are both generated according to the first random factor and the second random factor, so the first random number and the second random number are equal. Thus, the second random number may be verified by determining whether the second random number is equal to the first random number.

Optionally, the method further comprises:

performing modulo calculation on the first random number to obtain a node number of the generation node;

and acquiring the identity certificate according to the node number.

Optionally, performing modulo calculation on the first random number, where an obtained calculation result is a node number of a generation node, determining that a node in the block chain network, where the node number is the same as the node number of the generation node, is the generation node, and generating the identity certificate by the generation node.

In the method for generating a random number in a block chain according to the embodiment of the present invention, the determination of the random number related to the generation node of the identity certificate is determined by the random factors calculated by all the participating nodes in the block chain network, and the change of any one node causes the change of the random factor, thereby ensuring the randomness of the generation node. Therefore, the scheme of the embodiment of the invention ensures the randomness and the safety of random number generation, thereby improving the randomness of the generated nodes and ensuring the decentralization of the block chain network.

Optionally, before performing the modulo calculation on the first random number, the method further includes:

broadcasting the first random number;

receiving a second random number generated by the second node;

verifying the first random number and the second random number;

wherein the second random number is generated according to the first random factor and the second random factor.

Specifically, the first random number and the second random number are both generated according to the first random factor and the second random factor, so the first random number and the second random number are equal. Accordingly, the first random number may be verified by determining whether the first random number is equal to the second random number.

According to the method for generating the random number in the block chain, before the nodes perform modulus extraction on the random number, the random number generated by each node is compared with the random numbers generated by the other nodes for verification, so that the generation of wrong random numbers caused by malicious tampering in the transmission process of random factors is avoided, and the safety of determining the generated nodes is improved. Optionally, the obtaining the identity certificate according to the node number includes:

if the node number of the generating node is the same as the node number of the first node, generating the identity certificate;

and if the node number of the generating node is different from the node number of the first node, acquiring the identity certificate generated by the generating node.

According to the method for generating the random number in the block chain, the right of each participating node in the block chain network is the same, the random factors are independently generated through the state information of each node and the group common information, the random number is generated according to the random factors of all participating nodes, each node can be used as a generating node, the randomness determined by the generating node is ensured, and the fairness of the right of each node in the block chain is improved.

Optionally, the forwarding information of the identity certificate includes a block number of the generating node.

In an embodiment of the present invention, the production node stores its own block number and integer serial number in the forwarding information of the identity certificate, and verifies the signature in cooperation with the node information of the identity certificate application node to obtain the generated identity certificate.

It should be noted that a new block is generated when the identity certificate is generated, and the random factor, the random number and the generated identity certificate in the process of generating the identity certificate are attached to the newly generated block, and can be used for forward or backward tracing verification in cooperation with the block number recorded in the forward information of the identity certificate, thereby avoiding the problem that the verification needs to be performed through a root certificate in each verification.

According to the method for generating the random number in the block chain, only one block is generated in the process of applying for the identity certificate by the node each time, time overhead accompanying multiple steps of the node set does not exist, and the method is improved; the efficiency of certificate generation is improved, and the operation overhead is reduced.

The logic of the method for generating a random number in a block chain, the method for determining a generation node, and the method for generating an identity certificate of an embodiment of the present invention:

a plurality of initial nodes are connected with each other to form a block chain network;

each node sends an identity certificate request to a blockchain network;

each node generates a random factor according to the block information stored in the node and the number of the nodes in the block chain network, and broadcasts the generated random factor;

verifying the received random factors of other nodes;

after the received random factors of all other nodes in the block chain network pass verification, generating random numbers and broadcasting the generated random numbers;

verifying the received random numbers of other nodes;

after determining that the received random numbers of other nodes are the same as the random numbers generated by the nodes, performing modular operation on the random numbers;

the node with the same node number as the calculated result is the generating node;

if the generating node is self, generating an identity certificate; and if the generating node is other nodes, receiving the identity certificate generated by the generating node.

Fig. 2 is a schematic diagram of a method for generating a random number in a block chain by taking a node 1 as an identity certificate application node as an example, where the node 1 is a first node, that is, an application node of an identity certificate, and nodes 2 and 3 are other nodes in a block chain network except the node 1. The node 1 initiates an identity certificate request to a network, generates a random factor of the node 1, broadcasts the random factor of the node 1, receives the random factors generated by the nodes 2 and 3, and generates a random number according to the random factor generated by the node 1 and the received random factors of the nodes 2 and 3.

As shown in fig. 3, a method for generating a random number in a block chain according to an embodiment of the present invention is applied to a target second node in a block chain network, and includes:

step 301, after receiving a first random factor broadcasted by a first node, generating a second random factor according to the stored block information and the number of nodes in the block chain network;

step 302, generating a second random number according to the second random factor and a target random factor; the target random factor comprises the first random factor or the first random factor and a third random factor broadcast by a third node;

wherein the third node is a node in the blockchain network other than the first node and the second target node; the second random number is a random number associated with a generating node, the generating node being a node that generates an identity certificate of the first node.

In an embodiment of the present invention, in the process of the random number generating method, when there is only one second node involved, the target random factor is the first random factor;

when there are a plurality of participating second nodes, the target random number is the first random factor and the third random factor.

According to the method for generating the random number in the block chain, the right of each participating node in the block chain network is the same, the random factors are independently generated through the state information of each node and the group common information, and the random number is generated according to the random factors of all participating nodes, so that the randomness, the fairness and the safety of the method for generating the random number are improved.

Optionally, the generating the second random number includes:

verifying the first random factor;

and after the first random factor passes verification, generating the second random number according to the first random factor and the target random factor.

According to the method for generating the random number in the block chain, the received first random factor of the first node is verified, the second random number is generated according to the second random factor generated by the first random factor and the first random factor, and the safety of random number generation is guaranteed.

Optionally, the method further comprises:

performing modulo calculation on the second random number to obtain a node number of the generation node;

and if the node number of the generating node is the same as the node number of the second node, generating the identity certificate.

According to the method for generating the random number in the block chain, the right of each participating node in the block chain network is the same, the random factors are independently generated through the state information of each node and the group common information, the random number is generated according to the random factors of all participating nodes, each node can be used as a generating node, the randomness determined by the generating node is ensured, and the fairness of the right of each node in the block chain is improved.

Optionally, before performing the modulo calculation on the second random number, the method further includes:

broadcasting the second random number;

receiving a first random number generated by the first node;

verifying the first random number and the second random number;

wherein the first random number is generated according to the first random factor and the second random factor.

Specifically, the first random number and the second random number are both generated according to the first random factor and the second random factor, so the first random number and the second random number are equal. Accordingly, the first random number may be verified by determining whether the first random number is equal to the second random number.

According to the method for generating the random number in the block chain, before the nodes perform modulus extraction on the random number, the random number generated by each node is compared with the random numbers generated by the other nodes for verification, so that the generation of wrong random numbers caused by malicious tampering in the transmission process of random factors is avoided, and the safety of node determination of the identity certificate is improved.

As shown in fig. 4, an embodiment of the present invention further provides an apparatus 400 for generating a random number in a block chain, which is applied to a first node in a block chain network, and includes:

a first generating module 401, configured to generate a first random factor according to the stored block information and the number of nodes in the blockchain network and broadcast the first random factor;

a first obtaining module 402, configured to obtain a second random factor generated by at least one second node in the blockchain network after receiving the first random factor;

a second generating module 403, configured to generate a first random number according to the first random factor and the second random factor;

wherein the first random number is a random number associated with a generating node, and the generating node is a node that generates an identity certificate of the first node.

According to the device for generating the random number in the block chain, the right of each participating node in the block chain network is the same, the random factors are independently generated through the state information of each node and the group common information, and the random number is generated according to the random factors of all participating nodes, so that the randomness, the fairness and the safety of the random number generation method are improved.

Optionally, the apparatus further comprises:

the connection module is used for connecting with at least one second node to generate the block chain network;

an initiating module, configured to initiate an identity certificate request to the blockchain network.

Optionally, the generating module is further configured to:

verifying the second random factor;

and after the second random factor passes verification, generating the first random number according to the first random factor and the second random factor.

Optionally, the apparatus further comprises:

the first calculation module is used for carrying out modular calculation on the first random number to obtain the node number of the generation node;

and the second acquisition module is used for acquiring the identity certificate according to the node number.

Optionally, the first computing module is further configured to:

broadcasting the first random number;

receiving a second random number generated by the second node;

verifying the first random number and the second random number;

wherein the second random number is generated according to the first random factor and the second random factor.

Optionally, the second obtaining module is further configured to:

if the node number of the generating node is the same as the node number of the first node, generating the identity certificate;

and if the node number of the generating node is different from the node number of the first node, acquiring the identity certificate generated by the generating node.

As shown in fig. 5, an embodiment of the present invention further provides an apparatus 500 for generating a random number in a block chain, which is applied to a target second node in a block chain network, and includes:

a third generating module 501, configured to generate a second random factor according to the stored block information and the number of nodes in the block chain network after receiving the first random factor broadcasted by the first node;

a fourth generating module 502, configured to generate a second random number according to the second random factor and a target random factor; the target random factor comprises the first random factor or the first random factor and a third random factor broadcast by a third node;

wherein the third node is a node in the blockchain network other than the first node and the second target node; the second random number is a random number associated with a generating node, the generating node being a node that generates an identity certificate of the first node.

According to the device for generating the random number in the block chain, the right of each participating node in the block chain network is the same, the random factors are independently generated through the state information of each node and the group common information, and the random number is generated according to the random factors of all participating nodes, so that the randomness, the fairness and the safety of the random number generation method are improved.

Optionally, the fourth generating module is further configured to:

verifying the first random factor;

and after the first random factor passes verification, generating the second random number according to the first random factor and the second random factor.

Optionally, the apparatus further comprises:

the second calculation module is used for performing modulo calculation on the second random number to obtain the node number of the generation node;

a fifth generating module, configured to generate the identity certificate if the node number of the generating node is the same as the node number of the second node.

Optionally, the second computing module is further configured to:

broadcasting the second random number;

receiving a first random number generated by the first node;

verifying the first random number and the second random number;

wherein the first random number is generated according to the first random factor and the second random factor.

An embodiment of the present invention further provides a block link point, including: a first transceiver and a first processor;

the first processor is configured to generate a first random factor according to the stored tile information and the number of nodes in the blockchain network.

The first transceiver is configured to broadcast the first random factor.

Acquiring a second random factor generated by at least one second node in the block chain network after receiving the first random factor.

The first processor is further configured to generate a first random number according to the first random factor and the second random factor.

Wherein the first random number is a random number associated with a generating node, and the generating node is a node that generates an identity certificate of the first node.

The first processor is further configured to connect with at least one second node to generate the blockchain network.

The first transceiver is further configured to initiate an identity certificate request to the blockchain network.

The first processor is further configured to verify the second random factor;

and after the second random factor passes verification, generating the first random number according to the first random factor and the second random factor.

The first processor is further configured to perform modulo calculation on the first random number to obtain a node number of the generation node;

and acquiring the identity certificate according to the node number.

The first processor is further configured to generate the identity certificate if the node number of the generation node is the same as the node number of the first node;

the first transceiver is further configured to acquire the identity certificate generated by the generating node if the node number of the generating node is different from the node number of the first node.

An embodiment of the present invention further provides a block link point, including: a second transceiver and a second processor;

the second transceiver is used for receiving the first random factor broadcasted by the first node;

the second processor is configured to generate a second random factor according to the stored block information and the number of nodes in the block chain network after receiving the first random factor broadcasted by the first node;

generating a second random number according to the second random factor and a target random factor; the target random factor comprises the first random factor or the first random factor and a third random factor broadcast by a third node;

wherein the third node is a node in the blockchain network other than the first node and the second target node; the second random number is a random number associated with a generating node, the generating node being a node that generates an identity certificate of the first node.

The second processor is further configured to verify the first random factor;

and after the first random factor passes verification, generating the second random number according to the first random factor and the target random factor.

The second processor is further configured to perform modulo calculation on the second random number to obtain a node number of the generation node;

and if the node number of the generating node is the same as the node number of the second node, generating the identity certificate.

A terminal device according to another embodiment of the present invention, as shown in fig. 6, includes a transceiver 610, a processor 600, a memory 620, and a program or instructions stored in the memory 620 and executable on the processor 600; the processor 600 implements the above-described method for generating random numbers in a block chain when executing the program or instructions.

The transceiver 610 is used for receiving and transmitting data under the control of the processor 600.

Where in fig. 6, the bus architecture may include any number of interconnected buses and bridges, with various circuits being linked together, particularly one or more processors represented by processor 600 and memory represented by memory 620. The bus architecture may also link together various other circuits such as peripherals, voltage regulators, power management circuits, and the like, which are well known in the art, and therefore, will not be described any further herein. The bus interface provides an interface. The transceiver 610 may be a number of elements including a transmitter and a receiver that provide a means for communicating with various other apparatus over a transmission medium.

The processor 600 is responsible for managing the bus architecture and general processing, and the memory 620 may store data used by the processor 600 in performing operations.

The readable storage medium of the embodiment of the present invention stores a program or an instruction thereon, and the program or the instruction, when executed by the processor, implements the steps in the method for generating a random number in a block chain as described above, and can achieve the same technical effects, and the details are not repeated here to avoid repetition.

The readable storage medium includes a computer-readable storage medium, such as a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk.

It is further noted that the terminals described in this specification include, but are not limited to, smart phones, tablets, etc., and that many of the functional components described are referred to as modules in order to more particularly emphasize their implementation independence.

In embodiments of the present invention, modules may be implemented in software for execution by various types of processors. An identified module of executable code may, for instance, comprise one or more physical or logical blocks of computer instructions which may, for instance, be constructed as an object, procedure, or function. Nevertheless, the executables of an identified module need not be physically located together, but may comprise disparate instructions stored in different bits which, when joined logically together, comprise the module and achieve the stated purpose for the module.

Indeed, a module of executable code may be a single instruction, or many instructions, and may even be distributed over several different code segments, among different programs, and across several memory devices. Likewise, operational data may be identified within the modules and may be embodied in any suitable form and organized within any suitable type of data structure. The operational data may be collected as a single data set, or may be distributed over different locations including over different storage devices, and may exist, at least partially, merely as electronic signals on a system or network.

When a module can be implemented by software, considering the level of existing hardware technology, a module implemented by software may build a corresponding hardware circuit to implement a corresponding function, without considering cost, and the hardware circuit may include a conventional Very Large Scale Integration (VLSI) circuit or a gate array and an existing semiconductor such as a logic chip, a transistor, or other discrete components. A module may also be implemented in programmable hardware devices such as field programmable gate arrays, programmable array logic, programmable logic devices or the like.

The exemplary embodiments described above are described with reference to the drawings, and many different forms and embodiments of the invention may be made without departing from the spirit and teaching of the invention, therefore, the invention is not to be construed as limited to the exemplary embodiments set forth herein. Rather, these exemplary embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art. In the drawings, the size and relative sizes of elements may be exaggerated for clarity. The terminology used herein is for the purpose of describing particular example embodiments only and is not intended to be limiting. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. Unless otherwise indicated, a range of values, when stated, includes the upper and lower limits of the range and any subranges therebetween.

While the foregoing is directed to the preferred embodiment of the present invention, it will be understood by those skilled in the art that various changes and modifications may be made without departing from the spirit and scope of the invention as defined in the appended claims.

21页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种开发管理方法、平台及存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类