CN110515591A - Random digit generation method and device based on block chain - Google Patents

Random digit generation method and device based on block chain Download PDF

Info

Publication number
CN110515591A
CN110515591A CN201910716527.7A CN201910716527A CN110515591A CN 110515591 A CN110515591 A CN 110515591A CN 201910716527 A CN201910716527 A CN 201910716527A CN 110515591 A CN110515591 A CN 110515591A
Authority
CN
China
Prior art keywords
block
cryptographic hash
random number
subsequent
algorithm
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
CN201910716527.7A
Other languages
Chinese (zh)
Other versions
CN110515591B (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.)
Hunan Tianhe Guoyun Technology Co Ltd
Original Assignee
Hunan Tianhe Guoyun 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 Hunan Tianhe Guoyun Technology Co Ltd filed Critical Hunan Tianhe Guoyun Technology Co Ltd
Priority to CN201910716527.7A priority Critical patent/CN110515591B/en
Publication of CN110515591A publication Critical patent/CN110515591A/en
Application granted granted Critical
Publication of CN110515591B publication Critical patent/CN110515591B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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
    • 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

Abstract

The embodiment of the invention provides a kind of generating random number and device based on block chain, which comprises obtain the block cryptographic Hash of subsequent multiple blocks of current block;The current block is newest block when occurring with random number event to be dealt with;Polymerization processing is carried out to the block cryptographic Hash of subsequent multiple blocks, obtains polymerization processing result;Operation is carried out to the polymerization processing result by secure hash algorithm and exclusive or algorithm, generates the random number.Through the embodiment of the present invention, the randomness and safety of random number generated be can be improved.

Description

Random digit generation method and device based on block chain
Technical field
The invention belongs to block chain technical field, be specifically related to a kind of random digit generation method based on block chain, Device, terminal device and computer-readable medium.
Background technique
Block chain is the novel of the computer technologies such as Distributed Storage, point-to-point transmission, common recognition mechanism, Encryption Algorithm Application model.It is substantially the database of a decentralization, is a string using the associated data generated of cryptography method Block contains the information of a batch network trading in each data block, for verifying the validity (anti-fake) of its information and raw At next block.For narrow sense, block chain is that one kind sequentially in time combines data block in such a way that sequence is connected At a kind of linked data structure, and the distributed account book that can not be distorted He can not forge guaranteed in a manner of cryptography.Broad sense For, block chain technology be verified using block linked data structure with storing data, using distributed node know together algorithm come It generates and guarantees the safety of data transmission and access with more new data, in the way of cryptography, using by automatized script code The intelligent contract of composition programs the completely new distributed basis framework and calculation of one kind with operation data.
It is continuous universal and fast-developing with block chain technology, in the application of block chain increasingly for the use of random number Frequently and extensively.Existing method often uses history block data or external data as random number source.Using historical data There is predictability as former data, and using external data as former data equally has foreseeability and controllability, adds Existing random number algorithm is not safe enough, thus random number caused by the prior art does not have enough randomness and safety. Random number loophole leads to huge economic loss often by hacker as attack back door.
Summary of the invention
In view of this, the embodiment of the present invention provides a kind of random digit generation method based on block chain, device, terminal device And computer-readable medium, it can be improved the randomness and safety of random number generated.
The first aspect of the embodiment of the present invention provides a kind of random digit generation method based on block chain, comprising:
Obtain the block cryptographic Hash of subsequent multiple blocks of current block;The current block is with the random number institute Event to be processed newest block when occurring;
Polymerization processing is carried out to the block cryptographic Hash of subsequent multiple blocks, obtains polymerization processing result;
Operation is carried out to the polymerization processing result by secure hash algorithm and exclusive or algorithm, generates the random number.
The second aspect of the embodiment of the present invention provides a kind of random digit generation method based on block chain, comprising:
Obtain the block cryptographic Hash of subsequent n-th of block of current block;The current block is to use the random number Event to be dealt with newest block when occurring;
Operation is carried out to the block cryptographic Hash of subsequent n-th of block by secure hash algorithm and exclusive or algorithm, it is raw At the random number.
The third aspect of the embodiment of the present invention provides a kind of generating random number device based on block chain, comprising:
First obtains module, the block cryptographic Hash of subsequent multiple blocks for obtaining current block;The current block Newest block when to occur with random number event to be dealt with;
Aggregation module carries out polymerization processing for the block cryptographic Hash to subsequent multiple blocks, obtains polymerization processing As a result;
First generation module, for being transported by secure hash algorithm and exclusive or algorithm to the polymerization processing result It calculates, generates the random number.
The fourth aspect of the embodiment of the present invention provides a kind of generating random number device based on block chain, comprising:
Second obtains module, the block cryptographic Hash of subsequent n-th of block for obtaining current block;The current block Newest block when to occur with random number event to be dealt with;
Second generation module, for passing through secure hash algorithm and exclusive or algorithm to the block of subsequent n-th of block Cryptographic Hash carries out operation, generates the random number.
5th method of the embodiment of the present invention provides a kind of terminal device, including memory, processor and is stored in In the memory and the computer program that can run on the processor, when the processor executes the computer program The step of realizing the above-mentioned random digit generation method based on block chain.
6th aspect of the embodiment of the present invention provides a kind of computer-readable medium, the computer-readable medium storage There is a computer program, when computer program execution processed realizes the step of the above-mentioned random digit generation method based on block chain Suddenly.
Random digit generation method provided in an embodiment of the present invention based on block chain, can be by obtaining the subsequent of current block The block cryptographic Hash of multiple blocks is based on getting these Future Data (blocks of i.e. following multiple blocks as former data Cryptographic Hash) polymerization processing is carried out, polymerization processing result is done into further secure hash operation and XOR operation, is obtained final Random number, so that the randomness and safety of random number generated can be improved.
Detailed description of the invention
It to describe the technical solutions in the embodiments of the present invention more clearly, below will be to embodiment or description of the prior art Needed in attached drawing be briefly described, it should be apparent that, the accompanying drawings in the following description is only of the invention some Embodiment for those of ordinary skill in the art without any creative labor, can also be according to these Attached drawing obtains other attached drawings.
Fig. 1 is a kind of flow chart of random digit generation method based on block chain provided in an embodiment of the present invention;
Fig. 2 is the flow chart of another random digit generation method based on block chain provided in an embodiment of the present invention;
Fig. 3 is a kind of structural schematic diagram of generating random number device based on block chain provided in an embodiment of the present invention;
Fig. 4 is the refinement of the first generation module in the generating random number device based on block chain that Fig. 3 embodiment provides Structural schematic diagram;
Fig. 5 is the structural schematic diagram of another generating random number device based on block chain provided in an embodiment of the present invention;
Fig. 6 is the schematic diagram of terminal device provided in an embodiment of the present invention.
Specific embodiment
In being described below, for illustration and not for limitation, the tool of such as particular system structure, technology etc is proposed Body details, to understand thoroughly the embodiment of the present invention.However, it will be clear to one skilled in the art that there is no these specific The present invention also may be implemented in the other embodiments of details.In other situations, it omits to well-known system, device, electricity The detailed description of road and method, in case unnecessary details interferes description of the invention.
In order to illustrate technical solutions according to the invention, the following is a description of specific embodiments.
Referring to Fig. 1, Fig. 1 is a kind of random digit generation method based on block chain provided in an embodiment of the present invention.Such as Fig. 1 It is shown, the random digit generation method based on block chain of the present embodiment the following steps are included:
S101: the block cryptographic Hash of subsequent multiple blocks of current block is obtained.
In embodiments of the present invention, the data source about random number to be generated can obtain the subsequent multiple of current block The block cryptographic Hash of block, the data source as random number to be generated;The current block is is wanted with the random number The event of processing newest block when occurring, therefore, the block information of subsequent multiple blocks are relative to the thing The Future Data at the generation moment of part.The acquisition of block cryptographic Hash about subsequent multiple blocks, can be read block height For the block information of the block of H+1 to H+n, and the area that the block height is H+1 to H+n is obtained from the block information The block cryptographic Hash of block.Wherein, the block height of the current block is H, and n is the quantity of subsequent multiple blocks, and n can be with Value is, for example, 10.The block height is that the block cryptographic Hash of the block of H+1 to H+n can be saved successively into array.Into One step, the block information for the block that block height is H+1 can be first read, and from the block information for the block that height is H+1 The block cryptographic Hash for the block that height is H+1 is obtained, and is saved accordingly;The block for being H+2 in reading block height Block information, and the block cryptographic Hash for the block that acquisition height is H+2 from the block information for the block that height is H+2, go forward side by side Row is corresponding to be saved;And so on, until obtaining the block cryptographic Hash for the block that height is H+n.In addition, obtaining current block Subsequent multiple blocks block cryptographic Hash before, the value range of the settable random number is 0 to arrive K-1, while recording institute State the block height H of current block.
S102: carrying out polymerization processing to the block cryptographic Hash of subsequent multiple blocks, obtains polymerization processing result.
In embodiments of the present invention, by the cryptographic Hash of subsequent 1st block of the current block and an empty Kazakhstan Uncommon value does XOR operation, obtains the 1st wheel polymerization result;For example, it is assumed that the cryptographic Hash of subsequent 1st block of the current block It is 101010 ..., and the cryptographic Hash of the sky is 000000 ..., then the 1st wheel polymerization result is 101010 ....It then, can will be described The cryptographic Hash of subsequent 2nd block of current block and the 1st wheel polymerization result do XOR operation, obtain the 2nd wheel polymerization knot Fruit;And so on, the cryptographic Hash of subsequent n-th of block of the current block and the (n-1)th wheel polymerization result are done into XOR operation, Obtain the n-th wheel polymerization result;N is the quantity of subsequent multiple blocks, and the n-th wheel polymerization result is to described subsequent multiple The block cryptographic Hash of block carries out polymerizeing processing result obtained from polymerization processing, i.e., final polymerization processing result.More specifically Ground can initialize two buffers, and the i-th wheel is polymerize, after first buffer (cache 1) receives the current block The cryptographic Hash of continuous i-th of block, second buffer (cache 2) is to store the (i-1)-th wheel polymerization result, by i-th of block Cryptographic Hash carry out XOR operation with the (i-1)-th wheel polymerization result, obtain the i-th wheel polymerization result, the i-th wheel polymerization result can store with In second buffer, calculated for participating in next round.
S103: carrying out operation to the polymerization processing result by secure hash algorithm and exclusive or algorithm, generate it is described with Machine number.
In embodiments of the present invention, secure hash algorithm (for example, secure hash algorithm 2, abbreviation SHA2 algorithm) can be used Operation is carried out to the polymerization processing result, obtains the cryptographic Hash M of the polymerization processing result, then by the polymerization processing result First 128 of cryptographic Hash M and rear 128 progress XOR operation obtain operation result m (m is 128 unsigned ints), finally M can be made to K modulus, generate the random number;Wherein, the preset value range of the random number is 0 to K-1.It is above-mentioned random Number product process can realize that before above-mentioned process starts, dependent event has write block chain by way of intelligent contract, It may then wait for the generation of the subsequent block of a corresponding newest block (i.e. current block) when the event occurs, it is subsequent , can be based on the block cryptographic Hash of subsequent block after block generates, and final random number is generated according to above-mentioned processing method, The event can be finally handled by the random number of generation.In order to make it easy to understand, being bought for buying this event of lottery ticket The time of lottery ticket corresponds to the generation of event, and is located with the random number generated announce the winners in a lottery corresponding to the random number Reason buys this event of lottery ticket.
It, can be by obtaining the subsequent multiple of current block in the random digit generation method based on block chain that Fig. 1 is provided The block cryptographic Hash of block is based on getting these Future Data (block Hash of i.e. following multiple blocks as former data Value) carry out polymerization processing, will polymerization processing result do further secure hash operation and XOR operation, obtain it is final with Machine number, so that the randomness and safety of random number generated can be improved.
Referring to Fig. 2, Fig. 2 is another random digit generation method based on block chain provided in an embodiment of the present invention.Such as Shown in Fig. 2, the random digit generation method based on block chain of the present embodiment the following steps are included:
S201: the block cryptographic Hash of subsequent n-th of block of current block is obtained.
In embodiments of the present invention, the data source about random number to be generated can obtain subsequent n-th of current block The block cryptographic Hash of block, the data source as random number to be generated;The current block is is wanted with the random number The event of processing newest block when occurring, therefore, the block information of subsequent n-th of block are relative to the thing The Future Data at the generation moment of part.The acquisition of block cryptographic Hash about subsequent n-th of block, can be read block height For the block information of the block of H+n, and obtain from the block information block Hash for the block that the block height is H+n Value.Wherein, the block height of the current block is H, and n can be with value, for example, 10.
S202: the block cryptographic Hash of subsequent n-th of block is transported by secure hash algorithm and exclusive or algorithm It calculates, generates the random number.
In embodiments of the present invention, secure hash algorithm (for example, secure hash algorithm 2, abbreviation SHA2 algorithm) can be used Operation is carried out to the block cryptographic Hash of subsequent n-th of block, obtains the Kazakhstan of the block cryptographic Hash of subsequent n-th of block Uncommon value M ', then by first 128 of the cryptographic Hash M ' of the block cryptographic Hash of subsequent n-th of block and rear 128 progress exclusive or Operation obtains operation result m ' (m ' is 128 unsigned ints), can finally make m ' to K modulus, generate the random number;Its In, the preset value range of the random number is 0 to K-1.It should be pointed out that since the present embodiment only obtains once not Carry out the data of block, therefore, need to guarantee the interests independence of the random number of block production node and generation.
In the random digit generation method based on block chain that Fig. 2 is provided, it can pass through subsequent n-th of acquisition current block The block cryptographic Hash of block as former data, and based on this Future Data is got, (i.e. breathe out by the block of n-th following of the block Uncommon value) further secure hash operation and XOR operation are done, final random number is obtained, to can be improved generated random Several randomness and safety, and which only needs to obtain a block data, and does not need to carry out at relevant polymerization Reason operation, therefore entire calculating process can be made more succinct.
Referring to Fig. 3, Fig. 3 is a kind of structure of generating random number device based on block chain provided in an embodiment of the present invention Block diagram.As shown in figure 3, the generating random number device 20 based on block chain of the present embodiment includes the first acquisition module 301, polymerization Module 302 and the first generation module 303.First acquisition module 301, aggregation module 302 and the first generation module 303 are respectively used to The specific method in S101, S102 and S103 in Fig. 1 is executed, details can be found in the related introduction of Fig. 1, only make simply to retouch herein It states:
First obtains module 301, the block cryptographic Hash of subsequent multiple blocks for obtaining current block;It is described to work as proparea Block is newest block when occurring with random number event to be dealt with.
Aggregation module 302 carries out polymerization processing for the block cryptographic Hash to subsequent multiple blocks, obtains at polymerization Manage result.
First generation module 303, for being carried out by secure hash algorithm and exclusive or algorithm to the polymerization processing result Operation generates the random number.
Further, reference can be made to Fig. 4, the first generation module 303 may particularly include hashing unit 3031, exclusive or unit 3032 With modulus unit 3033:
Hashing unit 3031, for right using secure hash algorithm (for example, secure hash algorithm 2, abbreviation SHA2 algorithm) The polymerization processing result carries out operation, obtains the cryptographic Hash of the polymerization processing result.
Exclusive or unit 3032, for by first 128 of cryptographic Hash and rear 128 progress exclusive or of the polymerization processing result Operation obtains operation result m.
Modulus unit 3033 generates the random number for making m to K modulus;Wherein, the preset of the random number takes Being worth range is 0 to K-1.
The generating random number device based on block chain that Fig. 3 is provided can pass through subsequent multiple blocks of acquisition current block Block cryptographic Hash as former data, and based on get these Future Datas (the block cryptographic Hash of i.e. following multiple blocks) into Polymerization processing result is done further secure hash operation and XOR operation, obtains final random number by row polymerization processing, from And the randomness and safety of random number generated can be improved.
Referring to Fig. 5, Fig. 5 is the knot of another generating random number device based on block chain provided in an embodiment of the present invention Structure block diagram.As shown in figure 5, the generating random number device 50 based on block chain of the present embodiment includes the second acquisition 501 He of module Second generation module 502.Second acquisition module 501 and the second generation module 502 are respectively used to execute the S201 and S202 in Fig. 2 In specific method, details can be found in the related introduction of Fig. 2, are only briefly described herein:
Second obtains module 501, the block cryptographic Hash of subsequent n-th of block for obtaining current block;It is described current Block is newest block when occurring with random number event to be dealt with.
Second generation module 502, for passing through secure hash algorithm and exclusive or algorithm to the area of subsequent n-th of block Block cryptographic Hash carries out operation, generates the random number.
The generating random number device based on block chain that Fig. 5 is provided can pass through subsequent n-th of block of acquisition current block Block cryptographic Hash as former data, and based on getting this Future Data (i.e. block Hash of n-th following of the block Value) further secure hash operation and XOR operation are done, final random number is obtained, to can be improved generated random Several randomness and safety, and which only needs to obtain a block data, and does not need to carry out at relevant polymerization Reason operation, therefore entire calculating process can be made more succinct.
Fig. 6 is the schematic diagram for the terminal device that one embodiment of the invention provides.As shown in fig. 6, the terminal of the embodiment is set Standby 6 include: processor 60, memory 61 and are stored in the memory 61 and can run on the processor 60 Computer program 62, such as carry out the program of generating random number.The realization when processor 60 executes the computer program 62 Step in above method embodiment, for example, S101 shown in FIG. 1 to S103.Alternatively, the processor 60 executes the calculating The function of each module/unit in above-mentioned each Installation practice, such as module 301 to 303 shown in Fig. 3 are realized when machine program 62 Function.
Illustratively, the computer program 62 can be divided into one or more module/units, it is one or Multiple module/units are stored in the memory 61, and are executed by the processor 60, to complete the present invention.Described one A or multiple module/units can be the series of computation machine program instruction section that can complete specific function, which is used for Implementation procedure of the computer program 62 in terminal device 6 is described.For example, the computer program 62 can be divided into First obtains module 301, aggregation module 302 and the first generation module 303.(module in virtual bench), each specific function of module It can be as follows:
First obtains module 301, the block cryptographic Hash of subsequent multiple blocks for obtaining current block;It is described to work as proparea Block is newest block when occurring with random number event to be dealt with.
Aggregation module 302 carries out polymerization processing for the block cryptographic Hash to subsequent multiple blocks, obtains at polymerization Manage result.
First generation module 303, for being carried out by secure hash algorithm and exclusive or algorithm to the polymerization processing result Operation generates the random number.
The terminal device 6 can be the calculating such as desktop PC, notebook, palm PC and cloud server and set It is standby.Terminal device 6 may include, but be not limited only to, processor 60, memory 61.It will be understood by those skilled in the art that Fig. 6 is only It is only the example of terminal device 6, does not constitute the restriction to terminal device 6, may include components more more or fewer than diagram, Perhaps certain components or different components are combined, such as the terminal device can also connect including input-output equipment, network Enter equipment, bus etc..
The processor 60 can be central processing unit (Central Processing Unit, CPU), can also be Other general processors, digital signal processor (Digital Signal Processor, DSP), specific integrated circuit (Application Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field- Programmable Gate Array, FPGA) either other programmable logic device, discrete gate or transistor logic, Discrete hardware components etc..General processor can be microprocessor or the processor is also possible to any conventional processor Deng.
The memory 61 can be the internal storage unit of terminal device 6, such as the hard disk or memory of terminal device 6. It is hard that the memory 61 is also possible to the plug-in type being equipped on the External memory equipment of terminal device 6, such as the terminal device 6 Disk, intelligent memory card (Smart Media Card, SMC), secure digital (Secure Digital, SD) card, flash card (Flash Card) etc..Further, the memory 61 can also both including terminal device 6 internal storage unit and also including External memory equipment.The memory 61 for other programs needed for storing the computer program and terminal device 6 and Data.The memory 61 can be also used for temporarily storing the data that has exported or will export.
It is apparent to those skilled in the art that for convenience of description and succinctly, only with above-mentioned each function Can unit, module division progress for example, in practical application, can according to need and by above-mentioned function distribution by different Functional unit, module are completed, i.e., the internal structure of described device is divided into different functional unit or module, more than completing The all or part of function of description.Each functional unit in embodiment, module can integrate in one processing unit, can also To be that each unit physically exists alone, can also be integrated in one unit with two or more units, it is above-mentioned integrated Unit both can take the form of hardware realization, can also realize in the form of software functional units.In addition, each function list Member, the specific name of module are also only for convenience of distinguishing each other, the protection scope being not intended to limit this application.Above system The specific work process of middle unit, module, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
In the above-described embodiments, it all emphasizes particularly on different fields to the description of each embodiment, is not described in detail or remembers in some embodiment The part of load may refer to the associated description of other embodiments.
Those of ordinary skill in the art may be aware that list described in conjunction with the examples disclosed in the embodiments of the present disclosure Member and algorithm steps can be realized with the combination of electronic hardware or computer software and electronic hardware.These functions are actually It is implemented in hardware or software, the specific application and design constraint depending on technical solution.Professional technician Each specific application can be used different methods to achieve the described function, but this realization is it is not considered that exceed The scope of the present invention.
In embodiment provided by the present invention, it should be understood that disclosed device/terminal device and method, it can be with It realizes by another way.For example, device described above/terminal device embodiment is only schematical, for example, institute The division of module or unit is stated, only a kind of logical function partition, there may be another division manner in actual implementation, such as Multiple units or components can be combined or can be integrated into another system, or some features can be ignored or not executed.Separately A bit, shown or discussed mutual coupling or direct-coupling or communication connection can be through some interfaces, device Or the INDIRECT COUPLING or communication connection of unit, it can be electrical property, mechanical or other forms.
The unit as illustrated by the separation member may or may not be physically separated, aobvious as unit The component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multiple In network unit.It can select some or all of unit therein according to the actual needs to realize the mesh of this embodiment scheme 's.
It, can also be in addition, the functional units in various embodiments of the present invention may be integrated into one processing unit It is that each unit physically exists alone, can also be integrated in one unit with two or more units.Above-mentioned integrated list Member both can take the form of hardware realization, can also realize in the form of software functional units.
If the integrated module/unit be realized in the form of SFU software functional unit and as independent product sale or In use, can store in a computer readable storage medium.Based on this understanding, the present invention realizes above-mentioned implementation All or part of the process in example method, can also instruct relevant hardware to complete, the meter by computer program Calculation machine program can be stored in a computer readable storage medium, the computer program when being executed by processor, it can be achieved that on The step of stating each embodiment of the method.Wherein, the computer program includes computer program code, the computer program generation Code can be source code form, object identification code form, executable file or certain intermediate forms etc..The computer-readable medium It may include: any entity or device, recording medium, USB flash disk, mobile hard disk, magnetic that can carry the computer program code Dish, CD, computer storage, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium etc..It should be noted that described The content that computer-readable medium includes can carry out increasing appropriate according to the requirement made laws in jurisdiction with patent practice Subtract, such as does not include electric carrier signal and electricity according to legislation and patent practice, computer-readable medium in certain jurisdictions Believe signal.
Embodiment described above is merely illustrative of the technical solution of the present invention, rather than its limitations;Although referring to aforementioned reality Applying example, invention is explained in detail, those skilled in the art should understand that: it still can be to aforementioned each Technical solution documented by embodiment is modified or equivalent replacement of some of the technical features;And these are modified Or replacement, the spirit and scope for technical solution of various embodiments of the present invention that it does not separate the essence of the corresponding technical solution should all It is included within protection scope of the present invention.

Claims (11)

1. a kind of random digit generation method based on block chain characterized by comprising
Obtain the block cryptographic Hash of subsequent multiple blocks of current block;The current block is at the random number The event of reason newest block when occurring;
Polymerization processing is carried out to the block cryptographic Hash of subsequent multiple blocks, obtains polymerization processing result;
Operation is carried out to the polymerization processing result by secure hash algorithm and exclusive or algorithm, generates the random number.
2. the random digit generation method according to claim 1 based on block chain, which is characterized in that proparea is worked as in the acquisition The block cryptographic Hash of subsequent multiple blocks of block, comprising:
Read the block information for the block that block height is H+1 to H+n;Wherein, the block height of the current block is H, and n is The quantity of subsequent multiple blocks;
The block cryptographic Hash for the block that the block height is H+1 to H+n is obtained from the block information.
3. the random digit generation method according to claim 1 based on block chain, which is characterized in that described to described subsequent The block cryptographic Hash of multiple blocks carries out polymerization processing, obtains polymerization processing result, comprising:
The cryptographic Hash of subsequent 1st block of the current block and an empty cryptographic Hash are done into XOR operation, obtain the 1st wheel Polymerization result;
The cryptographic Hash of subsequent 2nd block of the current block and the first round polymerization result are done into XOR operation, obtained 2nd wheel polymerization result;
And so on, the cryptographic Hash of subsequent n-th of block of the current block and the (n-1)th wheel polymerization result are done into exclusive or fortune It calculates, obtains the n-th wheel polymerization result;N is the quantity of subsequent multiple blocks, and the n-th wheel polymerization result is to described subsequent The block cryptographic Hash of multiple blocks carries out polymerizeing processing result obtained from polymerization processing.
4. the random digit generation method based on block chain described according to claim 1 ~ any one of 3, which is characterized in that described Operation is carried out to the polymerization processing result by secure hash algorithm and exclusive or algorithm, generates the random number, comprising:
Operation is carried out to the polymerization processing result using secure hash algorithm 2, obtains the cryptographic Hash of the polymerization processing result;
First 128 of the cryptographic Hash of the polymerization processing result and rear 128 progress XOR operation are obtained into operation result m;
Make m to K modulus, generates the random number;Wherein, the preset value range of the random number is 0 to K-1.
5. a kind of random digit generation method based on block chain characterized by comprising
Obtain the block cryptographic Hash of subsequent n-th of block of current block;The current block is is wanted with the random number The event of processing newest block when occurring;
Operation is carried out to the block cryptographic Hash of subsequent n-th of block by secure hash algorithm and exclusive or algorithm, generates institute State random number.
6. random digit generation method according to claim 5, which is characterized in that described by secure hash algorithm and exclusive or Algorithm carries out operation to the block cryptographic Hash of subsequent n-th of block, generates the random number, comprising:
Operation is carried out using block cryptographic Hash of the secure hash algorithm 2 to subsequent n-th of block, obtains described subsequent n-th The cryptographic Hash of the block cryptographic Hash of a block;
First 128 of the cryptographic Hash of the block cryptographic Hash of subsequent n-th of block and rear 128 progress XOR operation are obtained Operation result m ';
Make m ' to K modulus, generates the random number;Wherein, the preset value range of the random number is 0 to K-1.
7. a kind of generating random number device based on block chain characterized by comprising
First obtains module, the block cryptographic Hash of subsequent multiple blocks for obtaining current block;The current block is fortune Newest block when being occurred with random number event to be dealt with;
Aggregation module carries out polymerization processing for the block cryptographic Hash to subsequent multiple blocks, obtains polymerization processing result;
First generation module, it is raw for carrying out operation to the polymerization processing result by secure hash algorithm and exclusive or algorithm At the random number.
8. the generating random number device according to claim 7 based on block chain, which is characterized in that described first generates mould Block includes:
Hashing unit obtains the polymerization processing for carrying out operation to the polymerization processing result using secure hash algorithm 2 As a result cryptographic Hash;
Exclusive or unit, for obtaining first 128 of the cryptographic Hash of the polymerization processing result and rear 128 progress XOR operation Operation result m;
Modulus unit generates the random number for making m to K modulus;Wherein, the preset value range of the random number is 0 To K-1.
9. a kind of generating random number device based on block chain characterized by comprising
Second obtains module, the block cryptographic Hash of subsequent n-th of block for obtaining current block;The current block is fortune Newest block when being occurred with random number event to be dealt with;
Second generation module, for passing through secure hash algorithm and exclusive or algorithm to the block Hash of subsequent n-th of block Value carries out operation, generates the random number.
10. a kind of terminal device, including memory, processor and storage are in the memory and can be on the processor The computer program of operation, which is characterized in that the processor is realized when executing the computer program as in claim 1-6 The step of any one the method.
11. a kind of computer-readable medium, the computer-readable medium storage has computer program, which is characterized in that described It is realized when computer program execution processed such as the step of any one of claim 1-6 the method.
CN201910716527.7A 2019-08-05 2019-08-05 Random number generation method and device based on block chain Active CN110515591B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910716527.7A CN110515591B (en) 2019-08-05 2019-08-05 Random number generation method and device based on block chain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910716527.7A CN110515591B (en) 2019-08-05 2019-08-05 Random number generation method and device based on block chain

Publications (2)

Publication Number Publication Date
CN110515591A true CN110515591A (en) 2019-11-29
CN110515591B CN110515591B (en) 2023-04-11

Family

ID=68625107

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910716527.7A Active CN110515591B (en) 2019-08-05 2019-08-05 Random number generation method and device based on block chain

Country Status (1)

Country Link
CN (1) CN110515591B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111311386A (en) * 2020-01-19 2020-06-19 深圳壹账通智能科技有限公司 Block chain-based bead shaking method and system, electronic device and storage medium
CN114553505A (en) * 2022-02-09 2022-05-27 蚂蚁区块链科技(上海)有限公司 Method and device for generating random number by cooperation of multiple parties

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101349968A (en) * 2007-06-30 2009-01-21 英特尔公司 Speeding up galois counter mode (GCM) computations
CN106802788A (en) * 2012-03-30 2017-06-06 英特尔公司 Method and apparatus for processing the SHAs of SHA 2
CN108182581A (en) * 2017-12-29 2018-06-19 北京欧链科技有限公司 A kind of bookkeeping methods and device of block chain
CN108563465A (en) * 2012-09-28 2018-09-21 英特尔公司 Systems, devices and methods for executing cycle and exclusive or in response to single instruction
CN108717466A (en) * 2018-06-05 2018-10-30 中国平安人寿保险股份有限公司 Collage-credit data storage method, device, computer equipment and storage medium
CN108768608A (en) * 2018-05-25 2018-11-06 电子科技大学 The secret protection identity identifying method of thin-client is supported at block chain PKI
CN109146524A (en) * 2018-08-22 2019-01-04 周口师范学院 A kind of agricultural product using block chain technology are traced to the source information security solution
CN109583892A (en) * 2018-11-21 2019-04-05 安徽高山科技有限公司 A kind of random number selecting method in block chain
CN109617679A (en) * 2018-11-29 2019-04-12 哈希未来(北京)科技有限公司 Generate, obtain and provide method, system and the storage medium of random number
CN109684080A (en) * 2018-12-10 2019-04-26 平安科技(深圳)有限公司 Centralized method for scheduling task, system and storage medium
CN109688211A (en) * 2018-12-18 2019-04-26 杭州茂财网络技术有限公司 Data distribution formula processing method
US20190173667A1 (en) * 2016-12-23 2019-06-06 Cloudminds (Shenzhen) Robotics Systems Co., Ltd. Block generation method, device and blockchain network

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101349968A (en) * 2007-06-30 2009-01-21 英特尔公司 Speeding up galois counter mode (GCM) computations
CN106802788A (en) * 2012-03-30 2017-06-06 英特尔公司 Method and apparatus for processing the SHAs of SHA 2
CN108563465A (en) * 2012-09-28 2018-09-21 英特尔公司 Systems, devices and methods for executing cycle and exclusive or in response to single instruction
US20190173667A1 (en) * 2016-12-23 2019-06-06 Cloudminds (Shenzhen) Robotics Systems Co., Ltd. Block generation method, device and blockchain network
CN108182581A (en) * 2017-12-29 2018-06-19 北京欧链科技有限公司 A kind of bookkeeping methods and device of block chain
CN108768608A (en) * 2018-05-25 2018-11-06 电子科技大学 The secret protection identity identifying method of thin-client is supported at block chain PKI
CN108717466A (en) * 2018-06-05 2018-10-30 中国平安人寿保险股份有限公司 Collage-credit data storage method, device, computer equipment and storage medium
CN109146524A (en) * 2018-08-22 2019-01-04 周口师范学院 A kind of agricultural product using block chain technology are traced to the source information security solution
CN109583892A (en) * 2018-11-21 2019-04-05 安徽高山科技有限公司 A kind of random number selecting method in block chain
CN109617679A (en) * 2018-11-29 2019-04-12 哈希未来(北京)科技有限公司 Generate, obtain and provide method, system and the storage medium of random number
CN109684080A (en) * 2018-12-10 2019-04-26 平安科技(深圳)有限公司 Centralized method for scheduling task, system and storage medium
CN109688211A (en) * 2018-12-18 2019-04-26 杭州茂财网络技术有限公司 Data distribution formula processing method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
匿名: "将SHA256散列截断为128位可以吗?", 《HTTPS://WWW.IT1352.COM/845309.HTML》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111311386A (en) * 2020-01-19 2020-06-19 深圳壹账通智能科技有限公司 Block chain-based bead shaking method and system, electronic device and storage medium
CN114553505A (en) * 2022-02-09 2022-05-27 蚂蚁区块链科技(上海)有限公司 Method and device for generating random number by cooperation of multiple parties

Also Published As

Publication number Publication date
CN110515591B (en) 2023-04-11

Similar Documents

Publication Publication Date Title
CN111080288B (en) Block chain consensus achieving method and device based on directed acyclic graph
CN111008863A (en) Lottery drawing method and system based on block chain
CN107819569A (en) The encryption method and terminal device of log-on message
CN107608667A (en) The update method and device of a kind of operation flow
CN103049710B (en) Field-programmable gate array (FPGA) chip for SM2 digital signature verification algorithm
CN112633508A (en) Quantum line generation method and device, storage medium and electronic device
CN103761068A (en) Optimized Montgomery modular multiplication method, optimized modular square method and optimized modular multiplication hardware
CN112769548B (en) Block chain numerical information transmission method, system, device and computer medium
CN109615525A (en) Multi-signature shares guard method, system and the electronic equipment of account
CN110515591A (en) Random digit generation method and device based on block chain
CN107632823A (en) A kind of software development methodology and device
CN112633507A (en) Method and device for encoding complex vector to quantum circuit
CN107784596A (en) Insurance kind state information statistics method, terminal device and the storage medium of declaration form
CN115237802A (en) Artificial intelligence based simulation test method and related equipment
CN112114776A (en) Quantum multiplication method and device, electronic device and storage medium
CN107977504A (en) A kind of asymmetric in-core fuel management computational methods, device and terminal device
CN110505655A (en) Data command processing method, storage medium and bluetooth shield
CN114254353A (en) Data processing method and device based on privacy protection and server
CN113721988A (en) Chip-based workload proving method and chip for workload proving
CN112163949A (en) Intelligent contract generation method and device based on contract component imaging
CN112162723A (en) Quantum addition operation method and device, electronic device and storage medium
CN107589965A (en) A kind of software development methodology and device
CN104298897B (en) embedded copyright authentication method based on chaos technology and special processor
CN110489151A (en) A kind of terminal staging method and system
CN109461081A (en) Credits capitalized method and device, storage medium, electronic device

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