CN111443894A - Random number generation method, device and medium based on block chain - Google Patents

Random number generation method, device and medium based on block chain Download PDF

Info

Publication number
CN111443894A
CN111443894A CN202010124861.6A CN202010124861A CN111443894A CN 111443894 A CN111443894 A CN 111443894A CN 202010124861 A CN202010124861 A CN 202010124861A CN 111443894 A CN111443894 A CN 111443894A
Authority
CN
China
Prior art keywords
random
block chain
node
random number
sent
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.)
Pending
Application number
CN202010124861.6A
Other languages
Chinese (zh)
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.)
Shandong Inspur Quality Chain Technology Co Ltd
Original Assignee
Shandong ICity Information Technology Co., Ltd.
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 Shandong ICity Information Technology Co., Ltd. filed Critical Shandong ICity Information Technology Co., Ltd.
Priority to CN202010124861.6A priority Critical patent/CN111443894A/en
Publication of CN111443894A publication Critical patent/CN111443894A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/58Random or pseudo-random number generators
    • G06F7/588Random number generators, i.e. based on natural stochastic processes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Abstract

The application discloses a random number generation method, equipment and medium based on a block chain, wherein the method comprises the following steps: determining a plurality of random sources of random numbers through intelligent contracts on the blockchains; and connecting the multiple random sources to obtain a hash value, and generating a random number by using the hash value. Firstly, the problem that random numbers generated by each node when executing contracts are inconsistent when the random numbers are generated in an intelligent contract is solved; secondly, the random number can be easily verified according to the parameters, so that traceability and enquiry in the following cases when problems occur are ensured; and finally, before generating the random number, the random source cannot be speculated, so that the objectivity is ensured.

Description

Random number generation method, device and medium based on block chain
Technical Field
The present application relates to the field of block chain technologies, and in particular, to a block chain-based random number generation method, device, and medium.
Background
In the block chain, since there are many nodes, the throughput of information is easy to reach the upper limit, and when a random number is generated in an intelligent contract, the random numbers generated when each node executes the contract are different, and the random numbers cannot be agreed when the nodes agree with each other.
Disclosure of Invention
An embodiment of the present specification provides a block chain-based random number generation method, device, and medium, which are used to solve the following technical problems in the prior art:
the number of nodes in the block chain is large, and when the information reaches the upper limit of the throughput, the information cannot be transmitted in time.
The embodiment of the specification adopts the following technical scheme:
a first aspect of an embodiment of the present invention provides a block chain-based random number generation method, including:
determining a plurality of random sources of random numbers through intelligent contracts on the blockchains;
and connecting the multiple random sources to obtain a hash value, and generating a random number by using the hash value.
In one example, the determining, by the intelligent contracts on the blockchain, a plurality of random sources of random numbers includes:
and comparing the time stamp obtained by the intelligent contract with the time stamp sent by the node of the block chain to determine whether the time stamp sent by the node of the block chain is legal or not.
In one example, the comparing the timestamp obtained by the intelligent contract with the timestamp sent by the node of the blockchain includes:
and comparing the time difference between the time stamp obtained by the intelligent contract and the time stamp sent by the node of the block chain with a preset threshold value.
In one example, the determining, by the intelligent contracts on the blockchain, a plurality of random sources of random numbers includes:
receiving a transaction hash sent by a node of the blockchain, determining whether the transaction hash is legal according to whether a timestamp sent by the node of the blockchain is legal, wherein,
the timestamp and transaction hash sent by the nodes of the blockchain are sent together.
In one example, the preset threshold is no greater than 2000 milliseconds.
In one example, the concatenating the multiple random sources to obtain the hash value includes:
and sequentially connecting the time stamp sent by the node of the block chain with the transaction hash to obtain the hash value.
In one example, the nodes of the blockchain include at least a lottery issuing center.
In one example, further comprising:
and taking the node generating the random number as a consensus node to perform consensus when the information throughput of the block chain reaches a threshold value.
A second aspect of an embodiment of the present invention provides a block chain-based random number generation device, including:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
determining a plurality of random sources of random numbers through intelligent contracts on the blockchains;
and connecting the multiple random sources to obtain a hash value, and generating a random number by using the hash value.
A third aspect of an embodiment of the present invention provides a block chain-based random number nonvolatile computer storage medium, in which computer-executable instructions are stored, where the computer-executable instructions are configured to:
determining a plurality of random sources of random numbers through intelligent contracts on the blockchains;
and connecting the multiple random sources to obtain a hash value, and generating a random number by using the hash value.
The embodiment of the specification adopts at least one technical scheme which can achieve the following beneficial effects:
firstly, the problem that random numbers generated by each node when executing contracts are inconsistent when the random numbers are generated in an intelligent contract is solved; secondly, the random number can be easily verified according to the parameters, so that traceability and enquiry in the following cases when problems occur are ensured; and finally, before generating the random number, the random source cannot be speculated, so that the objectivity is ensured.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
FIG. 1 is a schematic flow chart of a method provided by embodiments of the present disclosure;
fig. 2 is a schematic diagram of an apparatus framework provided in an embodiment of the present disclosure.
Detailed Description
In order to make the objects, technical solutions and advantages of the present disclosure more apparent, the technical solutions of the present disclosure will be clearly and completely described below with reference to the specific embodiments of the present disclosure and the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments obtained by a person skilled in the art without making any inventive step based on the embodiments in the description belong to the protection scope of the present application.
The technical solutions provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.
On the internet, the number of messages sent in a certain period of time is limited (i.e., throughput), and it takes a certain amount of time (i.e., delay) to send the messages, which imposes a certain limit on the consensus. The goal of any blockchain consensus protocol is to achieve an agreement within the above-mentioned limits. Thousands of nodes on a public chain participate in the maintenance of blockchains, and if each node needs to send messages to all other nodes and get their feedback, the limitations of the network can add significantly to the cost of reaching a consensus. This is because the number of messages sent over the network in a round of time is too large. Therefore, some nodes need to be selected for consensus, and the technical scheme of the application is designed based on the nodes.
The embodiment of the application provides a random number generation method based on a block chain and a corresponding scheme, and firstly, the problem that the random numbers generated by nodes when executing contracts are inconsistent when the random numbers are generated in an intelligent contract is solved; secondly, the random number can be easily verified according to the parameters, so that traceability and enquiry in the following cases when problems occur are ensured; and finally, before generating the random number, the random source cannot be speculated, so that the objectivity is ensured.
Fig. 1 is a schematic flow chart of a method provided in an embodiment of the present disclosure. As shown, the method comprises:
s101, determining various random sources of random numbers through intelligent contracts on the block chains;
s102, connecting the random sources to obtain a hash value, and generating a random number by using the hash value.
The block chain is a chain data structure formed by combining data blocks in a sequential connection mode according to a time sequence, and is a distributed account book which is guaranteed in a cryptographic mode and cannot be tampered and forged. Although the underlying technology of blockchains has been developed for many years, it has not been possible to achieve effective application in a particular scenario.
According to the embodiment of the invention, in step S101, an intelligent contract for managing random numbers is set on the blockchain, and the intelligent contract is an automatically running script deployed on the blockchain and has a transparent characteristic due to being set on the blockchain. A user presets rules through an intelligent contract so as to write data into a block chain and acquire data browsing permission, and disclosure of privacy information is avoided to a great extent. Of course, the smart contracts are not the only implementation manner of the present application, and are set correspondingly according to different blockchain platforms, such as an ethernet house, a super book, and the like.
According to a specific embodiment of the present invention, the determining, by the intelligent contract on the blockchain, the plurality of random sources of the random number includes: and comparing the time stamp obtained by the intelligent contract with the time stamp sent by the node of the block chain to determine whether the time stamp sent by the node of the block chain is legal or not.
Specifically, the comparing the timestamp acquired by the intelligent contract with the timestamp sent by the node of the blockchain includes: and comparing the time difference between the time stamp obtained by the intelligent contract and the time stamp sent by the node of the block chain with a preset threshold value.
According to a specific embodiment of the present invention, the determining, by the intelligent contract on the blockchain, the plurality of random sources of the random number includes: and receiving the transaction hash sent by the node of the block chain, and determining whether the transaction hash is legal according to whether the timestamp sent by the node of the block chain is legal, wherein the timestamp sent by the node of the block chain and the transaction hash are sent together.
Preferably, the preset threshold is not greater than 2000 milliseconds. The random source for generating the random number is composed of a millisecond timestamp of the current time (the time of the client of the node of the block chain) transmitted from the contract and a transaction hash of the transaction, the incoming timestamp is compared with the timestamp acquired at the present time of the contract in the contract, and if the difference is within 2000 milliseconds, the timestamp is considered to be legal.
According to a specific embodiment of the present invention, the connecting the multiple random sources to obtain the hash value includes: and sequentially connecting the time stamp sent by the node of the block chain with the transaction hash to obtain the hash value.
According to the specific embodiment of the present invention, the setting of the nodes of the block chain is not particularly limited, and the nodes of the block chain at least include a lottery issuing center, but may also be some departments that need objective random numbers, such as quality sampling inspection, and the like.
According to a specific embodiment of the present invention, the method provided by the embodiment of the present invention further includes: and taking the node generating the random number as a consensus node to perform consensus when the information throughput of the block chain reaches a threshold value. And detecting the state of information sent by the nodes of the block chain through the intelligent contract, thereby determining the nodes capable of realizing consensus.
Based on the same idea, some embodiments of the present application further provide a device and a non-volatile computer storage medium corresponding to the above method.
Fig. 2 is a schematic diagram of an apparatus framework provided in an embodiment of this specification, and a block chain-based random number generation apparatus includes:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
determining a plurality of random sources of random numbers through intelligent contracts on the blockchains;
and connecting the multiple random sources to obtain a hash value, and generating a random number by using the hash value.
Some embodiments of the present application provide a non-volatile computer storage medium corresponding to fig. 1 for block chain based random number generation, storing computer-executable instructions configured to:
determining a plurality of random sources of random numbers through intelligent contracts on the blockchains;
and connecting the multiple random sources to obtain a hash value, and generating a random number by using the hash value.
In summary, the technical scheme of the invention firstly solves the problem that the random numbers generated by each node when executing the contract are inconsistent when the random numbers are generated in the intelligent contract; secondly, the random number can be easily verified according to the parameters, so that traceability and enquiry in the following cases when problems occur are ensured; and finally, before generating the random number, the random source cannot be speculated, so that the objectivity is ensured.
The embodiments in the present application are described in a progressive manner, and the same and similar parts among the embodiments can be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the device and media embodiments, the description is relatively simple as it is substantially similar to the method embodiments, and reference may be made to some descriptions of the method embodiments for relevant points.
The device and the medium provided by the embodiment of the application correspond to the method one to one, so the device and the medium also have the similar beneficial technical effects as the corresponding method, and the beneficial technical effects of the method are explained in detail above, so the beneficial technical effects of the device and the medium are not repeated herein.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is directed to methods, apparatus (systems), and computer program products according to embodiments of the present invention
A flowchart and/or block diagram of an article. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (10)

1. A block chain-based random number generation method is characterized by comprising the following steps:
determining a plurality of random sources of random numbers through intelligent contracts on the blockchains;
and connecting the multiple random sources to obtain a hash value, and generating a random number by using the hash value.
2. The method of claim 1, wherein determining the plurality of random sources of random numbers by the intelligent contracts on the blockchains comprises:
and comparing the time stamp obtained by the intelligent contract with the time stamp sent by the node of the block chain to determine whether the time stamp sent by the node of the block chain is legal or not.
3. The method of claim 2, wherein comparing the timestamp obtained by the smart contract with the timestamp sent by the node of the blockchain comprises:
and comparing the time difference between the time stamp obtained by the intelligent contract and the time stamp sent by the node of the block chain with a preset threshold value.
4. The method of claim 3, wherein determining the plurality of random sources of random numbers by the intelligent contracts on the blockchains comprises:
receiving a transaction hash sent by a node of the blockchain, determining whether the transaction hash is legal according to whether a timestamp sent by the node of the blockchain is legal, wherein,
the timestamp and transaction hash sent by the nodes of the blockchain are sent together.
5. The method of claim 3, wherein the preset threshold is no greater than 2000 milliseconds.
6. The method according to claim 4, wherein the concatenating the plurality of random sources to obtain the hash value comprises:
and sequentially connecting the time stamp sent by the node of the block chain with the transaction hash to obtain the hash value.
7. The method of claim 1, wherein the nodes of the blockchain comprise at least a lottery distribution center.
8. The method of claim 1, further comprising:
and taking the node generating the random number as a consensus node to perform consensus when the information throughput of the block chain reaches a threshold value.
9. A block chain-based random number generation device, comprising:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
determining a plurality of random sources of random numbers through intelligent contracts on the blockchains;
and connecting the multiple random sources to obtain a hash value, and generating a random number by using the hash value.
10. A non-volatile computer storage medium for block chain based random numbers, storing computer-executable instructions, the computer-executable instructions configured to:
determining a plurality of random sources of random numbers through intelligent contracts on the blockchains;
and connecting the multiple random sources to obtain a hash value, and generating a random number by using the hash value.
CN202010124861.6A 2020-02-27 2020-02-27 Random number generation method, device and medium based on block chain Pending CN111443894A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010124861.6A CN111443894A (en) 2020-02-27 2020-02-27 Random number generation method, device and medium based on block chain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010124861.6A CN111443894A (en) 2020-02-27 2020-02-27 Random number generation method, device and medium based on block chain

Publications (1)

Publication Number Publication Date
CN111443894A true CN111443894A (en) 2020-07-24

Family

ID=71648840

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010124861.6A Pending CN111443894A (en) 2020-02-27 2020-02-27 Random number generation method, device and medium based on block chain

Country Status (1)

Country Link
CN (1) CN111443894A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112631551A (en) * 2020-12-29 2021-04-09 平安科技(深圳)有限公司 Random number generation method and device, electronic equipment and storage medium
CN112751846A (en) * 2020-12-28 2021-05-04 杭州趣链科技有限公司 Block chain-based electronic game random reward control method, device and equipment
CN114338051A (en) * 2022-03-15 2022-04-12 北京百度网讯科技有限公司 Method, device, equipment and medium for acquiring random number by block chain

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112751846A (en) * 2020-12-28 2021-05-04 杭州趣链科技有限公司 Block chain-based electronic game random reward control method, device and equipment
CN112631551A (en) * 2020-12-29 2021-04-09 平安科技(深圳)有限公司 Random number generation method and device, electronic equipment and storage medium
CN112631551B (en) * 2020-12-29 2023-05-30 平安科技(深圳)有限公司 Random number generation method, device, electronic equipment and storage medium
CN114338051A (en) * 2022-03-15 2022-04-12 北京百度网讯科技有限公司 Method, device, equipment and medium for acquiring random number by block chain

Similar Documents

Publication Publication Date Title
CN108053211B (en) Transaction processing method and device based on block chain
CN111443894A (en) Random number generation method, device and medium based on block chain
CN111415170A (en) Block chain-based food tracing method and equipment and related storage medium
CN111967610A (en) Block chain-based federal learning incentive method, device, equipment and storage medium
CN108985742A (en) Transaction processing method, device and block catenary system
CN110930578A (en) Voting method, equipment and medium based on block chain
CN111930497A (en) Resource allocation method, device and medium based on block chain and static code
CN105224541B (en) Uniqueness control method, information storage means and the device of data
CN111199350A (en) Block chain-based supervision and spot check method, equipment and medium
CN112967119A (en) Bidding method, device and medium based on block chain
CN111756803A (en) Server-side pushing method, equipment and medium based on block chain technology
CN111125802A (en) Method, device and medium for managing non-material cultural heritage information based on block chain
CN111008404A (en) Service call auditing method, equipment and medium based on block chain
CN111091353A (en) Loving public interest management method, equipment and medium based on block chain
CN111131474A (en) Method, device and medium for managing user protocol based on block chain
CN111125115A (en) Data storage method, device and medium based on block chain
CN111639998A (en) Method, device and medium for guaranteeing user deposit rights and interests based on block chain
CN112035156A (en) E-commerce platform docking device, method, equipment and medium
CN111679853A (en) Open source software publishing method and device, computer equipment and readable storage medium
CN111126959A (en) Block chain-based movie content management method, device and medium
CN110990889A (en) Method, equipment and medium based on block chain notarization prenuptial property
CN111010424A (en) Block chain-based network voting method, equipment and medium
CN114491662A (en) Block chain-based data asset auditing method, system and equipment
CN111709057A (en) Method, equipment and storage medium for tracing pesticide residue based on block chain
CN111008862A (en) Survey questionnaire information acquisition method, device and medium based on block chain

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20200814

Address after: Room 1-2301, Building 7, North District, Shandong Design and Creative Industry Park, No. 868 Tangye West Road, Licheng District, Jinan City, Shandong Province, 250102

Applicant after: SHANDONG INSPUR QUALINK TECHNOLOGY Co.,Ltd.

Address before: Room 3110, S01 building, Langchao building, No. 1036, Langchao Road, high tech Zone, Jinan City, Shandong Province 250101

Applicant before: Shandong Aicheng Network Information Technology Co.,Ltd.

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination