Common recognition method for building up, block catenary system and storage medium based on lottery mechanism
Technical field
The present invention relates to block chain technical field, more particularly to a kind of common recognition method for building up, block based on lottery mechanism
Catenary system and storage medium.
Background technology
Block chain is the distributed data base system participated in by node, can also be understood as account book system, be by area
All nodes in block chain network each independently compete what is completed.Common recognition mechanism is the core of block chain technology, and it causes block
The account book system of such a decentralization of chain becomes possibility, and common recognition mechanism and two central factors of decentralization are in block chain
Raw ability is able to the key extended.
In the structural system of centralization, the common recognition of system is determined by center, and each participant only needs to obey this center
, therefore the foundation known together is extremely efficient, and in the structural system of decentralization, due to each participant of system
It is equal, how to reach common understanding when there is difference just into problem.
The modes such as the block chain common recognition mechanism of generally use includes proof of work at present, rights and interests prove.Wherein, rights and interests are demonstrate,proved
Bright core is realized as follows:Accounting nodes are attached within a block by the address of oneself when producing new block, to prove that it occupies
Rights and interests ratio, accounting nodes are also required to corresponding to the address that private key is to Partial Block Information Signature simultaneously, to prove that its is true
Possess the assets of the address in fact.This common recognition mechanism is tended to occupy the big node of rights and interests in systems, is easily caused corruption, unfavorable
Block chain is used in receiving more multi-population.
The content of the invention
It is a primary object of the present invention to provide a kind of common recognition method for building up based on lottery mechanism, it is intended to solve rights and interests card
Bright common recognition mechanism is tended to occupy the big node of rights and interests in systems, is easily caused corruption, is unfavorable for receiving more multi-population to use area
The technical problem of block chain.
To achieve the above object, the present invention provides a kind of common recognition method for building up based on lottery mechanism, and methods described includes:
The accounting nodes of last position block in block chain are determined, based on the accounting nodes of last position block, obtain packet, it is described
Packet comprises at least the transaction data for the block to be accessed for preparing to be connected with last position block;
The packet and this node based on acquisition carry out Hash operation and obtain the first candidate Kazakhstan from the node data deposited
Uncommon value;
Second candidate's cryptographic Hash of other node broadcasts is obtained, according to the first preset rules in the first candidate cryptographic Hash
With selection target cryptographic Hash in second candidate's cryptographic Hash, the node of the target cryptographic Hash is the book keeping operation section of the block to be accessed
Point.
In one of the embodiments, it is described according to preset rules in first candidate's cryptographic Hash and second candidate's cryptographic Hash
The step of selection target cryptographic Hash, includes:
Candidate's cryptographic Hash of minimum, the minimum candidate are determined in the first candidate cryptographic Hash and second candidate's cryptographic Hash
Cryptographic Hash is target cryptographic Hash.
In one of the embodiments, the packet based on acquisition and this node enter from the node data deposited
Row Hash operation, which obtains the step of first candidate's cryptographic Hash, to be included:
The transaction data of block to be accessed in the packet is obtained, the characteristic value based on the transaction data and last position block
Hash operation is carried out, obtains the first cryptographic Hash;
First cryptographic Hash is signed based on the private key deposited certainly, first cryptographic Hash after signature is breathed out
Uncommon computing, obtains first candidate's cryptographic Hash.
In one of the embodiments, include after the step of acquisition packet:
According to the historical trading data in block chain, verify whether the transaction data of block to be accessed in the packet is complete
Portion is effective;
If the transaction data of block to be accessed is all effective described in the packet, the data based on acquisition are performed
Bag and this node carry out the step for Hash operation obtains first candidate's cryptographic Hash from the node data deposited.
In one of the embodiments, wrapped after the step of second candidate's cryptographic Hash of other node broadcasts of acquisition
Include:
Based on the first candidate cryptographic Hash and second candidate's cryptographic Hash, judge that described first waits according to the second preset rules
Select whether cryptographic Hash meets broadcast conditional;
If the first candidate cryptographic Hash meets broadcast conditional, by the first candidate cryptographic Hash to the block chain institute
Block chain network broadcast.
In one of the embodiments, it is described to judge whether the first candidate cryptographic Hash meets according to the second preset rules
The step of broadcast conditional, includes:
The second preset rules are parsed, when analysis result is that minimum candidate's cryptographic Hash in candidate's cryptographic Hash is target cryptographic Hash
When, if the first candidate cryptographic Hash is less than the second candidate cryptographic Hash, the first candidate cryptographic Hash meets broadcast bar
Part.
In one of the embodiments, the accounting nodes for determining last position block in block chain, based on last position block
Accounting nodes, obtain packet the step of before include:
The accounting nodes of the last position block determine the transaction data for the block to be accessed that preparation is connected with last position block;
The transaction data of the accounting nodes of last position block based on the block to be accessed, packet is generated, this is counted
Broadcasted according to bag to the block chain network where block chain.
In one of the embodiments, the number of deals of the accounting nodes of last position block based on the block to be accessed
According to, generate packet, by the packet to where block chain block chain network broadcast the step of include:
Characteristic value of the accounting nodes of the last position block based on the transaction data and last position block, carry out Hash operation
Obtain the second cryptographic Hash;
The accounting nodes of the last position block are based on the transaction data, characteristic value and the second cryptographic Hash generation packet,
And the packet is broadcasted to the block chain network where the block chain.
In addition, to achieve the above object, the present invention also provides a kind of block catenary system, the block catenary system includes multiple
Node, the node include:Memory, processor and it is stored in the base that can be run on the memory and on the processor
Program is established in the common recognition of lottery mechanism, the common recognition based on lottery mechanism is realized when establishing program by the computing device
The step of common recognition method for building up based on lottery mechanism as described above.
In addition, to achieve the above object, the present invention also provides a kind of storage medium, is stored with and is based in the storage medium
The common recognition of lottery mechanism establishes program, and the common recognition based on lottery mechanism is established and realized as described above when program is executed by processor
The step of common recognition method for building up based on lottery mechanism.
Accounting nodes of the embodiment of the present invention based on last position block determine the transaction data of block to be accessed, composition data
Bag, because what the accounting nodes of last position block were to determine, the transaction data of the block to be accessed has necessarily unique
Property and certainty, and then cause block to be accessed uniquely determine, be easy to the smooth establishment of the block to be accessed;By block chain network
In each node be based on respective node data and the packet and carry out Hash operation obtaining candidate's cryptographic Hash (first candidate's cryptographic Hash
With second candidate's cryptographic Hash) because the irreversible feature of hash algorithm, it is ensured that candidate's cryptographic Hash completely unidirectionally can not be pre-
Survey, though accounting nodes of the packet based on last position block and determine, therefore the accounting nodes of the last position block can not also adjust
The node data of oneself causes the candidate's cryptographic Hash of oneself to turn into target cryptographic Hash with cheating mode, thus eliminates last position block
The possibility done evil of accounting nodes, meanwhile, candidate's cryptographic Hash is completely unidirectional unpredictable, can further enhance candidate's cryptographic Hash
Randomness, that is, ensure that the accounting nodes of block to be accessed randomly generate so that each node is in competition book keeping operation power in block chain
When not because calculate the other factors such as power or rights and interests and be in weak position, ensure block chain in each node completely coequally competition keeps accounts
Power, can encourage more people to participate in block chain, be advantageous to the promotion and application of block chain;Because of irreversible, the Kazakhstan of Hash operation
Uncommon value it is unpredictable so that the selection of accounting nodes is similar to a kind of lottery mechanism, therefore this programme principal name is based on taking out
The common recognition method for building up of label mechanism;Unique target cryptographic Hash is determined in candidate's cryptographic Hash, and then determines to broadcast this only
The node of one target candidate cryptographic Hash is the accounting nodes of block to be accessed, and then reaches block chain common recognition.
Brief description of the drawings
Fig. 1 is the block catenary system schematic diagram of the embodiment of the present invention;
Fig. 2 is the nodal terminal structural representation of the embodiment of the present invention;
Fig. 3 is the schematic flow sheet of common recognition method for building up first embodiment of the present invention based on lottery mechanism;
Fig. 4 is the schematic flow sheet of common recognition method for building up 3rd embodiment of the present invention based on lottery mechanism;
Fig. 5 is the schematic flow sheet of common recognition method for building up fiveth embodiment of the present invention based on lottery mechanism;
Fig. 6 is the schematic flow sheet after the embodiment of the present invention refines the step S51 in Fig. 5;
Fig. 7 is the schematic diagram of a scenario of common recognition method for building up sixth embodiment of the present invention based on lottery mechanism;
Fig. 8 is the schematic flow sheet of common recognition method for building up sixth embodiment of the present invention based on lottery mechanism;
Fig. 9 is the schematic flow sheet of common recognition method for building up seventh embodiment of the present invention based on lottery mechanism.
The realization, functional characteristics and advantage of the object of the invention will be described further referring to the drawings in conjunction with the embodiments.
Embodiment
It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, it is not intended to limit the present invention.
In follow-up description, the suffix using such as " module ", " part " or " unit " for representing element is only
Be advantageous to the explanation of the present invention, itself there is no a specific meaning.Therefore, " module ", " part " or " unit " can mix
Ground uses.
As shown in figure 1, Fig. 1 is the block catenary system schematic diagram of the embodiment of the present invention.
The block catenary system includes multiple nodes, and when creating new block, some or some nodes perform specific program
Or specific function, the embodiment of the present invention are designated as accounting nodes, other nodes in block catenary system are ordinary node, each
The block created has the accounting nodes of its determination.Accounting nodes and ordinary node are not fixed, specific some sections
Point, but can be changed according to the common recognition algorithm of block chain.
The accounting nodes, are used for:
It is determined that prepare the transaction data of block to be accessed being connected with last position block;
Based on the transaction data of the block to be accessed, packet is generated, by the packet to the block where block chain
Chain network is broadcasted.
The accounting nodes or ordinary node, are used for:
The accounting nodes of last position block in block chain are determined, based on the accounting nodes of last position block, obtain packet, it is described
Packet comprises at least the transaction data for the block to be accessed for preparing to be connected with last position block;
The packet and this node based on acquisition carry out Hash operation and obtain the first candidate Kazakhstan from the node data deposited
Uncommon value;
Second candidate's cryptographic Hash of other node broadcasts is obtained, according to the first preset rules in the first candidate cryptographic Hash
With selection target cryptographic Hash in second candidate's cryptographic Hash, the node of the target cryptographic Hash is the book keeping operation section of the block to be accessed
Point.
The nodal terminal can be server, PC or smart mobile phone, tablet personal computer, E-book reader,
MP3 (Moving Picture Experts Group Audio Layer III, dynamic image expert's compression standard audio aspect
3) player, MP4 (Moving Picture Experts Group Audio Layer IV, dynamic image expert's compression standard
Audio aspect 3) player, pocket computer etc. have the packaged type terminal device of display function.
As shown in Fig. 2 the node can include:Processor 1001, such as CPU, communication bus 1002, user interface
1003, network interface 1004, memory 1005.Wherein, communication bus 1002 is used to realize the connection communication between these components.
User interface 1003 can include display screen (Display), input block such as keyboard (Keyboard), optional user interface
1003 can also include wireline interface, the wave point of standard.Network interface 1004 can optionally connect including the wired of standard
Mouth, wave point (such as WI-FI interfaces).Memory 1005 can be high-speed RAM memory or stable memory
(non-volatile memory), such as magnetic disk storage.Memory 1005 optionally can also be independently of aforementioned processor
1001 storage device.
It will be understood by those skilled in the art that the nodal terminal knot shown in the constituent system components shown in Fig. 1, Fig. 2
The restriction of structure, not structure paired systems or nodal terminal, parts more more or less than diagram can be included, or combined some
Part, or different parts arrangement.
As shown in Fig. 2 in the present embodiment, the nodal terminal includes processor 1001, communication bus 1002, user interface
1003, network interface 1004, memory 1005.A kind of memory 1005 as computer-readable storage medium is included based on lot
The common recognition of mechanism establishes program.
In the terminal shown in Fig. 2, network interface 1004 is mainly used in connecting background server, is carried out with background server
Data communicate;User interface 1003 is mainly used in connecting client (user terminal), enters row data communication with client.
And processor 1001 can be used for calling the common recognition based on lottery mechanism stored in memory 1005 to establish program,
And perform following operate:
The accounting nodes of last position block in block chain are determined, based on the accounting nodes of last position block, obtain packet, it is described
Packet comprises at least the transaction data for the block to be accessed for preparing to be connected with last position block;
The packet and this node based on acquisition carry out Hash operation and obtain the first candidate Kazakhstan from the node data deposited
Uncommon value;
Second candidate's cryptographic Hash of other node broadcasts is obtained, according to the first preset rules in the first candidate cryptographic Hash
With selection target cryptographic Hash in second candidate's cryptographic Hash, the node of the target cryptographic Hash is the book keeping operation section of the block to be accessed
Point.
The step according to preset rules selection target cryptographic Hash in first candidate's cryptographic Hash and second candidate's cryptographic Hash
Suddenly include:
Candidate's cryptographic Hash of minimum, the minimum candidate are determined in the first candidate cryptographic Hash and second candidate's cryptographic Hash
Cryptographic Hash is target cryptographic Hash.
The packet based on acquisition and this node carry out Hash operation and obtain the first time from the node data deposited
The step of selecting cryptographic Hash includes:
The transaction data of block to be accessed in the packet is obtained, the characteristic value based on the transaction data and last position block
Hash operation is carried out, obtains the first cryptographic Hash;
First cryptographic Hash is signed based on the private key deposited certainly, first cryptographic Hash after signature is breathed out
Uncommon computing, obtains first candidate's cryptographic Hash.
Also include after the step of acquisition packet:
According to the historical trading data in block chain, verify whether the transaction data of block to be accessed in the packet is complete
Portion is effective;
If the transaction data of block to be accessed is all effective described in the packet, perform described based on described in acquisition
Packet and this node carry out the step for Hash operation obtains first candidate's cryptographic Hash from the node data deposited.
Also include after the step of second candidate's cryptographic Hash of other node broadcasts of acquisition:
Based on the first candidate cryptographic Hash and second candidate's cryptographic Hash, judge that described first waits according to the second preset rules
Select whether cryptographic Hash meets broadcast conditional;
If the first candidate cryptographic Hash meets broadcast conditional, by the first candidate cryptographic Hash to the block chain institute
Block chain network broadcast.
It is described to judge that the step of whether the first candidate cryptographic Hash meets broadcast conditional includes according to the second preset rules:
The second preset rules are parsed, when analysis result is that minimum candidate's cryptographic Hash in candidate's cryptographic Hash is target cryptographic Hash
When, if the first candidate cryptographic Hash is less than the second candidate cryptographic Hash, the first candidate cryptographic Hash meets broadcast bar
Part.
The accounting nodes for determining last position block in block chain, based on the accounting nodes of last position block, obtain packet
The step of before include:
The accounting nodes of the last position block determine the transaction data for the block to be accessed that preparation is connected with last position block;
The transaction data of the accounting nodes of last position block based on the block to be accessed, packet is generated, this is counted
Broadcasted according to bag to the block chain network where block chain.
The transaction data of the accounting nodes of last position block based on the block to be accessed, packet is generated, this is counted
The step of being broadcasted according to bag to the block chain network where block chain includes:
Characteristic value of the accounting nodes of the last position block based on the transaction data and last position block, carry out Hash operation
Obtain the second cryptographic Hash;
The accounting nodes of the last position block are based on the transaction data, characteristic value and the second cryptographic Hash generation packet,
And the packet is broadcasted to the block chain network where the block chain.
Reference picture 3, it is described to be based on Sortition machine in common recognition method for building up first embodiment of the present invention based on lottery mechanism
The common recognition method for building up of system includes:
Step S10, the accounting nodes of last position block in block chain are determined, based on the accounting nodes of last position block, obtain number
According to bag, the packet comprises at least the transaction data for the block to be accessed for preparing to be connected with last position block;
For ease of understanding the present invention program, block chain relevant feature is simply introduced first below.
Broadly, block chain technology is verified with data storage, saved using distribution using block linked data structure
Point common recognition algorithm ensures the safety of data transfer and access to generate and update the data, using the mode of cryptography, using by certainly
Dynamicization scripted code composition intelligent contract come program and a kind of brand-new distributed basis framework of operation data with calculate model
Formula.
For narrow sense, block chain be a string using cryptography methods it is associated caused by data block, be it is a kind of according to when
Between order by data block a kind of linked data structure for being combined into a manner of being sequentially connected.Friendship is included in each data block
Easy information, each transaction in block chain is all connected by cryptography method with two neighboring block, therefore can be traced and be taken office
The history of what transaction, therefore checking and the next block of generation of effectiveness of information can be realized.
Block chain network is the end to end network collectively constituted by numerous nodes, and every equipment can all be used as a section
Point, a set of common recognition mechanism is based between node, whole block chain is safeguarded jointly by competing to calculate.Node can obtain complete block
Chain copy (block chain in the narrow sense, equivalent to database), this node is generally via node, also can only fetching portion block
Chain copy, such as only conservation zone build information, that is tried to locate by following up a clue by way of P2P (point-to-point) finds via node, so as to search
Rope is to information needed.
All data messages in block chain are disclosed, and All Activity is visible to all nodes on block chain.Block chain
Each block have respective accounting nodes.
Block chain in the present embodiment is block chain in the narrow sense, i.e., sequentially in time by data block with sequentially connected
A kind of linked data structure for being combined into of mode.Last position block refers to the newest caused block of block chain, from block chain
Said in chain structure, last position block refers to last block of block chain.Block to be accessed in the present embodiment refers to and will created
But the new block not yet created.
Accounting nodes of the prior art refer to the node for creating block, and the node can be single or multiple (multiple
Situation be group's form).But in the present embodiment, the accounting nodes of last position block are not necessarily referring to determine last position block transaction data
Node, and refer to determine block transaction data to be accessed, the node that has with last position block nominal book keeping operation relation, Mo Wei areas
Block determines, what the accounting nodes of last position block were also to determine.The accounting nodes of last position block in block chain are determined, including are not limited to
Following manner:It can be determined by inquiring about the signing messages on the last position block, if for example, having certain node on the last position block
Private key signature, then the node be last position block accounting nodes.
Packet in the present embodiment, determined including at least the accounting nodes of last position block, preparation connect with last position block
The transaction data of the block to be accessed connect, packet include but is not limited to following several building forms:The packet can be only
Include the transaction data of block to be accessed;It can be the cryptographic Hash for obtaining the transaction data progress Hash operation of block to be accessed
With the set of the transaction data of the block to be accessed;Can also be by the transaction data of block to be accessed and other data, such as
The characteristic value of last position block, Discontinuous Factors carry out cryptographic Hash and the transaction data of the block to be accessed that Hash operation obtains
Set, wherein the characteristic value of last position block can refer to the cryptographic Hash that the transaction data of last position block is carried out Hash operation and obtained.
In the present embodiment, by accounting nodes of each node in block chain network based on last position block, packet, end are obtained
The accounting nodes of position block can also obtain the packet, participate in election contest (now, the Mo Wei areas of block accounting nodes to be accessed
The accounting nodes of block directly can carry out next step operation to the packet), it can also be excluded outside election contest.Common section
Point directly receives the packet of the accounting nodes broadcast of last position block.
Step S11, the packet based on acquisition and this node carry out Hash operation and obtain the from the node data deposited
One candidate's cryptographic Hash;
In the present embodiment, node data can not change in a short time for determine, node, solely belong in a degree
Can be node private key in the data of node, or other node identification informations.
Each node of block chain receive the packet after (if the accounting nodes of last position block participate in election contest, last position block
Accounting nodes directly carry out subsequent operation to being stored in local packet), can be according in the data that the packet includes
Hold and determine to operate in next step, can be directly to the area to be accessed if the packet only includes the transaction data of block to be accessed
The transaction data of block is necessarily operated, if the packet also includes other in addition to the transaction data including block to be accessed
Value, then all or part of content in the packet can be carried out after necessarily operating, the node data with depositing certainly is breathed out
Uncommon computing.
Based on the packet and the node data deposited certainly, Hash operation is carried out, can be directly by the packet bag
The all the elements contained and respective node data carry out Hash operation or node data or the packet are carried out into phase
Hash operation is carried out again after the processing of pass.
The relevant treatment can include but is not limited to:
If the packet only includes the transaction data of block to be accessed, the transaction data can be subjected to Hash operation and obtained
To cryptographic Hash, the cryptographic Hash and node data are subjected to Hash operation again and obtain first candidate's cryptographic Hash (referred to hereinafter as HASH1);
Or transaction data progress Hash operation is obtained into cryptographic Hash, the cryptographic Hash+transaction data+node data is carried out again
Hash operation obtains HASH1.
If the packet includes the transaction data of block to be accessed and the cryptographic Hash of the transaction data, it can be only selected
In transaction data, the cryptographic Hash and node data are subjected to Hash operation again and obtain HASH1;Or can be by the transaction data
Time cryptographic Hash is obtained after carrying out Hash operation with the cryptographic Hash of the transaction data, this cryptographic Hash+node data is subjected to Hash
Computing, obtain HASH1.
If the packet not only includes the transaction data of block to be accessed and the cryptographic Hash of the transaction data, in addition to its
The characteristic value of his data, such as last position block, then after some of which data being carried out into Hash operation, then by Hash result and node
Data carry out Hash operation and obtain HASH1.
Also after node data and the packet being carried out into some computings, Hash operation is carried out to operation result, obtained
HASH1.For example, if node data is private key, can be used after private key signs to the packet, then by the information after signature
Carry out Hash operation.
The node that first candidate's cryptographic Hash (i.e. HASH1) in the present embodiment refers in block chain network is kept accounts for competition weighs institute
Caused cryptographic Hash.
Step S12, second candidate's cryptographic Hash of other node broadcasts is obtained, waited according to the first preset rules described first
Selection target cryptographic Hash in cryptographic Hash and second candidate's cryptographic Hash is selected, the node of the target cryptographic Hash is the block to be accessed
Accounting nodes.
Second candidate's cryptographic Hash (referred to hereinafter as HASH2) in the present embodiment refers to, and is produced relative to other nodes of this node
Cryptographic Hash.As there is the node of A, B, C, D tetra- in block chain network, from A angle, candidate's cryptographic Hash caused by A oneself is the
One candidate's cryptographic Hash (HASH1), candidate's cryptographic Hash caused by B, C, D are second candidate's cryptographic Hash (HASH2), but if station is in B
Angle, candidate's cryptographic Hash caused by B oneself is HASH1, and candidate's cryptographic Hash caused by A, C, D is HASH2.Candidate's cryptographic Hash refers to
The cryptographic Hash that each node generates to compete book keeping operation power in block chain network.First, second in the present embodiment is only to distinguish
Candidate's cryptographic Hash caused by this node and other nodes.HASH2 can have multiple.
The first preset rules in the present embodiment are the rules for determining target cryptographic Hash, can be stored in block chain
In particular address, first preset rules can be directly invoked when needing and electing accounting nodes.
A unique Hash should can be selected in multiple candidate's cryptographic Hash according to first preset rules
Be worth (i.e. target cryptographic Hash), can be candidate's cryptographic Hash in maximum, or according to special algorithm determination size sequence number, such as
All candidate's cryptographic Hash are subjected to size sequence, determine that n-th candidate cryptographic Hash is target cryptographic Hash according to special algorithm.The mesh
The node of mark cryptographic Hash refers to the node for broadcasting the target cryptographic Hash.
Each node can obtain the candidate's cryptographic Hash broadcasted in block chain, so it is determined that during target cryptographic Hash, block
Each node can select target cryptographic Hash according to the first preset rules in all candidate's cryptographic Hash in chain.
Alternatively, mesh is selected in first candidate's cryptographic Hash and second candidate's cryptographic Hash according to preset rules in step S12
The step for marking cryptographic Hash includes:
Step S13, candidate's cryptographic Hash of minimum is determined in the first candidate cryptographic Hash and second candidate's cryptographic Hash, should
Minimum candidate's cryptographic Hash is target cryptographic Hash.
In the present embodiment, the first preset rules provide that candidate's cryptographic Hash of minimum is target cryptographic Hash.
Each node produces all second candidate cryptographic Hash (HASH2 more than one) of reception and respective node in block chain
First candidate's cryptographic Hash (HASH1) carry out size comparison (also including the comparison between HASH2), select wherein minimum Hash
Value, i.e. target cryptographic Hash.
Minimum candidate's cryptographic Hash is defined as target cryptographic Hash by the present embodiment, because size judges easily to realize, meter
Calculation amount is little, and the present embodiment is easier to realize, meanwhile, the present embodiment specify that target cryptographic Hash is established rules then really, further determine that
The accounting nodes of block to be accessed.
In the present embodiment, the accounting nodes based on last position block determine the transaction data of block to be accessed, composition data
Bag, because what the accounting nodes of last position block were to determine, the transaction data of the block to be accessed has necessarily unique
Property and certainty, and then cause block to be accessed uniquely determine, be easy to the smooth establishment of the block to be accessed;
Respective node data is based on by each node in block chain network and the packet carries out Hash operation and obtains candidate
Cryptographic Hash (first candidate's cryptographic Hash and second candidate's cryptographic Hash), because the irreversible feature of hash algorithm, it is ensured that candidate
Cryptographic Hash is completely unidirectional unpredictable, though accounting nodes of the packet based on last position block and determine, the note of the last position block
Therefore account node can not also adjust the node data of oneself and cause the candidate's cryptographic Hash of oneself to turn into target Hash with cheating mode
Value, thus the possibility that the accounting nodes for eliminating last position block are done evil, meanwhile, candidate's cryptographic Hash is completely unidirectional unpredictable, can
The randomness of candidate's cryptographic Hash is further enhanced, that is, ensures that the accounting nodes of block to be accessed randomly generate so that block
Each node is not temporary in weak position in competition book keeping operation because calculating the other factors such as power or rights and interests in chain, ensures each in block chain
Node completely coequally weighed by competition book keeping operation, and more people can be encouraged to participate in block chain, be advantageous to the promotion and application of block chain;
It is irreversible because of Hash operation, cryptographic Hash it is unpredictable so that the selection of accounting nodes is similar to a kind of lottery mechanism, thus this
Scheme principal name is the common recognition method for building up based on lottery mechanism;
In the determination unique candidate cryptographic Hash in selecting cryptographic Hash, and then determine to broadcast the node of the unique candidate cryptographic Hash
For the accounting nodes of block to be accessed, and then reach block chain common recognition.
In common recognition method for building up second embodiment of the embodiment of the present invention based on lottery mechanism, first based on this method is real
Example is applied, step S11 includes:
Step S20, the transaction data of block to be accessed in the packet is obtained, based on the transaction data and last position block
Characteristic value carry out Hash operation, obtain the first cryptographic Hash;
Step S21, first cryptographic Hash is signed based on the private key deposited certainly, by first Hash after signature
Value carries out Hash operation, obtains first candidate's cryptographic Hash.
In order to determine the uniqueness of block to be accessed, its transaction data need to be determined by certain specific node, in the present embodiment, when
The transaction data of preceding block determines that the transaction data of block that is, to be accessed is by last position block by the accounting nodes of a upper block
Accounting nodes determine, after the accounting nodes of last position block determine the transaction data of block to be accessed, it is waiting will to comprise at least this
The packet for entering the transaction data of block is broadcasted to block chain network.
In the present embodiment, the characteristic value of last position block refers to all the elements for being included last position block and carries out Hash operation institute
The cryptographic Hash of acquisition or the cryptographic Hash for being obtained the set progress Hash operation of last position block transaction data.
The characteristic value of transaction data and last position block based on the block to be accessed carries out Hash operation, can refer to direct incite somebody to action
The characteristic value of the transaction data of the block to be accessed and last position block carries out Hash operation, can also refer to the friendship of the block to be accessed
Easy data and the characteristic value of last position block carry out processing early stage and carry out Hash operation again, and early stage, processing can refer to the block to be accessed
Transaction data carry out a Hash operation.
Each node can obtain block chain copy in block chain network, so, the characteristic value of last position block can be obtained voluntarily.
Because the first cryptographic Hash, which is the characteristic value of transaction data and last position block based on access block, carries out Hash operation acquisition, institute
So that the first cryptographic Hash is equal caused by all nodes in block chain network.
After obtaining the first cryptographic Hash, each node is signed using the private key of oneself to the first cryptographic Hash in block chain network
Name, then the first cryptographic Hash after signature is subjected to Hash operation, obtain HASH1.
In the present embodiment, the first cryptographic Hash is generated by transaction data of each node based on block to be accessed in packet,
Signature result based on private key to first cryptographic Hash again, generates candidate's cryptographic Hash for election contest, because Hash operation
Irreversibility, twice Hash operation can further enhance the unpredictability of cryptographic Hash, the accounting nodes of last position block can be prevented
Do evil, can also ensure the random generation of candidate's cryptographic Hash, election contest accounting nodes can completely random, the fair election contest of each node, chance
Equality, attract more people to use block chain, promote the development of block chain.
Reference picture 4, in common recognition method for building up 3rd embodiment of the present invention based on lottery mechanism, based on this method
One embodiment or second embodiment, step S10 also include afterwards:
Step S30, the historical trading data inquired about in block chain;
Step S31, according to the historical trading data in block chain, verify the number of deals of block to be accessed in the packet
According to whether all effective;
Step S32, if the transaction data of block to be accessed is all effective described in the packet, execution is described to be based on obtaining
The packet and this node taken carries out the step of Hash operation obtains first candidate's cryptographic Hash from the node data deposited;
Step S33, it is described if invalid transaction data described in the packet in the transaction data of block to be accessed be present
Packet is invalid, redefines the accounting nodes of last position block.
The packet is parsed, first verifies that whether the transaction data of block to be accessed therein is all effective, because often
Include Transaction Information in one block, each transaction in block chain all passes through cryptography method and two neighboring block string
Connection, therefore the history of any transaction can be traced back to, so the complete block chain deposited certainly or portion can be passed through by respectively participating in node
Whether the historical trading data stored in blockette chain, verifying the transaction data of the block to be accessed in the data all has
Effect.
If the transaction data is all effective, Hash operation is carried out based on the packet and the node data deposited certainly,
All the elements in the packet and the node data deposited certainly directly can be subjected to Hash operation, also can be by the packet
Partial content and the node data deposited certainly carry out Hash operation, also the packet and the node data deposited certainly can be carried out into early stage
Processing carries out Hash operation again, for example, the transaction data of the block to be accessed in the packet is obtained, by the packet
The transaction data of block to be accessed obtains cryptographic Hash after carrying out Hash operation, after each node is signed the cryptographic Hash using private key,
Signature result is subjected to Hash operation.
It is if in the packet in the transaction data of block to be accessed, invalid transaction data be present, then because described waiting
The transaction data for entering block is that the accounting nodes based on last position block obtain, and invalid transaction occurs, then explanation has Mo Wei areas
The accounting nodes of block are done evil to reduce evil node to dislike the possibility of node, the accounting nodes of last position block are necessarily punished.
Punitive measures can impose a fine, and can also deprive book keeping operation power, need to redefine the accounting nodes of last position block.
The present embodiment verifies whether the transaction data of block to be accessed in the packet is all effective, if institute in the packet
It is all effective to state the transaction data of block to be accessed, then the packet is digitally signed, then by the packet after signing
Hash operation is carried out, obtains first candidate's cryptographic Hash, participates in election contest;If invalid transaction data in the packet be present, because
Transaction data in the packet determines by the accounting nodes of last position block, so, the accounting nodes that the last position block be present are
The possibility of node is disliked, so the packet that the accounting nodes of the last position block determine is invalid, redefines the book keeping operation of last position block
Node, thus by verifying the validity of the transaction data, exclude to dislike the possibility that node is done evil, it can also increase and dislike node
Do evil cost, done evil possibility with reducing node, safeguard the normal operation of block chain;Meanwhile based on the packet and each node
Hash operation is carried out from the unique node data deposited, it is ensured that obtains unique first candidate cryptographic Hash, it is ensured that subsequently only
The determination of one target cryptographic Hash, and then successfully determine the accounting nodes of block to be accessed.
In common recognition method for building up fourth embodiment of the present invention based on lottery mechanism, the first embodiment based on this method
Either second embodiment or 3rd embodiment, the step of obtaining second candidate's cryptographic Hash of other node broadcasts in step S12
Also include afterwards:
Step S40, based on the first candidate cryptographic Hash and second candidate's cryptographic Hash, judge institute according to the second preset rules
State whether first candidate's cryptographic Hash meets broadcast conditional;
The second preset rules in the present embodiment refer to the rule for determining target cryptographic Hash.Second preset rules can deposit
Storage is in the particular address of block chain, when it needs to be determined that can directly invoke second preset rules during accounting nodes.This is second pre-
If rule can be, but not limited to for:Select candidate's cryptographic Hash maximum in candidate's cryptographic Hash;Select minimum candidate's cryptographic Hash;Root
The unique candidate cryptographic Hash obtained according to certain algorithm.
Broadcast conditional in the present embodiment need to determine according to the second preset rules.Such as:Second preset rules are waited to obtain
Candidate's cryptographic Hash maximum in cryptographic Hash is selected, then broadcast conditional can be:First candidate's cryptographic Hash is more than second candidate's cryptographic Hash.
Specifically, judge whether the first candidate cryptographic Hash meets to broadcast bar according to the second preset rules in step S40
The step for part, includes:
Step S41, the second preset rules are parsed, when analysis result is that minimum candidate's cryptographic Hash in candidate's cryptographic Hash is mesh
When marking cryptographic Hash, if the first candidate cryptographic Hash is less than the second candidate cryptographic Hash, the first candidate cryptographic Hash expires
Sufficient broadcast conditional.
Parse the second preset rules, in the present embodiment, the second preset rules are:Minimum candidate's Hash in candidate's cryptographic Hash
It is worth for target cryptographic Hash, then broadcast conditional is that first candidate's cryptographic Hash is less than second candidate's cryptographic Hash.Because preset rules provide
Minimum candidate's cryptographic Hash is target cryptographic Hash, so, when first candidate's cryptographic Hash is more than second candidate's cryptographic Hash, this first
The impossible successful contention of the node of candidate's cryptographic Hash is weighed to book keeping operation, so, the first candidate cryptographic Hash is not necessarily to broadcast.(number
Reduced according to amount, save computing resource) if first candidate's cryptographic Hash is less than second candidate's cryptographic Hash, the first candidate cryptographic Hash
Node is it is also possible to competition now needs to broadcast the first candidate cryptographic Hash to book keeping operation power.
In the present embodiment, determine that broadcast conditional is less than second candidate's cryptographic Hash for first candidate's cryptographic Hash by preset rules,
Compare so that in block chain a wheel can be carried out first at each node, when first candidate's cryptographic Hash is less than second candidate's cryptographic Hash,
Because the still old competition of the node of first candidate's cryptographic Hash is successfully possible, the first candidate cryptographic Hash can be broadcasted, should
First candidate's cryptographic Hash meets broadcast conditional, can share the amount of calculation for determining target cryptographic Hash to each node in block chain, carry
Rise election contest efficiency.
Step S42, if the first candidate cryptographic Hash meets broadcast conditional, by the first candidate cryptographic Hash to described
Block chain network broadcast where block chain.
If the first candidate cryptographic Hash meets broadcast conditional, show that the first candidate cryptographic Hash is possible to competition and turned into
The accounting nodes of block to be accessed, then need to broadcast the first candidate cryptographic Hash to the block chain network where block chain,
To participate in the election contest of accounting nodes., need not be by first candidate's Hash if the first candidate cryptographic Hash is unsatisfactory for broadcast conditional
It is worth to the block chain network where the block chain and broadcasts
The present embodiment just carries out first round screening at each node of block chain, will campaigned for waiting by setting broadcast conditional
Enter candidate's cryptographic Hash broadcast of the promising node of block accounting nodes, amount of calculation can be reduced, lifting election contest efficiency, selected as early as possible
The accounting nodes of block to be accessed.
Reference picture 5, in common recognition method for building up fiveth embodiment of the present invention based on lottery mechanism, based on this method
Either second embodiment or 3rd embodiment or fourth embodiment, step S10 include one embodiment before:
Step S50, the accounting nodes of last position block determine the number of deals for the block to be accessed that preparation is connected with last position block
According to;
Step S51, transaction data of the accounting nodes of last position block based on the block to be accessed, packet is generated, will
The packet is broadcasted to the block chain network where block chain.
The connection that the present embodiment is determined the transaction data of block to be accessed and respectively merchandised by the accounting nodes of last position block is suitable
Sequence, and the generation packet of the transaction data based on the block to be accessed.In the present embodiment, the friendship based on the block to be accessed
Easy data generation packet, the packet should comprise at least the transaction data of block to be accessed, and packet include but unlimited
In following several building forms:The packet can only include the transaction data of block to be accessed;Can be by area to be accessed
The transaction data of block carries out cryptographic Hash and the set of the transaction data of the block to be accessed that Hash operation obtains;Can also be
By the transaction data of block to be accessed and other data, such as characteristic value of last position block or Discontinuous Factors carry out Hash operation and obtained
Cryptographic Hash and the block to be accessed transaction data set, wherein the characteristic value of last position block can refer to last position block
Transaction data carry out the obtained cryptographic Hash of Hash operation.
Generate after the packet, it is necessary to be broadcasted to block chain network, so that other nodes obtain.
The company that the present embodiment is determined the transaction data of block to be accessed and respectively merchandised by the accounting nodes by last position block
Connect order, it is ensured that the uniqueness of the transaction data of block to be accessed so that block to be accessed is successfully generated;Based on area to be accessed
The transaction data generation packet of block, broadcasts to block chain network, the election contest of block accounting nodes to be accessed can be initiated, so as to suitable
Profit selects the accounting nodes of block to be accessed.
Specifically, reference picture 6, step S51 include:
Step S52, characteristic value of the accounting nodes based on the transaction data and last position block of last position block, carry out Hash
Computing obtains the second cryptographic Hash;
Step S53, the accounting nodes of last position block are based on the transaction data, characteristic value and the second cryptographic Hash generation data
Bag, and the packet is broadcasted to the block chain network where the block chain.
The present embodiment determines a kind of building form of packet, i.e.,:Packet includes the transaction data of block to be accessed, end
The characteristic value and the second cryptographic Hash of position block.Wherein, the second cryptographic Hash refers to the transaction data of foregoing block to be accessed and last position
The characteristic value of block carries out the cryptographic Hash of Hash operation acquisition.
The present embodiment by by based on last position block accounting nodes obtain block to be accessed transaction data and last position
The characteristic value of block carries out Hash operation, and the Hash operation value and the characteristic value of the last position block, transaction data are combined into
Data packet broadcast.So that each node can carry out secondary Hash fortune based on the cryptographic Hash for containing a Hash operation in block chain
Calculate, because the irreversibility of Hash operation, Hash operation can further enhance the unpredictability of cryptographic Hash twice, can prevent end
The accounting nodes of position block are done evil;Meanwhile content of the present embodiment using the characteristic value of last position block as packet, end can be established
Position block and block to be accessed contact, and then guarantee block to be accessed and block chain contact, by the transaction of block to be accessed
A part of the data as packet, it is ensured that block to be accessed is successfully generated.
Further, for ease of understanding this programme, the sixth embodiment of the common recognition method for building up based on lottery mechanism is proposed.
If the schematic diagram of a scenario that Fig. 7 is sixth embodiment, such as Fig. 8 are the schematic flow sheet of sixth embodiment.
In block chain network, as long as node can submit the transaction data oneself recorded online, disturbance can also be submitted
The factor or what do not do.In Fig. 6, A, B, C, D are node online in block chain network, and A, B have transaction data defeated
Enter, the D input disturbance factors, C is not inputted.Fig. 6 only show part of nodes (A B C D), in addition to other unshowned nodes.
Block S shown in Fig. 6 is last position block, and N+1 blocks below are block to be accessed, middle A, B, C, D
Data input be block to be accessed transaction data.
The accounting nodes of block S are determined first, and the transaction data of block to be accessed is determined by the accounting nodes of block S
(A, B, C, D data input in such as Fig. 6), and the cryptographic Hash that the characteristic value of block S is block S is added into block to be accessed
Transaction data carry out Hash operation, obtain the first Hash result, by block S accounting nodes signature after, by described first
The transaction data of Hash result and block to be accessed is broadcasted to the block chain network where A, B, C, D node.
Each node receives the cryptographic Hash of accounting nodes broadcast and the friendship of block to be accessed of block S in block chain network
Easily after data, verify whether the transaction data of block to be accessed is all effective, if all effectively, each node uses oneself
Private key is signed to first Hash result, and signature result is carried out into Hash operation again, and each node obtains one
Second Hash result (is designated as 2HASH).
Each node carries out lot election based on the 2HASH, and its implementation process is as follows:
1. arbitrary node (such as A) broadcasts oneself and calculates 2HASH-A first;
2. other nodes (such as B) calculate the result 2HASH-B of oneself, compared with 2HASH-A;
3. if 2HASH-B<2HASH-A, then 2HASH-B is broadcasted, otherwise do not broadcast meaning (B node) lot election and lose
Lose;
Judge 4. other nodes are similar with B node, finally elect N+1 block accounting nodes.
Further, reference picture 9, for ease of understanding this programme, the of the common recognition method for building up based on lottery mechanism is proposed
Seven embodiments.
Step S50, the accounting nodes of last position block determine the number of deals for the block to be accessed that preparation is connected with last position block
According to;
Step S52, characteristic value of the accounting nodes based on the transaction data and last position block of last position block, carry out Hash
Computing obtains the second cryptographic Hash;
Step S53, the accounting nodes of last position block are based on the transaction data, characteristic value and the second cryptographic Hash generation data
Bag, and the packet is broadcasted to the block chain network where the block chain;
Step S10, the accounting nodes of last position block in block chain are determined, based on the accounting nodes of last position block, obtain number
According to bag, the packet comprises at least the transaction data for the block to be accessed for preparing to be connected with last position block;
Step S30, the historical trading data inquired about in block chain;
Step S31, according to the historical trading data in block chain, verify the number of deals of block to be accessed in the packet
According to whether all effective;
Step S32, if the transaction data of block to be accessed is all effective described in the packet, perform step S20;
Step S33, it is described if invalid transaction data described in the packet in the transaction data of block to be accessed be present
Packet is invalid, redefines the accounting nodes of last position block;
Step S20, the transaction data of block to be accessed in the packet is obtained, based on the transaction data and last position block
Characteristic value carry out Hash operation, obtain the first cryptographic Hash;
Step S21, first cryptographic Hash is signed based on the private key deposited certainly, by first Hash after signature
Value carries out Hash operation, obtains first candidate's cryptographic Hash;
Step S121, second candidate's cryptographic Hash of other node broadcasts is obtained,
Step S41, based on the first candidate cryptographic Hash and second candidate's cryptographic Hash, the second preset rules are parsed, work as solution
When analysis result is that minimum candidate's cryptographic Hash in candidate's cryptographic Hash is target cryptographic Hash, if the first candidate cryptographic Hash is less than institute
Second candidate's cryptographic Hash is stated, then the first candidate cryptographic Hash meets broadcast conditional;
Step S42, if the first candidate cryptographic Hash meets broadcast conditional, by the first candidate cryptographic Hash to described
Block chain network broadcast where block chain;
Step S13, candidate's cryptographic Hash of minimum is determined in the first candidate cryptographic Hash and second candidate's cryptographic Hash, should
Minimum candidate's cryptographic Hash is target cryptographic Hash;
Step S123, the node of the target cryptographic Hash are the accounting nodes of the block to be accessed.
In addition, the embodiment of the present invention also proposes a kind of storage medium, it is stored with the storage medium based on lottery mechanism
Common recognition establish program, the common recognition based on lottery mechanism is established and realized when program is executed by processor such as above-mentioned embodiment institute
The step of stating.Because the specific embodiment of storage medium of the present invention is essentially identical with each embodiment of above-mentioned identity identifying method,
It will not be described here.
It should be noted that can be mutual group between some features in technical characteristic described in all embodiments of the invention
Close.
Herein, term " comprising ", "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, from
And process, method, article or the system for include a series of elements not only include those key elements, but also including not bright
The other element really listed, or also include for this process, method, article or the intrinsic key element of system.Do not having
In the case of more limitations, the key element that is limited by sentence "including a ...", it is not excluded that in the process including the key element, side
Other identical element in method, article or system also be present.
The embodiments of the present invention are for illustration only, do not represent the quality of embodiment.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side
Method can add the mode of required general hardware platform to realize by software, naturally it is also possible to by hardware, but in many cases
The former is more preferably embodiment.Based on such understanding, technical scheme is substantially done to prior art in other words
Going out the part of contribution can be embodied in the form of software product, and the computer software product is stored in one as described above
In storage medium (such as ROM/RAM, magnetic disc, CD), including some instructions to cause a station terminal equipment (can be mobile phone,
Computer, server, air conditioner, or network equipment etc.) perform method described in each embodiment of the present invention.
The preferred embodiments of the present invention are these are only, are not intended to limit the scope of the invention, it is every to utilize this hair
The equivalent structure or equivalent flow conversion that bright specification and accompanying drawing content are made, or directly or indirectly it is used in other related skills
Art field, is included within the scope of the present invention.