CN110336668A - A kind of random digit generation method, device and application, equipment and storage medium - Google Patents

A kind of random digit generation method, device and application, equipment and storage medium Download PDF

Info

Publication number
CN110336668A
CN110336668A CN201910731626.2A CN201910731626A CN110336668A CN 110336668 A CN110336668 A CN 110336668A CN 201910731626 A CN201910731626 A CN 201910731626A CN 110336668 A CN110336668 A CN 110336668A
Authority
CN
China
Prior art keywords
fragment
hash
block
content
indexi
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
CN201910731626.2A
Other languages
Chinese (zh)
Other versions
CN110336668B (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.)
Hangzhou Fuzamei Technology Co Ltd
Original Assignee
Hangzhou Fuzamei 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 Hangzhou Fuzamei Technology Co Ltd filed Critical Hangzhou Fuzamei Technology Co Ltd
Priority to CN201910731626.2A priority Critical patent/CN110336668B/en
Publication of CN110336668A publication Critical patent/CN110336668A/en
Application granted granted Critical
Publication of CN110336668B publication Critical patent/CN110336668B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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
    • H04L67/104Peer-to-peer [P2P] networks
    • 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/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

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Power Engineering (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a kind of random digit generation method, device and application, equipment and storage mediums, belong to block chain technical field.Content C is formed by cascade is carried out comprising the transaction in continuous N number of block before current block, content C is split as the fragment of M byte, fragment sum S=len (C)/M;If len (C) > S*M;Then S=S+1;It determines that a fragment indexes Indexi at random from S fragment, and Indexi is indexed according to fragment and obtains fragment content, by carrying out Hash operation to fragment content, random number is calculated;Wherein, N >=1, M and N are integer.The random number obtained for existing method is easy to be broken, so that being on the hazard by the safety that the contract of block chain random number executes.The present invention determines the generation of block chain random number by series of rules such as the cascade of continuous multiple block transaction contents and slices, it is ensured that its randomness, while not being broken again.

Description

A kind of random digit generation method, device and application, equipment and storage medium
Technical field
The present invention relates to block chain technical field more particularly to a kind of random digit generation method, device and application, equipment and Storage medium.
Background technique
In block chain network demand random number, all nodes meeting one third party's stochastic sources of synchronization request generate random Number, to guarantee the consistency of nodal information, has a disadvantage in that, not can guarantee the safety and stability of third party's stochastic source, when When third party's stochastic source is controlled by attack, then the business of entire block chain network can may all be affected.To overcome Drawbacks described above, existing random digit generation method are as follows: directly according to current block cryptographic Hash or public key to obtaining random number, these The random number that method obtains is easy to be broken, so that the safety executed by the contract of block chain random number is by prestige The side of body.
Publication No. is CN107301546A, and date of publication is the Chinese invention patent application on October 27th, 2017, be related to Machine number generates and methods for using them and device, discloses and needs to generate the transaction request of random number according to receiving, will receive the moment Timestamp as initial random number, this random number acquisition methods on different block chain nodes when executing, each node Obtained random number outcome is different, cannot keep the consistency of nodal information.
Summary of the invention
1. technical problems to be solved by the inivention
In order to overcome the above technical problems, the present invention provides a kind of random digit generation method, device and application, equipment and Storage medium.The life of block chain random number is determined by series of rules such as the cascade of continuous multiple block transaction contents and slices At the random number obtained through the invention, it is ensured that its randomness, while not being broken again.
2. technical solution
To solve the above problems, technical solution provided by the invention are as follows:
In a first aspect, the invention proposes random digit generation methods, comprising: will be comprising continuous N number of before current block Transaction in block carries out cascade and forms content C, and content C is split as the fragment of M byte, fragment sum S=len (C)/M; If len (C) > S*M;Then S=S+1;It determines that a fragment indexes Indexi at random from S fragment, and is indexed according to fragment Indexi obtains fragment content, and by carrying out Hash operation to fragment content, random number is calculated;Wherein, N >=1, M and N are equal For integer.
Further improving is, the method for determining fragment index at random from S fragment are as follows: fragment index Indexi=Hash_C mod (S);The cryptographic Hash of content C is Hash_C;Or, fragment indexes Indexi=Hash_Header_ block_N mod(S);Wherein, content is denoted as after the block head of N number of block carries out cascade: Header_block_N, Hash_ Header_block_N is its corresponding cryptographic Hash;Or, fragment index Indexi=Hash_Block_N mod (S);Wherein, N Content is denoted as after the block content of a block carries out cascade: Block_N, Hash_Block_N are its corresponding cryptographic Hash; Indexi value range is [0, S-1], and the corresponding fragment content SC=C of fragment index Indexi is obtained from content C [Indexi];Corresponding fragment content Hash value Hash (SC) is calculated through Hash operation, random number is calculated.
Further improving is the value range of M byte: the power side that len (C) >=M >=32, M are 2.
Further improving is that the cryptographic Hash Hash_C of the content C adopts Hash operation and is calculated, the Hash fortune The algorithm of calculation is MD5 or SHA-1 or SHA-2 or SHA-3 or BLAKE2 or BLAKE2s.
Further improving is, the method obtains random number during current block is run.
Second aspect, the present invention propose generating random number device, comprising: sharding unit, for will comprising current block it Transaction in preceding continuous N number of block carries out cascade and forms content C, and content C is split as the fragment of M byte;Fragment sum Determination unit obtains fragment sum S, S=len (C)/M for calculating;If len (C) > S*M;Then S=S+1;Fragment index Determination unit, for determining that a fragment indexes Indexi at random from S fragment;Random number arithmetic element, for basis point Piece indexes Indexi and obtains fragment content, and by carrying out Hash operation to fragment content, random number is calculated;Wherein, N >=1, M and N is integer.
Further improving is, the method for determining fragment index at random from S fragment are as follows: fragment index Indexi=Hash_C mod (S);The cryptographic Hash of content C is Hash_C;Or, fragment indexes Indexi=Hash_Header_ block_N mod(S);Wherein, content is denoted as after the block head of N number of block carries out cascade: Header_block_N, Hash_ Header_block_N is its corresponding cryptographic Hash;Or, fragment index Indexi=Hash_Block_N mod (S);Wherein, N Content is denoted as after the block content of a block carries out cascade: Block_N, Hash_Block_N are its corresponding cryptographic Hash; Indexi value range is [0, S-1], and the corresponding fragment content SC=C of fragment index Indexi is obtained from content C [Indexi];Corresponding fragment content Hash value Hash (SC) is calculated through Hash operation, random number is calculated.
Further improving is the value range of M byte: the power side that len (C) >=M >=32, M are 2.
Further improving is that the cryptographic Hash Hash_C of the content C adopts Hash operation and is calculated, the Hash fortune The algorithm of calculation is MD5 or SHA-1 or SHA-2 or SHA-3 or BLAKE2 or BLAKE2s.
Further improving is that described device is located on the block chain node of block chain network.
The third aspect, the present invention propose a kind of application of random number, apparatus above according to approach described above generate with Machine number is applied to choose common recognition node, and for determining packing sequence.
Fourth aspect, the present invention propose a kind of application of random number again, and apparatus above is generated according to approach described above Random number is applied in guessing game or lottery industry.
5th aspect, the present invention propose that a kind of equipment, the equipment include: one or more processors;Memory is used for One or more programs are stored, when one or more of programs are executed by one or more of processors, so that described One or more processors execute method as described above.
6th aspect, the present invention propose a kind of storage medium for being stored with computer program, which is executed by processor Method of the Shi Shixian as described in any of the above item.
3. beneficial effect
Using technical solution provided by the invention, compared with prior art, have the following beneficial effects:
The life of block chain random number is determined by series of rules such as the cascade of continuous multiple block transaction contents and slices At the random number obtained through the invention, it is ensured that its randomness and consistency, while not being broken again.
Detailed description of the invention
Fig. 1 is a kind of flow chart for random digit generation method that the embodiment of the present invention 1 provides.
Fig. 2 is a kind of structural schematic diagram for generating random number device that the embodiment of the present invention 2 provides.
Fig. 3 is the cascade schematic diagram of 3 content C of the embodiment of the present invention.
Fig. 4 is the subregion schematic diagram of 3 content C of the embodiment of the present invention.
Fig. 5 is a kind of device structure schematic diagram of the invention.
Specific embodiment
To further appreciate that the contents of the present invention, in conjunction with accompanying drawings and embodiments, the present invention is described in detail.
The application is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched The specific embodiment stated is used only for explaining related invention, rather than the restriction to the invention.It also should be noted that in order to Convenient for description, part relevant to invention is illustrated only in attached drawing.
Heretofore described first, second equal words are convenient and be arranged in order to describe technical solution of the present invention, and There is no specific restriction effect, be to refer to, restriction effect is not constituted to technical solution of the present invention.
It should be noted that in the absence of conflict, the features in the embodiments and the embodiments of the present application can phase Mutually combination.The application is described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
Embodiment 1
The present embodiment is related to random digit generation method, as shown in Figure 1, comprising:
S101, it will carry out cascading comprising the transaction in continuous N number of block before current block forming content C;
S102, content C are split as the fragment of M byte, fragment sum S=len (C)/M;
Do are S103, len (C) > S*M true? if so, S=S+1;If it is not, then S value remains unchanged;
S104, from determining that fragment indexes Indexi in S fragment at random from S fragment;
S105, fragment content is obtained from content C according to fragment index Indexi, by carrying out Hash fortune to fragment content It calculates, random number is calculated.
Wherein, N >=1, M and N are integer, the value range of M: the power side that len (C) >=M >=32, M are 2.
Further improving is, there are many kinds of the methods for determining fragment index at random from S fragment, can root According to needing to be determined, the present embodiment enumerates three kinds of methods respectively include:
Method one: fragment index
Indexi=Hash_C mod (S);
Wherein, Hash_C is the cryptographic Hash of content C, and I ndex i value range is [0, S-1].
Method two: fragment index
Indexi=Hash_Header_block_N mod (S);
Wherein, content is denoted as after the block head of N number of block carries out cascade: Header_block_N, Hash_Header_ Block_N is its corresponding cryptographic Hash, and Indexi value range is [0, S-1].
Method three: fragment index
Indexi=Hash_Block_N mod (S);
Wherein, content is denoted as after the block content of N number of block carries out cascade: Block_N, Hash_Block_N correspond to for it Cryptographic Hash, Indexi value range be [0, S-1].
The corresponding fragment content SC=C [Indexi] of fragment index Indexi is obtained from content C;It is calculated through Hash operation Corresponding fragment content Hash value Hash (SC) is obtained, random number is calculated.
Above-described cryptographic Hash calculates, and the progress of Hash operation is required to hash algorithm, and the hash algorithm includes MD5 or SHA-1 or SHA-2 or SHA-3 or BLAKE2 or BLAKE2s.BLAKE2 series is spread out from famous ChaCha algorithm Raw, there are two main version BLAKE2b (BLAKE2) and BLAKE2s.
Further, the cryptographic Hash Hash_C of the content C is calculated using Sha3-hash algorithm, content Hash value The binary number that Hash_C is 256.
The present embodiment the method runs during current block and obtains random number.
Embodiment 2
The present embodiment is related to generating random number device, as shown in Figure 2, comprising: sharding unit, for that will include current block The transaction in continuous N number of block before carries out cascade and forms content C, and content C is split as the fragment of M byte;
Fragment sum determination unit obtains fragment sum S, S=len (C)/M for calculating;If len (C) > S*M;Then S=S+1;Accordingly, the byte length of the last one fragment S are as follows: len (C) mod (M);
Fragment indexes determination unit, for determining that a fragment indexes Indexi at random from S fragment;
Random number arithmetic element obtains fragment content for indexing Indexi according to fragment, by carrying out to fragment content Random number is calculated in Hash operation;Wherein, N >=1, M and N are integer.
Further improving is, described to determine a fragment rope at random from S fragment in fragment index determination unit The method drawn can be with are as follows: fragment indexes Indexi=Hash_C mod (S);The cryptographic Hash of content C is Hash_C;From content C Obtain the corresponding fragment content SC=C [Indexi] of fragment index Indexi;It is calculated in corresponding fragment through Hash operation Hold cryptographic Hash hash (SC), random number is calculated.In fragment index determination unit, the cryptographic Hash Hash_C of the content C It is calculated using Sha3-hash algorithm, the binary number that content Hash value Hash_C is 256.It is determined in fragment sum single In member, the value range of M: the power side that len (C) >=M >=32, M are 2.The generating random number device is located at block chain network Block chain node on.The calculating of cryptographic Hash, the progress of Hash operation can also use following Hash, including MD5 or SHA- 1 or SHA-2 or SHA-3 or BLAKE2 or BLAKE2s.At this stage, BLAKE2 is popular because performance is ultrafast.
Embodiment 3
The present embodiment is related to random digit generation method, using technical solution described in embodiment 1, will currently be performed block The transaction in continuous N number of block before is cascaded, as shown in Figure 3, it is assumed that the current height for executing block is H, H-N, H- N-1,, H-2, H-1 be current block before continuous N number of block.
Wherein, H-1_Ex, the digging mine for being block H-1 are traded;H-1_Tx0, H-1_Tx1, H-1_Tx2,, H-1_TxK1 be The transaction of block H-1.
H-2_Ex, the digging mine for being block H-2 are traded;H-2_Tx0, H-2_Tx1, H-2_Tx2,, H-2_TxK2 be block H- 2 transaction.
H-N_Ex, the digging mine for being block H-N are traded;H-N_Tx0, H-N_Tx1, H-N_Tx2,, H-N_TxKN be block H- The transaction of N.
Content after transaction cascade:
C=H-1_Ex | | H-1_Tx0 | | H-1_Tx1 | | H-1_Tx2 | | ... | | H-1_TxK1 | | H-2_Ex | | H-2_Tx0 | |H-2_Tx1||H-2_Tx2||...||H-2_TxK2||...||H-N_Ex||H-N_Tx0||H-N_Tx1||...||H-N_KN;
It is the fragment of 64 (M takes 64) a bytes by content C cutting, the sum of fragment is S, i.e. S=l en (C)/64;l en (C), for calculating the length of content C.
If l en (C) > S*64;Then S=S+1, i.e. S add 1;From left to right to content C according to 64 bytes as one Fragment is divided, and identify upper serial number 0,1,2,3,, S-1, as shown in Figure 4.The present embodiment uses Sha3-hash algorithm meter The cryptographic Hash Hash_C of content C is calculated, the binary number that the cryptographic Hash Hash_C of content C is 256:
Hash_C=Hash (H-1_Ex | | H-1_Tx0 | | H-1_Tx1 | | H-1_Tx2 | | ... | | H-1_TxK1 | | H-2_Ex ||H-2_Tx0||H-2_Tx1||H-2_Tx2||...||H-2_TxK2||...||H-N_Ex||H-N_Tx0||H-N_Tx1| |...||H-N_KN);
Determine a fragment at random from S fragment by the following method:
S201, determine that a fragment indexes Indexi at random from S fragment:
The corresponding decimal number of cryptographic Hash Hash_C of Indexi=Hash_C mod (S), content C take fragment sum S Mould determines the serial number of a fragment, that is, determines that a fragment indexes Indexi;A kind of determining fragment index is listed herein The mode of Indexi can also use other modes, depending on different application scenarios and demand.
S202, the corresponding fragment content SC=C [Indexi] of fragment index Indexi is obtained from content C;
S203, the corresponding fragment content Hash value Hash of fragment index Indexi is calculated using Sha3-hash algorithm (SC), as random number.
The random digit generation method of the present embodiment is quick, and committed memory is few, portable, can concurrently execute, for different Parameter all has uniform speed.
The use of the random number generated using the random digit generation method of the present embodiment has certain limitation, needs to exclude thing Random number is first calculated, to obtain the malice situation of the interests of non-justice in the transaction of block chain, then, inventor is creatively Proposing random number should use in certain window phase.Generated using N number of block before the block being currently generating After random number, used in the block being currently generating.The application establishes on the basis of block chain network stable operation, i.e., The case where exclusion block bifurcated, rollback.
When the scene of the present embodiment block chain random number is that all nodes are needed using the same random number, own The present embodiment generating random number device is equipped on node may be implemented using random digit generation method described in the present embodiment In block chain network, all nodes are consistent when obtaining some highly relevant random number, and are provided simultaneously with randomness. Although the generation method of random number is variant, the random number that each node generates may also be consistent, and probability is very low, especially When being that node in a certain block chain network is more.It is consistent in the random number that each node generates using the technical solution of the application Property under the premise of, the stochastic source of random number has enough randomness, uses in certain window phase, and random number will not be broken Solution, it can be ensured that the safety of random number.
In view of the above, the technical solution of the present embodiment is suitable for using on chain, the guess trip such as based on block chain Play --- more people's guessing games of 2 people or more, before random number and its cryptographic Hash are announced, the guess content cochain of each player Terminate, triggers guessing game contract after waiting random number to announce, game contract calculates game knot according to preset rules Fruit, triggering game contract distributes game reward, and announces the game result and punishment/reward situation of each player.
Illustrated for guessing big trivial games, it, can be because it is big or small to guess that the game random number of size only needs The random number of generation is to 2 remainders, the result of remainder: 1 represent it is big, 0 represent it is small.Random number is to the result of 2 remainders and the trip of player Play predictive content (0 or 1) is compared and is announced the winners in a lottery.If random number is 0 to the result of 2 remainders, the game predictive content of player It is 0, illustrates that player hits it, player brings back capital, while the reward equal with capital is obtained from prizes pool, if guessing wrong, capital Into prizes pool.
A kind of application of random number is such as applied to guess the game of Digital size, and all players are with transaction form in block chain Cash pledge/the bet of oneself, and the content guessed are announced in network --- or it is big or small, until sometime node, or The modes such as until reaching game and participating in the number upper limit, during a back to back block height, each node is according to this The application generating random number device generates random number by using random digit generation method described herein, and announces, And then game contract is triggered, and game contract is regular according to the contract of itself, and game result is determined by random number and is announced, into And trigger game reward/punishment contract and execute, distribute game reward/punishment.
A kind of application of random number, such as in POS or DPOS common recognition mechanism, common recognition node is chosen by random number, Ensure to be packaged the uncontrollable of node and its packing sequence.In this case, to prevent malice from intervening, malice situations such as hacker attack Determine common recognition node and its packing sequence, often require that random number while having randomness, it is with uniformity.I.e. all sections Point is consistent when obtaining some highly relevant random number, and is provided simultaneously with randomness.So use the technology of the application Above-mentioned purpose can be realized in scheme.
A kind of application of random number, is such as applied to the game of lottery industry class, and random digit generation method described in the present embodiment generates Random number deal out the cards for justice, generate lottery winning number drawn etc..In centralization application, random number is raw by the server of centralization At it is fair and just not can guarantee system.Under block chain environment, without unique center, each node participates in random number jointly It generates, guarantees fairness;Because multiple nodes participate in, the consistency of random number may insure using the method for the present embodiment, one Determine to increase the cost that hacker launches a offensive to random number using block node in degree, especially block chain network node compared with When more.
Embodiment 3
A kind of equipment, the equipment include: one or more processors;Memory, for storing one or more programs, When one or more of programs are executed by one or more of processors, so that one or more of processors execute Method as described above.
A kind of storage medium being stored with computer program realizes such as above embodiments 1 when the program is executed by processor The method.
Fig. 5 is a kind of structural schematic diagram for equipment that one embodiment of the invention provides.
As shown in figure 5, present invention also provides a kind of equipment 500, including one or more centres as on the other hand Unit (CPU) 501 is managed, can be added according to the program being stored in read-only memory (ROM) 502 or from storage section 508 The program that is downloaded in random access storage device (RAM) 503 and execute various movements appropriate and processing.In RAM503, also deposit It contains equipment 500 and operates required various programs and data.CPU501, ROM502 and RAM503 pass through the phase each other of bus 504 Even.Input/output (I/O) interface 505 is also connected to bus 504.
I/O interface 505 is connected to lower component: the importation 506 including keyboard, mouse etc.;It is penetrated including such as cathode The output par, c 507 of spool (CRT), liquid crystal display (LCD) etc. and loudspeaker etc.;Storage section 508 including hard disk etc.; And the communications portion 509 of the network interface card including LAN card, modem etc..Communications portion 509 via such as because The network of spy's net executes communication process.Driver 510 is also connected to I/O interface 505 as needed.Detachable media 511, such as Disk, CD, magneto-optic disk, semiconductor memory etc. are mounted on as needed on driver 510, in order to read from thereon Computer program be mounted into storage section 508 as needed.
Particularly, according to disclosed embodiments, the method for any of the above-described embodiment description may be implemented as counting Calculation machine software program.For example, disclosed embodiments include a kind of computer program product comprising be tangibly embodied in Computer program on machine readable media, the computer program include the method for executing any of the above-described embodiment description Program code.In such embodiments, which can be downloaded and be pacified from network by communications portion 509 Dress, and/or be mounted from detachable media 511.
As another aspect, present invention also provides a kind of computer readable storage medium, the computer-readable storage mediums Matter can be computer readable storage medium included in the device of above-described embodiment;It is also possible to individualism, it is unassembled Enter the computer readable storage medium in equipment.Computer-readable recording medium storage has one or more than one program, should Program is used to execute by one or more than one processor is described in the present processes.
Flow chart and block diagram in attached drawing are illustrated according to the system of various embodiments of the invention, method and computer journey The architecture, function and operation in the cards of sequence product.In this regard, each box in flowchart or block diagram can generation A part of one module, program segment or code of table, a part of the module, program segment or code include one or more use The executable instruction of the logic function as defined in realizing.It should also be noted that in some implementations as replacements, being marked in box The function of note can also occur in a different order than that indicated in the drawings.For example, two boxes succeedingly indicated are actually It can be basically executed in parallel, they can also be executed in the opposite order sometimes, this is depending on related function.Also it wants It is noted that the combination of each box in block diagram and or flow chart and the box in block diagram and or flow chart, Ke Yitong The dedicated hardware based system of functions or operations as defined in executing is crossed to realize, or by specialized hardware and can be calculated The combination of machine instruction is realized.
Being described in the embodiment of the present application involved unit or module can be realized by way of software, can also be with It is realized by way of hardware.Described unit or module also can be set in the processor, for example, each unit can To be the software program being arranged in computer or intelligent movable equipment, it is also possible to the hardware device being separately configured.Wherein, this The title of a little units or module does not constitute the restriction to the unit or module itself under certain conditions.
Above description is only the preferred embodiment of the application and the explanation to institute's application technology principle.Those skilled in the art Member is it should be appreciated that invention scope involved in the application, however it is not limited to technology made of the specific combination of above-mentioned technical characteristic Scheme, while should also cover in the case where not departing from the application design, appointed by above-mentioned technical characteristic or its equivalent feature Other technical solutions of meaning combination and formation.Such as features described above and (but being not limited to) disclosed herein have similar functions Technical characteristic replaced mutually and the technical solution that is formed.

Claims (14)

1. random digit generation method characterized by comprising the transaction in continuous N number of block before current block will be included It carries out cascade and forms content C, content C is split as the fragment of M byte, fragment sum S=len (C)/M;
If
Len (C) > S*M;
Then
S=S+1;
It determines that a fragment indexes Indexi at random from S fragment, and Indexi is indexed according to fragment and obtains fragment content, lead to It crosses and Hash operation is carried out to fragment content, random number is calculated;
Wherein, N >=1, M and N are integer.
2. the method according to claim 1, wherein described determine a fragment index at random from S fragment Method are as follows: fragment index
Indexi=Hash_C mod (S);
The cryptographic Hash of content C is Hash_C;
Or, fragment indexes
Indexi=Hash_Header_block_N mod (S);
Wherein, content is denoted as after the block head of N number of block carries out cascade: Header_block_N, Hash_Header_block_N For its corresponding cryptographic Hash;
Or, fragment indexes
Indexi=Hash_Block_N mod (S);
Wherein, content is denoted as after the block content of N number of block carries out cascade: Block_N, Hash_Block_N are its corresponding Kazakhstan Uncommon value;
Indexi value range is [0, S-1], and the corresponding fragment content SC=C of fragment index Indexi is obtained from content C [Indexi];Corresponding fragment content Hash value Hash (SC) is calculated through Hash operation, random number is calculated.
3. the method according to claim 1, wherein the value range of M byte: len (C) >=M >=32, M 2 Power side.
4. according to the method described in claim 2, it is characterized in that, the cryptographic Hash Hash_C of the content C adopts Hash operation meter It obtains, the algorithm of the Hash operation is MD5 or SHA-1 or SHA-2 or SHA-3 or BLAKE2 or BLAKE2s.
5. method according to claim 1-4, which is characterized in that the method obtains during current block is run To random number.
6. generating random number device characterized by comprising
Sharding unit forms content C for the transaction in continuous N number of block before including current block to be carried out cascade, interior Hold C to be split as the fragment of M byte;
Fragment sum determination unit obtains fragment sum S for calculating,
S=len (C)/M;
If
Len (C) > S*M;
Then
S=S+1;
Fragment indexes determination unit, for determining that a fragment indexes Indexi at random from S fragment;
Random number arithmetic element obtains fragment content for indexing Indexi according to fragment, by carrying out Hash to fragment content Random number is calculated in operation;
Wherein, N >=1, M and N are integer.
7. device according to claim 6, which is characterized in that described to determine what a fragment indexed at random from S fragment Method are as follows: fragment index
Indexi=Hash_C mod (S);
Wherein, the cryptographic Hash of content C is Hash_C;
Or, fragment indexes
Indexi=Hash_Header_block_N mod (S);
Wherein, content is denoted as after the block head of N number of block carries out cascade: Header_block_N, Hash_Header_block_N For its corresponding cryptographic Hash;
Or, fragment indexes
Indexi=Hash_Block_N mod (S);
Wherein, content is denoted as after the block content of N number of block carries out cascade: Block_N, Hash_Block_N are its corresponding Kazakhstan Uncommon value;
Indexi value range is [0, S-1], and the corresponding fragment content SC=C of fragment index Indexi is obtained from content C [Indexi];Corresponding fragment content Hash value Hash (SC) is calculated through Hash operation, random number is calculated.
8. device according to claim 6, which is characterized in that the value range of M byte: len (C) >=M >=32, M are 2 Power side.
9. device according to claim 7, which is characterized in that the cryptographic Hash Hash_C of the content C adopts Hash operation calculating It obtains, the algorithm of the Hash operation is MD5 or SHA-1 or SHA-2 or SHA-3 or BLAKE2 or BLAKE2s.
10. according to any one of claim 6-9 described device, which is characterized in that described device is located at the block of block chain network On chain node.
11. a kind of application of random number, which is characterized in that claim 6 described device generates method according to claim 1 Random number be applied to choose common recognition node, and for determine packing sequence.
12. a kind of application of random number, which is characterized in that claim 6 described device generates method according to claim 1 Random number be applied in guessing game or lottery industry.
13. a kind of equipment, which is characterized in that the equipment includes:
One or more processors;
Memory, for storing one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processors Execute method according to any one of claims 1 to 5.
14. a kind of storage medium for being stored with computer program, which is characterized in that realize when the program is executed by processor as weighed Benefit requires method described in any one of 1-5.
CN201910731626.2A 2019-08-08 2019-08-08 Random number generation method and device, application, equipment and storage medium Active CN110336668B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910731626.2A CN110336668B (en) 2019-08-08 2019-08-08 Random number generation method and device, application, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910731626.2A CN110336668B (en) 2019-08-08 2019-08-08 Random number generation method and device, application, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110336668A true CN110336668A (en) 2019-10-15
CN110336668B CN110336668B (en) 2022-02-11

Family

ID=68149101

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910731626.2A Active CN110336668B (en) 2019-08-08 2019-08-08 Random number generation method and device, application, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110336668B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110955407A (en) * 2019-11-21 2020-04-03 杭州趣链科技有限公司 Random number taking method based on block chain
CN110990808A (en) * 2019-11-21 2020-04-10 杭州趣链科技有限公司 Notarization number shaking method based on block chain
CN113055175A (en) * 2021-06-02 2021-06-29 杭州链城数字科技有限公司 Private key distribution method of distributed CA and electronic device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107392770A (en) * 2017-08-09 2017-11-24 北京云知科技有限公司 A kind of random-number generating method and system based on block chain
CN109558112A (en) * 2018-11-14 2019-04-02 杭州复杂美科技有限公司 Random digit generation method, anti-cheating block catenary system, equipment and storage medium
CN109583892A (en) * 2018-11-21 2019-04-05 安徽高山科技有限公司 A kind of random number selecting method in block chain
CN109934583A (en) * 2019-03-04 2019-06-25 安徽高山科技有限公司 The generation method of credible random number sequence in a kind of block chain

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107392770A (en) * 2017-08-09 2017-11-24 北京云知科技有限公司 A kind of random-number generating method and system based on block chain
CN109558112A (en) * 2018-11-14 2019-04-02 杭州复杂美科技有限公司 Random digit generation method, anti-cheating block catenary system, equipment and storage medium
CN109583892A (en) * 2018-11-21 2019-04-05 安徽高山科技有限公司 A kind of random number selecting method in block chain
CN109934583A (en) * 2019-03-04 2019-06-25 安徽高山科技有限公司 The generation method of credible random number sequence in a kind of block chain

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110955407A (en) * 2019-11-21 2020-04-03 杭州趣链科技有限公司 Random number taking method based on block chain
CN110990808A (en) * 2019-11-21 2020-04-10 杭州趣链科技有限公司 Notarization number shaking method based on block chain
CN110955407B (en) * 2019-11-21 2022-04-01 杭州趣链科技有限公司 Random number taking method based on block chain
CN110990808B (en) * 2019-11-21 2022-04-01 杭州趣链科技有限公司 Notarization number shaking method based on block chain
CN113055175A (en) * 2021-06-02 2021-06-29 杭州链城数字科技有限公司 Private key distribution method of distributed CA and electronic device
CN113055175B (en) * 2021-06-02 2021-08-06 杭州链城数字科技有限公司 Private key distribution method of distributed CA and electronic device

Also Published As

Publication number Publication date
CN110336668B (en) 2022-02-11

Similar Documents

Publication Publication Date Title
CN110336668A (en) A kind of random digit generation method, device and application, equipment and storage medium
US11232081B2 (en) Methods and apparatus for a distributed database within a network
TWI695331B (en) Random object selection method and device based on blockchain
CA2996714C (en) Methods and apparatus for a distributed database within a network
CN109544334A (en) A kind of network scalability block chain implementation method
KR102094066B1 (en) Method and device for processing data for mobile games
CN109985389B (en) Cheating-preventing method and system for card games based on intelligent block chain contracts
CN108512650A (en) Dynamic Hash calculation method, apparatus, node and storage medium towards block chain
US20220189254A1 (en) Information processing program, information processing device, and information processing system
CN107579814A (en) Device, computing chip, the digging ore deposit machine of the computational methods of proof of work
CN108230047A (en) Data processing method of drawing a lottery and device
Vega-Oliveros et al. Rumor propagation with heterogeneous transmission in social networks
Miyaji et al. The evolution of fairness in the coevolutionary ultimatum games
He et al. Consensus mechanism design based on structured directed acyclic graphs
CN110772794B (en) Intelligent game processing method, device, equipment and storage medium
CN110648447B (en) Game random number generation method, application, device, equipment and storage medium
CN108572978A (en) Method and computer system of the structure for the inverted index structure of block chain
CN113230665A (en) Resource allocation method and device
CN108553904A (en) A kind of game matching process, device, electronic equipment and medium
CN110515591A (en) Random digit generation method and device based on block chain
Paul Randomised fast no‐loss expert system to play tic‐tac‐toe like a human
Negrevergne et al. Distributed nested rollout policy for samegame
Li et al. Improved Feature Learning: A Maximum‐Average‐Out Deep Neural Network for the Game Go
Tagiew Multi-agent petri-games
US20220080322A1 (en) Information processing program, information processing device, and information processing system

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