CN112968769A - Method and device for generating random number in block chain - Google Patents

Method and device for generating random number in block chain Download PDF

Info

Publication number
CN112968769A
CN112968769A CN202110233212.4A CN202110233212A CN112968769A CN 112968769 A CN112968769 A CN 112968769A CN 202110233212 A CN202110233212 A CN 202110233212A CN 112968769 A CN112968769 A CN 112968769A
Authority
CN
China
Prior art keywords
random number
node
service
block chain
intelligent contract
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110233212.4A
Other languages
Chinese (zh)
Other versions
CN112968769B (en
Inventor
穆长春
狄刚
钱友才
陈庆接
杜金钊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Digital Currency Institute of the Peoples Bank of China
Original Assignee
Digital Currency Institute of the Peoples Bank of China
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Digital Currency Institute of the Peoples Bank of China filed Critical Digital Currency Institute of the Peoples Bank of China
Priority to CN202110233212.4A priority Critical patent/CN112968769B/en
Publication of CN112968769A publication Critical patent/CN112968769A/en
Priority to EP22762599.3A priority patent/EP4304131A1/en
Priority to PCT/CN2022/079062 priority patent/WO2022184137A1/en
Application granted granted Critical
Publication of CN112968769B publication Critical patent/CN112968769B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0861Generation of secret information including derivation or calculation of cryptographic keys or passwords
    • H04L9/0869Generation of secret information including derivation or calculation of cryptographic keys or passwords involving random numbers or seeds
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/06Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
    • H04L9/0643Hash functions, e.g. MD5, SHA, HMAC or f9 MAC
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3236Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions
    • H04L9/3239Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions involving non-keyed hash functions, e.g. modification detection codes [MDCs], MD5, SHA or RIPEMD
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees

Abstract

The invention discloses a method and a device for generating random numbers in a block chain, and relates to the technical field of computers. One embodiment of the method comprises: locally generating a first random number and a first abstract value of the first random number by using a first node in a block chain; the first node submits a first abstract value to the intelligent contract; the intelligent contract broadcasts the first service so that at least one block link point submits participation information related to the first service; the intelligent contract determines a second node from at least one block chain node according to the sequence of submitting the participation information; when the first service is finished, the first node submits a first random number to the intelligent contract; when the intelligent contract verifies that the first random number corresponds to the first abstract value, generating a second random number according to a second abstract value of the second node and the first random number; and starting the second service according to the second random number. The implementation method improves the reliability of the random number, and further ensures the fairness of the service result.

Description

Method and device for generating random number in block chain
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for generating random numbers in a block chain.
Background
Random numbers have many application scenarios in block chains, such as generation of private keys and guessing-type applications. With the continuous development of the block chain, the application of random numbers in the block chain will continue to increase. Therefore, how to generate reliable random numbers in the blockchain is important for the security of the assets in the blockchain and the fairness of the applications.
The common random number generation method in the prior art is as follows: the block producer computes the random number based on the hash value of one or more blocks in the block chain as its random number seed.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art: the block producer may adjust the random number by adding or discarding part of the transaction, that is, there is a possibility that the block producer may cheat in the random number generation process, which results in a low reliability of the generated random number.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for generating a random number in a block chain, where a first node in the block chain is used to first locally generate a first random number and a first digest value of the first random number, and then submit the first digest value to an intelligent contract. After the intelligent contract broadcasts the first service, each block chain node can participate in the first service by submitting participation information, then the intelligent contract can determine a second node according to the sequence of the participation information submitted by each block chain node, and a second random number is generated by combining a second abstract value of the second node and the first random number submitted by the first node after the first service is finished. Since the sequence of each block chain link point participating in the first service cannot be determined in advance, that is, the sequence of each block chain link point participating in the first service is random, the process of determining the second node according to the sequence of submitting participation information by each block chain node cannot be cheated, and the randomness of the second node is ensured. In addition, the first abstract value submitted by the first node to the intelligent contract can be notified to each block chain node in the block chain, and the intelligent contract can also check the first abstract value and the first random number, so that the first abstract value submitted by the first node and the first random number submitted after the first service is finished can not be cheated. Therefore, the intelligent contract can not cheat according to the second abstract value of the second node and the first random number submitted by the first node, namely, the generation process of the second random number can not cheat, and therefore the reliability of the generated random number is improved. Furthermore, the second service is started according to the generated credible random number, so that the randomness of the result of the second service can be ensured, the possibility of cheating caused by human intervention is avoided, and the fairness of the service result is ensured.
To achieve the above object, according to an aspect of an embodiment of the present invention, a method for generating a random number in a block chain is provided.
The method for generating the random number in the block chain comprises the following steps: locally generating a first random number and a first digest value of the first random number by using a first node in the blockchain;
the first node submits the first digest value to an intelligent contract;
the intelligent contract broadcasts a first service so that at least one block link point in the block chain submits participation information about the first service;
the intelligent contract determines a second node from the at least one block chain node according to the sequence of the participation information submitted by the at least one block chain node;
when the first service is finished, the first node submits the first random number to the intelligent contract;
when the intelligent contract verifies that the first random number corresponds to the first abstract value, generating a second random number according to a second abstract value of the second node and the first random number;
and starting a second service according to the second random number.
Optionally, the determining a second node from the at least one blockchain node includes:
and determining the second node according to a preset target value and the sequence of submitting the participation information by the at least one block link point.
Optionally, the preset target value is the last in the sequence.
Optionally, the second digest value and the first random number are calculated according to a preset algorithm to generate the second random number.
Optionally, the smart contract generates a third digest value according to the first random number; wherein the algorithms for generating the first digest value and the third digest value are the same;
when the third digest value is the same as the first digest value, determining that the first random number corresponds to the first digest value.
Optionally, a block link point corresponding to a provider of the first service is used as the first node.
Optionally, after generating the second random number, the method further includes:
the intelligent contract sends virtual resources to the first node.
Optionally, the starting the second service according to the second random number includes:
receiving at least one option submitted by the blockchain nodes respectively;
and starting a selection service to determine a target selection item from the selection items respectively submitted by the at least one block chain link point according to the second random number.
Optionally, the method further comprises: and sending the virtual resource to the block chain node submitting the target option.
To achieve the above object, according to still another aspect of the embodiments of the present invention, there is provided an apparatus for generating a random number in a block chain.
The device for generating the random number in the block chain in the embodiment of the invention comprises: the system comprises a local generation module, a submission module, a first service module, a random number generation module and a second service module; wherein the content of the first and second substances,
the local generation module is configured to locally generate a first random number and a first digest value of the first random number by using a first node in the block chain;
the submitting module is used for submitting the first abstract value to the intelligent contract by using the first node; submitting the first random number to the intelligent contract by using the first node when the first service is finished;
the first service module is used for broadcasting a first service by using the intelligent contract so as to enable at least one block link point in the block chain to submit participation information about the first service;
the random number generation module is used for determining a second node from the at least one block chain node according to the sequence of the participation information submitted by the at least one block chain node by using the intelligent contract; when the intelligent contract verifies that the first random number corresponds to the first abstract value, generating a second random number according to a second abstract value of the second node and the first random number;
and the second service module is used for starting a second service according to the second random number.
Optionally, the random number generation module is configured to determine the second node according to a preset target value and a sequence in which the at least one block link point submits the participation information.
Optionally, the preset target value is the last in the sequence.
Optionally, the random number generating module is configured to calculate the second digest value and the first random number according to a preset algorithm to generate the second random number.
Optionally, the random number generation module is configured to generate a third digest value according to the first random number by using the smart contract; wherein the algorithms for generating the first digest value and the third digest value are the same; when the third digest value is the same as the first digest value, determining that the first random number corresponds to the first digest value.
Optionally, the local generation module is configured to use a block link point corresponding to a provider of the first service as the first node.
Optionally, the second service module is further configured to send a virtual resource to the first node by using the intelligent contract.
Optionally, the second service module is configured to receive options respectively submitted by at least one of the blockchain nodes; and starting a selection service to determine a target selection item from the selection items respectively submitted by the at least one block chain link point according to the second random number.
Optionally, the second service module is further configured to send a virtual resource to a block link node submitting the target option.
To achieve the above object, according to still another aspect of embodiments of the present invention, there is provided an electronic device that generates a random number in a block chain.
An electronic device for generating a random number in a block chain according to an embodiment of the present invention includes: one or more processors; a storage device, configured to store one or more programs, which when executed by the one or more processors, cause the one or more processors to implement a method for generating random numbers in a blockchain according to an embodiment of the present invention.
To achieve the above object, according to still another aspect of embodiments of the present invention, there is provided a computer-readable storage medium.
A computer-readable storage medium of an embodiment of the present invention stores thereon a computer program, which when executed by a processor implements a method for generating random numbers in a block chain of an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: the method comprises the steps of firstly locally generating a first random number and a first abstract value of the first random number by using a first node in a block chain, and then submitting the first abstract value to an intelligent contract. After the intelligent contract broadcasts the first service, each block chain node can participate in the first service by submitting participation information, then the intelligent contract can determine a second node according to the sequence of the participation information submitted by each block chain node, and a second random number is generated by combining a second abstract value of the second node and the first random number submitted by the first node after the first service is finished. Since the sequence of each block chain link point participating in the first service cannot be determined in advance, that is, the sequence of each block chain link point participating in the first service is random, the process of determining the second node according to the sequence of submitting participation information by each block chain node cannot be cheated, and the randomness of the second node is ensured. In addition, the first abstract value submitted by the first node to the intelligent contract can be notified to each block chain node in the block chain, and the intelligent contract can also check the first abstract value and the first random number, so that the first abstract value submitted by the first node and the first random number submitted after the first service is finished can not be cheated. Therefore, the intelligent contract can not cheat according to the second abstract value of the second node and the first random number submitted by the first node, namely, the generation process of the second random number can not cheat, and therefore the reliability of the generated random number is improved. Furthermore, the second service is started according to the generated credible random number, so that the randomness of the result of the second service can be ensured, the possibility of cheating caused by human intervention is avoided, and the fairness of the service result is ensured.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a diagram illustrating the main steps of a method for generating random numbers in a block chain according to an embodiment of the present invention;
fig. 2 is a schematic diagram of main steps of another method for generating random numbers in a block chain according to an embodiment of the present invention;
FIG. 3 is a block diagram of the main blocks of an apparatus for generating random numbers in a blockchain according to an embodiment of the present invention;
FIG. 4 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 5 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It should be noted that the embodiments of the present invention and the technical features of the embodiments may be combined with each other without conflict.
Fig. 1 is a schematic diagram illustrating the main steps of a method for generating random numbers in a block chain according to an embodiment of the present invention.
As shown in fig. 1, a method for generating random numbers in a block chain according to an embodiment of the present invention mainly includes the following steps:
step S101: generating a first random number locally by a first node in the blockchain and a first digest value of the first random number.
In an embodiment of the present invention, a block link point corresponding to a provider of the first service may be used as the first node. For example, each block link point in the block chain may issue a first service using a smart contract, such as a voting or auction campaign, and when the smart contract prepares to generate a second random number by using the digest values of the block chain nodes participating in the service, the block link point corresponding to the provider of the corresponding campaign may be notified before the first service is started, so that the first random number and the first digest value of the first random number are locally generated.
Of course, in addition to the foregoing embodiments, the first node may also be determined in other manners according to the embodiments of the present invention, for example, the first node may be determined by voting by each blockchain node in the blockchain, or the first node that needs to locally generate the first random number and the first digest value is written in the intelligent contract in advance.
In generating the first digest value of the first random number, the first node may generate the first digest value through a secure hash algorithm, such as a sha256 algorithm. For convenience of description, a first random number generated by a first node in a block chain is denoted as k in the following1Will k is1Is represented by a first abstract value of h1
Step S102: the first node submits the first digest value to an intelligent contract.
Before the first service is started, the first node determined in any way can generate a first abstract value h locally by the first node1And submitting the contract to an intelligent contract. Then, any blockchain node in the blockchain may know the first digest value h1Therefore, the first node is prevented from cheating in the process of submitting the first abstract value and the first random number, and the reliability of generating the second random number is improved.
Step S103: the intelligent contract broadcasts a first service to cause at least one block link point in the block chain to submit participation information regarding the first service.
The intelligent contract can broadcast first services such as voting and auction to each block link point in the block chain, so that each block chain node participates in the first services according to the notification, the block link points participating in the first services correspondingly submit participation information, and if the block chain nodes participate in the voting activities, the block chain nodes can send targets voted by the intelligent contract.
Step S104: and the intelligent contract determines a second node from the at least one block chain node according to the sequence of the participation information submitted by the at least one block chain node.
In this embodiment of the present invention, the intelligent contract may determine the second node according to a preset target value and a sequence of submitting the participation information by the at least one block link point. The preset target value may be any one of the foregoing sequences, and preferably, in order to avoid traversing each block link point participating in the first service to search for the second node, thereby improving the efficiency of determining the second node, the preset target value may be the last one of the foregoing sequences. For example, there are 5 block link nodes participating in the first service, and the order of submitting participation information by the 5 block link nodes respectively is as follows: block chain node a, block link point D, block link point B, block link point E, and block link point F. If the preset target value is the last one in the sequence of submitting the participation information, the second node determined in this example is the block link point F. Of course, if the preset target value is the second in the order of submitting the participation information, the determined second node is the block link point D. Since it is not possible to predetermine which block chain nodes in the block chain will participate in the first service, and it is also not possible to predetermine the order in which each block chain node participates in the first service, the process of determining the second node according to the order in which each block chain node submits the participation information is not cheatable, thereby ensuring the randomness of the second node, and being beneficial to improving the reliability of the generated second random number.
Step S105: when the first service is finished, the first node submits the first random number to the intelligent contract.
When the first node is a blockchain node corresponding to the provider of the first service, the first node may automatically know the end time of the first service, and then the first node may be in the first serviceAfter the business is finished, actively submitting a first random number k to the intelligent contract1. When the first node is a node selected by voting or a block chain link point written in the intelligent contract in advance, after the first service is finished, the intelligent contract can send prompt information to the first node, so that the first node submits a first random number k to the intelligent contract according to the prompt information1
Step S106: and when the intelligent contract verifies that the first random number corresponds to the first abstract value, generating a second random number according to a second abstract value of the second node and the first random number.
In an embodiment of the present invention, the intelligent contract may determine whether the first digest value corresponds to the first random number by: the intelligent contract generates a third abstract value according to the first random number; wherein the algorithms for generating the first digest value and the third digest value are the same; when the third digest value is the same as the first digest value, determining that the first random number corresponds to the first digest value.
After the smart contract receives the first random number, the first random number k may be calculated1Corresponding third digest value h'1. It is worth mentioning that the first random number k is calculated1Corresponding third digest value h'1The algorithm is based on the first random number k1Calculating a first digest value h1The same algorithm is used. For example, the blockchain node locally calculates a first random number k through the sha256 algorithm1Corresponding first digest value h1Then, in the verification stage, the intelligent contract also calculates the first random number k by using the sha256 algorithm1Corresponding second digest value h'1. In order to facilitate the intelligent contract to check the received first digest value and the first random number, an algorithm for calculating the digest value corresponding to the first random number may be written into the intelligent contract in advance.
When the third abstract value is h'1And a first digest value h1When the two are the same, the intelligent contract can determine the first abstract value h1And a first random number k1Correspondingly, this indicates that the first node is not in the firstThe submission of the random number and the first digest value is cheated, the first random number is authentic, and the smart contract may generate a second random number based on the first random number and the second digest value of the second node. When the third abstract value is different from the first abstract value, the first random number is determined not to correspond to the first abstract value, and at the moment, the intelligent contract can send prompt information to the first node, so that the first node resends the first random number according to the prompt information, and the generation of a credible second random number is facilitated.
When generating the second random number, the second digest value and the first random number may be calculated according to a preset algorithm to generate the second random number. The preset algorithm may be an or operation, an and operation, or an xor operation. Preferably, the embodiment of the present invention performs an exclusive or operation on the first random number and the second digest value of the second node to generate the second random number. For example, when the second node is the last blockchain node submitting the participation information for the first service, the random number is generated according to the digest value of the blockchain node submitting the participation information last and the first random number submitted by the first node.
In addition, in order to prompt the determined first node to actively participate in the random number generation process, namely prompt the first node to send the first abstract value generated locally before the first service starts and send the first random number generated locally after the first service ends, in the embodiment of the invention, after the second random number is generated, the intelligent contract can send the virtual resource to the first node to reward the first node, so that the enthusiasm of the first node on the random number generation process is improved.
Step S107: and starting a second service according to the second random number.
It is to be understood that the generated trusted second random number may be applied to various services in the block chain, such as a private key generation service, a quiz-like service, a selection-like service, and the like. That is, multiple types of second services in the block chain, such as a generation service, a quiz service, and a selection service, may be initiated based on the trusted second random number. The types of the first service and the second service may be the same or different.
The embodiment of the invention takes the selection type service as an example to explain the application of the trusted second random number. Various selection services such as generation of a sports lottery or a welfare lottery and generation of a winner, selection of a winner from a plurality of bidders having the same condition at the time of bidding, selection of a winner in a variety of activities such as a company annual meeting, a promotion activity or a promotion activity, etc. can be realized by random numbers in the block chain.
When the selection service is started, at least one selection item respectively submitted by at least one block chain link point can be received; and starting a selection service to determine a target selection item from the selection items respectively submitted by the at least one block chain link point according to the second random number.
In this example, the selection item submitted by the block link point is the selection corresponding to the block link point, taking the selection of a winner in a company meeting as an example, the selection item corresponds to the job number or other identification corresponding to each employee, and in the process of determining the target selection item according to the second random number, since the second random number is credible, the selection process is random, human intervention is avoided, and therefore, the process of selecting the target selection item according to the second random number is random and fair. It will be appreciated that the block link point corresponding to the selected target option is the block link point corresponding to the winner.
To ensure that the award delivery process is publicly trusted, in one embodiment of the invention, virtual resources may be sent to the block link points that submit targeted selections via smart contracts to deliver the awards to the winners. Therefore, the reward issuing process is also carried out in the block chain, and the authenticity and the credibility of the reward issuing process are ensured.
According to the foregoing embodiment, as shown in fig. 2, a method for generating random numbers in a block chain according to an embodiment of the present invention may include the following steps:
step S201: generating a first random number locally by a first node in the blockchain and a first digest value of the first random number.
Step S202: the first node submits the first digest value to an intelligent contract.
Step S203: the intelligent contract broadcasts a first service to cause at least one block link point in the block chain to submit participation information regarding the first service.
Step S204: and the intelligent contract takes the last block chain link point submitting the participation information as a second node according to the sequence of submitting the participation information by the at least one block chain node.
Step S205: when the first service is finished, the first node submits the first random number to the intelligent contract.
Step S206: and when the intelligent contract verifies that the first random number corresponds to the first abstract value, calculating a second abstract value of the second node and the first random number according to exclusive-or operation to generate a second random number.
Step S207: and receiving at least one option submitted by the blockchain nodes respectively.
Step S208: and starting a selection service to determine a target selection item from the selection items respectively submitted by the at least one block chain link point according to the second random number.
Step S209: and sending the virtual resource to the block chain node submitting the target option.
According to the method for generating the random number in the block chain, disclosed by the embodiment of the invention, the first random number and the first abstract value of the first random number are generated locally by using the first node in the block chain, and then the first abstract value is submitted to the intelligent contract. After the intelligent contract broadcasts the first service, each block chain node can participate in the first service by submitting participation information, then the intelligent contract can determine a second node according to the sequence of the participation information submitted by each block chain node, and a second random number is generated by combining a second abstract value of the second node and the first random number submitted by the first node after the first service is finished. Since the sequence of each block chain link point participating in the first service cannot be determined in advance, that is, the sequence of each block chain link point participating in the first service is random, the process of determining the second node according to the sequence of submitting participation information by each block chain node cannot be cheated, and the randomness of the second node is ensured. In addition, the first abstract value submitted by the first node to the intelligent contract can be notified to each block chain node in the block chain, and the intelligent contract can also check the first abstract value and the first random number, so that the first abstract value submitted by the first node and the first random number submitted after the first service is finished can not be cheated. Therefore, the intelligent contract can not cheat according to the second abstract value of the second node and the first random number submitted by the first node, namely, the generation process of the second random number can not cheat, and therefore the reliability of the generated random number is improved. Furthermore, the second service is started according to the generated credible random number, so that the randomness of the result of the second service can be ensured, the possibility of cheating caused by human intervention is avoided, and the fairness of the service result is ensured.
Fig. 3 is a schematic diagram illustrating major blocks of an apparatus for generating random numbers in a block chain according to an embodiment of the present invention.
As shown in fig. 3, an apparatus 300 for generating random numbers in a block chain according to an embodiment of the present invention includes: a local generation module 301, a submission module 302, a first service module 303, a random number generation module 304 and a second service module 305; wherein the content of the first and second substances,
the local generation module 301 is configured to locally generate a first random number and a first digest value of the first random number by using a first node in the block chain;
the submitting module 302 is configured to submit the first digest value to an intelligent contract using the first node; submitting the first random number to the intelligent contract by using the first node when the first service is finished;
the first service module 303 is configured to broadcast a first service using the smart contract, so that at least one block link point in the block chain submits participation information about the first service;
the random number generation module 304 is configured to determine, by using the intelligent contract, a second node from the at least one blockchain node according to the order in which the participation information is submitted by the at least one blockchain node; when the intelligent contract verifies that the first random number corresponds to the first abstract value, generating a second random number according to a second abstract value of the second node and the first random number;
the second service module 305 is configured to start a second service according to the second random number.
In an embodiment of the present invention, the random number generating module 304 is configured to determine the second node according to a preset target value and a sequence of submitting the participation information by the at least one block link point.
In an embodiment of the present invention, the preset target value is the last one in the sequence.
In an embodiment of the present invention, the random number generation module 304 is configured to calculate the second digest value and the first random number according to a preset algorithm to generate the second random number.
In an embodiment of the present invention, the random number generation module 304 is configured to generate a third digest value according to the first random number by using the smart contract; wherein the algorithms for generating the first digest value and the third digest value are the same; when the third digest value is the same as the first digest value, determining that the first random number corresponds to the first digest value.
In an embodiment of the present invention, the local generation module 301 is configured to use a block link point corresponding to a provider of the first service as the first node.
In an embodiment of the present invention, the second service module 305 is further configured to send a virtual resource to the first node by using the intelligent contract.
In an embodiment of the present invention, the second service module 305 is configured to receive at least one option submitted by each of the blockchain nodes; and starting a selection service to determine a target selection item from the selection items respectively submitted by the at least one block chain link point according to the second random number.
In an embodiment of the present invention, the second service module 305 is further configured to send a virtual resource to a block link node submitting the target option.
According to the device for generating the random number in the blockchain, disclosed by the embodiment of the invention, the first random number and the first abstract value of the first random number are generated locally by using the first node in the blockchain, and then the first abstract value is submitted to the intelligent contract. After the intelligent contract broadcasts the first service, each block chain node can participate in the first service by submitting participation information, then the intelligent contract can determine a second node according to the sequence of the participation information submitted by each block chain node, and a second random number is generated by combining a second abstract value of the second node and the first random number submitted by the first node after the first service is finished. Since the sequence of each block chain link point participating in the first service cannot be determined in advance, that is, the sequence of each block chain link point participating in the first service is random, the process of determining the second node according to the sequence of submitting participation information by each block chain node cannot be cheated, and the randomness of the second node is ensured. In addition, the first abstract value submitted by the first node to the intelligent contract can be notified to each block chain node in the block chain, and the intelligent contract can also check the first abstract value and the first random number, so that the first abstract value submitted by the first node and the first random number submitted after the first service is finished can not be cheated. Therefore, the intelligent contract can not cheat according to the second abstract value of the second node and the first random number submitted by the first node, namely, the generation process of the second random number can not cheat, and therefore the reliability of the generated random number is improved. Furthermore, the second service is started according to the generated credible random number, so that the randomness of the result of the second service can be ensured, the possibility of cheating caused by human intervention is avoided, and the fairness of the service result is ensured.
Fig. 4 shows an exemplary system architecture 400 of a method for generating random numbers in a blockchain or an apparatus for generating random numbers in a blockchain, to which embodiments of the present invention can be applied.
As shown in fig. 4, the system architecture 400 may include terminal devices 401, 402, 403, a network 404, and a server 405. The network 404 serves as a medium for providing communication links between the terminal devices 401, 402, 403 and the server 405. Network 404 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use terminal devices 401, 402, 403 to interact with a server 405 over a network 404 to receive or send messages or the like. The terminal devices 401, 402, 403 may have various communication client applications installed thereon, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, and the like.
The terminal devices 401, 402, 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 405 may be a server that provides various services, such as a background management server that supports shopping websites browsed by users using the terminal devices 401, 402, and 403. The background management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (e.g., target push information and product information) to the terminal device.
It should be noted that the method for generating the random number in the block chain provided by the embodiment of the present invention is generally executed by the server 405, and accordingly, the device for generating the random number in the block chain is generally disposed in the server 405.
It should be understood that the number of terminal devices, networks, and servers in fig. 4 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 5, shown is a block diagram of a computer system 500 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU)501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 501.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a local generation module, a submission module, a first service module, a random number generation module, and a second service module. Where the names of these modules do not in some cases constitute a limitation on the module itself, for example, the random number generation module may also be described as a "module that generates a second random number".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: locally generating a first random number and a first digest value of the first random number by using a first node in the blockchain; the first node submits the first digest value to an intelligent contract; the intelligent contract broadcasts a first service so that at least one block link point in the block chain submits participation information about the first service; the intelligent contract determines a second node from the at least one block chain node according to the sequence of the participation information submitted by the at least one block chain node; when the first service is finished, the first node submits the first random number to the intelligent contract; when the intelligent contract verifies that the first random number corresponds to the first abstract value, generating a second random number according to a second abstract value of the second node and the first random number; and starting a second service according to the second random number.
According to the technical scheme of the embodiment of the invention, the first random number and the first abstract value of the first random number are generated locally by utilizing the first node in the block chain, and then the first abstract value is submitted to the intelligent contract. After the intelligent contract broadcasts the first service, each block chain node can participate in the first service by submitting participation information, then the intelligent contract can determine a second node according to the sequence of the participation information submitted by each block chain node, and a second random number is generated by combining a second abstract value of the second node and the first random number submitted by the first node after the first service is finished. Since the sequence of each block chain link point participating in the first service cannot be determined in advance, that is, the sequence of each block chain link point participating in the first service is random, the process of determining the second node according to the sequence of submitting participation information by each block chain node cannot be cheated, and the randomness of the second node is ensured. In addition, the first abstract value submitted by the first node to the intelligent contract can be notified to each block chain node in the block chain, and the intelligent contract can also check the first abstract value and the first random number, so that the first abstract value submitted by the first node and the first random number submitted after the first service is finished can not be cheated. Therefore, the intelligent contract can not cheat according to the second abstract value of the second node and the first random number submitted by the first node, namely, the generation process of the second random number can not cheat, and therefore the reliability of the generated random number is improved. Furthermore, the second service is started according to the generated credible random number, so that the randomness of the result of the second service can be ensured, the possibility of cheating caused by human intervention is avoided, and the fairness of the service result is ensured.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (20)

1. A method for generating random numbers in a block chain is characterized by comprising the following steps:
locally generating a first random number and a first digest value of the first random number by using a first node in the blockchain;
the first node submits the first digest value to an intelligent contract;
the intelligent contract broadcasts a first service so that at least one block link point in the block chain submits participation information about the first service;
the intelligent contract determines a second node from the at least one block chain node according to the sequence of the participation information submitted by the at least one block chain node;
when the first service is finished, the first node submits the first random number to the intelligent contract;
when the intelligent contract verifies that the first random number corresponds to the first abstract value, generating a second random number according to a second abstract value of the second node and the first random number;
and starting a second service according to the second random number.
2. The method of claim 1, wherein determining the second node from the at least one blockchain node comprises:
and determining the second node according to a preset target value and the sequence of submitting the participation information by the at least one block link point.
3. The method of claim 2,
the preset target value is the last one in the sequence.
4. The method of claim 1,
and calculating the second abstract value and the first random number according to a preset algorithm to generate the second random number.
5. The method of claim 1,
the intelligent contract generates a third abstract value according to the first random number; wherein the algorithms for generating the first digest value and the third digest value are the same;
when the third digest value is the same as the first digest value, determining that the first random number corresponds to the first digest value.
6. The method of claim 1,
and taking the block link point corresponding to the provider of the first service as the first node.
7. The method of claim 1, after generating the second random number, further comprising:
the intelligent contract sends virtual resources to the first node.
8. The method of claim 1, wherein the initiating a second service according to the second random number comprises:
receiving at least one option submitted by the blockchain nodes respectively;
and starting a selection service to determine a target selection item from the selection items respectively submitted by the at least one block chain link point according to the second random number.
9. The method of claim 8, further comprising:
and sending the virtual resource to the block chain node submitting the target option.
10. An apparatus for generating random numbers in a block chain, comprising: the system comprises a local generation module, a submission module, a first service module, a random number generation module and a second service module; wherein the content of the first and second substances,
the local generation module is configured to locally generate a first random number and a first digest value of the first random number by using a first node in the block chain;
the submitting module is used for submitting the first abstract value to the intelligent contract by using the first node; submitting the first random number to the intelligent contract by using the first node when the first service is finished;
the first service module is used for broadcasting a first service by using the intelligent contract so as to enable at least one block link point in the block chain to submit participation information about the first service;
the random number generation module is used for determining a second node from the at least one block chain node according to the sequence of the participation information submitted by the at least one block chain node by using the intelligent contract; when the intelligent contract verifies that the first random number corresponds to the first abstract value, generating a second random number according to a second abstract value of the second node and the first random number;
and the second service module is used for starting a second service according to the second random number.
11. The apparatus of claim 10,
and the random number generation module is used for determining the second node according to a preset target value and the sequence of submitting the participation information by the at least one block chain node.
12. The apparatus of claim 11,
the preset target value is the last one in the sequence.
13. The apparatus of claim 10,
and the random number generation module is used for calculating the second abstract value and the first random number according to a preset algorithm so as to generate the second random number.
14. The apparatus of claim 10,
the random number generation module is used for generating a third abstract value according to the first random number by using the intelligent contract; wherein the algorithms for generating the first digest value and the third digest value are the same; when the third digest value is the same as the first digest value, determining that the first random number corresponds to the first digest value.
15. The apparatus of claim 10,
the local generation module is configured to use a block link point corresponding to the provider of the first service as the first node.
16. The apparatus of claim 10,
the second service module is further configured to send a virtual resource to the first node by using the intelligent contract.
17. The apparatus of claim 10,
the second service module is configured to receive options respectively submitted by at least one of the blockchain nodes; and starting a selection service to determine a target selection item from the selection items respectively submitted by the at least one block chain link point according to the second random number.
18. The apparatus of claim 17,
the second service module is further configured to send a virtual resource to the block link node submitting the target option.
19. An electronic device for generating random numbers in a block chain, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-9.
20. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-9.
CN202110233212.4A 2021-03-03 2021-03-03 Method and device for generating random number in block chain Active CN112968769B (en)

Priority Applications (3)

Application Number Priority Date Filing Date Title
CN202110233212.4A CN112968769B (en) 2021-03-03 2021-03-03 Method and device for generating random number in block chain
EP22762599.3A EP4304131A1 (en) 2021-03-03 2022-03-03 Method and apparatus for generating random numbers in blockchain
PCT/CN2022/079062 WO2022184137A1 (en) 2021-03-03 2022-03-03 Method and apparatus for generating random numbers in blockchain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110233212.4A CN112968769B (en) 2021-03-03 2021-03-03 Method and device for generating random number in block chain

Publications (2)

Publication Number Publication Date
CN112968769A true CN112968769A (en) 2021-06-15
CN112968769B CN112968769B (en) 2023-04-07

Family

ID=76276779

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110233212.4A Active CN112968769B (en) 2021-03-03 2021-03-03 Method and device for generating random number in block chain

Country Status (1)

Country Link
CN (1) CN112968769B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022184137A1 (en) * 2021-03-03 2022-09-09 中国人民银行数字货币研究所 Method and apparatus for generating random numbers in blockchain

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110135909A (en) * 2019-05-15 2019-08-16 山东工商学院 Data processing method, system, equipment and storage medium based on zero-knowledge proof
US20190327084A1 (en) * 2018-04-19 2019-10-24 Electronics And Telecommunications Research Institute Method for selecting consensus node using nonce and method and apparatus for generating blockchain using the same
CN110430045A (en) * 2019-07-17 2019-11-08 上海朝夕网络技术有限公司 A kind of random digit generation method based on distributed common recognition algorithm
CN111223227A (en) * 2018-11-26 2020-06-02 腾讯科技(深圳)有限公司 Target user screening method and device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190327084A1 (en) * 2018-04-19 2019-10-24 Electronics And Telecommunications Research Institute Method for selecting consensus node using nonce and method and apparatus for generating blockchain using the same
CN111223227A (en) * 2018-11-26 2020-06-02 腾讯科技(深圳)有限公司 Target user screening method and device
CN110135909A (en) * 2019-05-15 2019-08-16 山东工商学院 Data processing method, system, equipment and storage medium based on zero-knowledge proof
CN110430045A (en) * 2019-07-17 2019-11-08 上海朝夕网络技术有限公司 A kind of random digit generation method based on distributed common recognition algorithm

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022184137A1 (en) * 2021-03-03 2022-09-09 中国人民银行数字货币研究所 Method and apparatus for generating random numbers in blockchain

Also Published As

Publication number Publication date
CN112968769B (en) 2023-04-07

Similar Documents

Publication Publication Date Title
CN108984784B (en) Application implementation method, device, equipment and storage medium based on block chain network
US20220138737A1 (en) Computer-implemented systems and methods for implementing transfers over a blockchain network
US20220239496A1 (en) Blockchain consensus method, device and system
US20220284469A1 (en) Verifying ad requests
US9210201B2 (en) Cross social network data aggregation
JP2020144838A (en) Business process system, business data processing method and device
CN112968769B (en) Method and device for generating random number in block chain
CN108449186B (en) Security verification method and device
CN114945932A (en) Feedback controller using secret sharing
CN114331397A (en) Information processing method, device, electronic equipment and storage medium
CN112910643B (en) Method and device for generating random number in block chain
CN108564406B (en) Incentive pushing method and device
CN113873004B (en) Task execution method and device and distributed computing system
CN112995932B (en) Short message link monitoring method, device, equipment and medium based on Hash algorithm
US20240146509A1 (en) Method and Apparatus for Generating Random Number in Blockchain
KR20190130377A (en) Network server mediating game item transaction between user terminals and method of operating thereof
EP4304131A1 (en) Method and apparatus for generating random numbers in blockchain
CN114328731A (en) Information processing method, device, electronic equipment and storage medium
CN111144977B (en) Stock order processing method and device
CN111093281B (en) Method and device for allocating resources
CN113283850A (en) Task auditing method, device and system
CN111786936A (en) Method and device for authentication
CN111815381A (en) Information generation method and device
CN110875950B (en) Method and equipment for allocating resources and drawing resources
CN111131355B (en) Method and apparatus for processing information

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant