Disclosure of Invention
In order to solve the problems, the invention provides a multi-party asynchronous sampling consensus method, a multi-party asynchronous sampling consensus system, a multi-party asynchronous sampling consensus device and a multi-party asynchronous sampling consensus medium based on a blockchain, which are suitable for different time points, and the multi-party asynchronous sampling consensus method, the multi-party asynchronous sampling consensus device, the multi-party sampling consensus medium are used for rapidly verifying data on the blockchain, so that the reliability of consensus is ensured.
To achieve the above object, the present invention provides a multi-party asynchronous sampling consensus method based on blockchain, comprising:
the multi-party asynchronous sampling consensus method based on the block chain is characterized by comprising the following steps of:
the initiating node acquires target data according to the data information and acquires a hash value A of the target data;
the initiating node performs snapshot processing on the hash value A and the data information to obtain snapshot data, and sends the snapshot data to a blockchain evidence supervisor;
the initiating node sends a consensus request to all the participating nodes, and the initiating node sends identity information of all the participating nodes to a blockchain evidence supervisor;
the participating node sends a request for acquiring data information to a blockchain evidence supervisor according to the consensus request;
the block chain evidence supervisor judges the identity information of the participating nodes and sends out snapshot data to the participating nodes with accurate identity information;
the participating node randomly acquires a section of sampling data in the target data according to the snapshot data, and acquires a hash value B of the sampling data;
by comparing the hash value A with the hash value B, whether the two are in agreement is judged.
When the method is used, the data information and the hash value A are snapped to the blockchain evidence supervision party, when the participating node needs to verify the reliability of the consensus, the blockchain evidence supervision party obtains the snap data, obtains the data information according to the snap data, performs asynchronous sampling hash calculation on the target data, compares the hash value A with the hash value B, further judges the reliability of the consensus method, and judges whether the consensus exists.
Compared with the existing consensus method, the method can use multi-party asynchronous sampling to judge, store data in a snapshot mode, has higher acquisition processing speed for more participating nodes, and can be more conveniently used under the multi-party asynchronous condition.
Preferably, the initiating node sends a consensus request to all the participating nodes, and the initiating node sends identity information of all the participating nodes to the blockchain evidence supervisor, specifically including:
the initiating node packages the blockchain evidence supervisor verification information into a first block and adds the first block into a blockchain of the initiating node;
the initiating node sends a consensus request to all the participating nodes, and the initiating node sends identity information of all the participating nodes to a blockchain evidence supervisor;
when receiving a consensus request sent by an initiating node, a participating node receives and verifies a first block, if the verification is passed, the participating node stores the first block and sends a request for acquiring data information to a blockchain evidence supervisor; discarding the first block if the verification is not passed.
When the initiating node sends a consensus request to the participating node, the participating node will first verify the identity of the initiating node, and after the identity verification is passed, the first block of the initiating node is received and stored, which also preliminarily ensures the identity accuracy of the first block and the participating node, and after the participating node receives the first block, when the participating node sends a request for acquiring data information to the blockchain evidence supervisor, the blockchain evidence supervisor will verify the identity of the participating node through the blockchain evidence supervisor verification information in the first block before sending the data information to the participating node.
Specifically, the blockchain evidence supervisor judges identity information of the participating nodes, and sends snapshot data to the participating nodes with accurate identity information, specifically comprising:
the participating node acquires block chain evidence supervision party verification information according to the first block, wherein the block chain evidence supervision party verification information comprises a public key and a private key of the block chain evidence supervision party;
the participating node acquires the address of the blockchain evidence supervision party according to the public key of the blockchain evidence supervision party verification information, and acquires the identity information of the participating node in the blockchain evidence supervision party according to the private key; the identity information of the participating nodes is that the initiating node sends a consensus request to all the participating nodes, and the initiating node sends the identity information of all the participating nodes to the blockchain evidence supervisor;
the identity information of the participating node and the identity information of the participating node in the acquired blockchain evidence supervision party are verified, and if the identity of the participating node is accurate, the blockchain evidence supervision party sends snapshot data to the participating node; if the verification is not passed, the blockchain evidence supervisor does not send the snapshot data to the participating nodes. In the operation, the identity of the participating node is doubly verified, so that the consensus credibility can be further ensured when the participating node is used.
Preferably, the participating node randomly acquires a section of sampling data in the target data according to the snapshot data, and acquires a hash value B of the sampling data, which specifically includes:
the method comprises the steps that a participating node obtains data information according to snapshot data, wherein the data information comprises a data information interface, a program language for an initiating node to obtain a hash value, a software environment parameter and a hardware environment parameter;
the participating node reads a section of data randomly in the target data of the initiating node according to the software environment parameters, the hardware environment parameters and the data interface of the snapshot data to obtain sampling data;
and obtaining the hash value B of the sampling data according to the program language of the hash value obtained by the initiating node.
Wherein, through comparing hash value A and hash value B, judge whether consensus, specifically include:
comparing the hash value A with the hash value B, and if the hash value B exists in the hash value A, enabling the participation node corresponding to the hash value B to pass through the consensus; if the hash value B does not exist in the hash value A, the participation node consensus corresponding to the hash value B does not pass;
acquiring the consensus passing rate of all the participating nodes, and if the passing rate is greater than or equal to a threshold Y, passing the consensus; if the passing rate is smaller than the threshold value Y, the consensus is not passed.
Preferably, the consensus passing rate of all the participating nodes is obtained, and if the passing rate is greater than or equal to a threshold Y, the consensus passes;
and acquiring the participation nodes which do not pass the consensus, and carrying out early warning marking on the participation nodes which do not pass the consensus.
Corresponding to the method in the invention, the invention also provides a multiparty asynchronous sampling consensus system based on block chains, which comprises the following steps:
the first data information processing module is used for the initiating node to acquire target data according to the data information and obtain a hash value A of the target data;
the block chain evidence supervision module is used for storing the hash value A, the identity information and the data information of all the participating nodes;
the judging module is used for judging the identity information of the participating node sending the request for acquiring the data information to the blockchain evidence supervisor and sending the snapshot data to the participating node with accurate identity information;
the second data information processing module is used for participating in the random acquisition of a section of sampling data in the target data according to the snapshot data and acquiring a hash value B of the sampling data;
and the comparison module is used for judging whether the hash value A and the hash value B are in common or not.
Corresponding to the method in the invention, the invention also provides an electronic device, which comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the processor realizes the steps of the multi-party asynchronous sampling consensus method based on the block chain when executing the computer program.
Corresponding to the method in the invention, the invention also provides a storage medium, and the computer readable storage medium stores a computer program, and the computer program realizes the steps of the multi-party asynchronous sampling consensus method based on the block chain when being executed by a processor.
The one or more technical schemes provided by the invention have at least the following technical effects or advantages:
according to the invention, the data information is snapshot to the blockchain evidence supervisory party, so that the computation condition of multiparty asynchronism is met, the multiparty can sample hash computation on the data according to the self environment, asynchronous hash computation is performed on the consensus data, hash verification is performed again, the consistency of the computation results is determined, the data are digitally signed after the participation nodes with the consistency of the computation results are subjected to the consensus, namely the consensus is passed, and when the consensus passing rate is greater than or equal to a threshold value, the consensus is not carried out otherwise, the problem of low data credibility in the existing blockchain network can be effectively solved by the consensus method, meanwhile, the consensus capability of the blockchain network data is enhanced, and the use efficiency can be improved by rapidly processing under the multiparty asynchronism use condition.
Detailed Description
In order that the above-recited objects, features and advantages of the present invention will be more clearly understood, a more particular description of the invention will be rendered by reference to the appended drawings and appended detailed description. In addition, the embodiments of the present invention and the features in the embodiments may be combined with each other without collision.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention, however, the present invention may be practiced in other ways than within the scope of the description, and the scope of the invention is therefore not limited to the specific embodiments disclosed below.
It will be appreciated by those skilled in the art that in the present disclosure, the terms "longitudinal," "transverse," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," "outer," etc. refer to an orientation or positional relationship based on that shown in the drawings, which is merely for convenience of description and to simplify the description, and do not indicate or imply that the apparatus or elements referred to must have a particular orientation, be constructed and operated in a particular orientation, and therefore the above terms should not be construed as limiting the present invention.
It will be understood that the terms "a" and "an" should be interpreted as referring to "at least one" or "one or more," i.e., in one embodiment, the number of elements may be one, while in another embodiment, the number of elements may be plural, and the term "a" should not be interpreted as limiting the number.
Example 1
Referring to fig. 1, fig. 1 is a flow chart of a multi-party asynchronous sampling consensus method based on a block chain, and the invention provides a multi-party asynchronous sampling consensus method based on a block chain, which comprises the following steps:
step 1, an initiating node acquires target data according to data information and acquires a hash value A of the target data;
step 2, the initiating node performs snapshot processing on the hash value A and the data information to obtain snapshot data, and sends the snapshot data to a blockchain evidence supervisor;
2.1 the initiating node packages the blockchain evidence supervisor verification information into a first block and adds the first block into the blockchain of the initiating node;
2.2, the initiating node sends a consensus request to all the participating nodes, and the initiating node sends the identity information of all the participating nodes to a blockchain evidence supervisor;
2.3 when receiving the consensus request sent by the initiating node, the participating node receives and verifies the first block, if the verification is passed, the participating node stores the first block and sends a request for acquiring data information to a blockchain evidence supervisor;
2.4 discarding the first block if the verification is not passed.
Step 3, the participating node sends a request for acquiring data information to the blockchain evidence supervision party according to the consensus request, the blockchain evidence supervision party judges the identity information of the participating node, and sends snapshot data to the participating node with accurate identity information;
3.1 the participating node obtains blockchain evidence supervision party verification information according to the first block, wherein the blockchain evidence supervision party verification information comprises a public key and a private key of the blockchain evidence supervision party;
3.2 the participating node obtains the address of the blockchain evidence supervision party according to the public key of the blockchain evidence supervision party verification information, and obtains the identity information of the participating node in the blockchain evidence supervision party according to the private key;
3.3, verifying the identity information of the participating node and the identity information of the participating node in the acquired blockchain evidence supervision party, and if the verification is passed, the blockchain evidence supervision party sends snapshot data to the participating node;
3.4 if the verification is not passed, the blockchain evidence supervisor does not send the snapshot data to the participating nodes.
Step 4, the participating node randomly acquires a section of sampling data in the target data according to the snapshot data, and acquires a hash value B of the sampling data;
4.1, the participating node acquires data information according to the snapshot data, wherein the data information comprises a data information interface, a program language for acquiring a hash value by an initiating node, a software environment parameter and a hardware environment parameter;
4.2 the participating node randomly reads a section of data in the target data of the initiating node according to the software environment parameters, the hardware environment parameters and the data interface of the snapshot data to obtain sampling data;
4.3, obtaining a hash value B of the sampling data according to a program language for obtaining the hash value by the initiating node;
and 5, judging whether the hash value A and the hash value B are in agreement or not by comparing the hash value A and the hash value B.
5.1, comparing the hash value A with the hash value B, and if the hash value B exists in the hash value A, enabling the participation node corresponding to the hash value B to pass through the consensus; if the hash value B does not exist in the hash value A, the participation node consensus corresponding to the hash value B does not pass;
5.2, acquiring the consensus passing rate of all the participating nodes, and if the passing rate is greater than or equal to a threshold Y, passing the consensus; if the passing rate is smaller than the threshold value Y, the consensus is not passed.
5.3, acquiring the consensus passing rate of all the participating nodes, and if the passing rate is greater than or equal to a threshold Y, passing the consensus;
and 5.4, acquiring the participation nodes which do not pass the consensus, and marking the participation nodes which do not pass the consensus in an early warning way.
Example two
The invention provides a multi-party asynchronous sampling consensus method based on a block chain, which comprises the following steps:
step 1, an initiating node acquires target data according to data information and acquires a hash value A of the target data; the initiating node is provided with a timer which is used for recording the time from the initiating node sending the consensus request to the snapshot data acquired by the participating node from the blockchain evidence supervision party, and the time is recorded as T1;
step 2, the initiating node performs snapshot processing on the hash value A and the data information to obtain snapshot data, and sends the snapshot data to a blockchain evidence supervisor;
2.1 the initiating node packages the blockchain evidence supervisor verification information into a first block and adds the first block into the blockchain of the initiating node;
2.2, the initiating node sends a consensus request to all the participating nodes, and the initiating node sends the identity information of all the participating nodes to a blockchain evidence supervisor;
2.3 when receiving the consensus request sent by the initiating node, the participating node receives and verifies the first block, if the verification is passed, the participating node stores the first block and sends a request for acquiring data information to a blockchain evidence supervisor;
2.4 discarding the first block if the verification is not passed.
Step 3, the participating node sends a request for acquiring data information to the blockchain evidence supervision party according to the consensus request, the blockchain evidence supervision party judges the identity information of the participating node, and sends snapshot data to the participating node with accurate identity information;
3.1 the participating node obtains blockchain evidence supervision party verification information according to the first block, wherein the blockchain evidence supervision party verification information comprises a public key and a private key of the blockchain evidence supervision party;
3.2 the participating node obtains the address of the blockchain evidence supervision party according to the public key of the blockchain evidence supervision party verification information, and obtains the identity information of the participating node in the blockchain evidence supervision party according to the private key;
3.3, verifying the identity information of the participating node and the identity information of the participating node in the acquired blockchain evidence supervision party, and if the verification is passed, the blockchain evidence supervision party sends snapshot data to the participating node;
3.4 if the verification is not passed, the blockchain evidence supervisor does not send the snapshot data to the participating nodes.
Step 4, the participating nodes verify the received snapshot data; after receiving the snapshot data, if T1 is greater than or equal to a threshold value T, the participating node does not verify the snapshot data and returns to the step 1; if T1 is smaller than a threshold T, the participating node verifies the received snapshot data, wherein the threshold T is the effective time of the consensus request;
the initiating node deploys authentication service of the snapshot data to the data service platform;
the initiating node writes a reading interface on the data service platform, wherein the reading interface is used for participating in the node to acquire the authentication content of the snapshot data;
the initiating node acquires the reading interface and the snapshot data, and stores the reading interface and the snapshot data on the blockchain through the intelligent contract;
the participating node acquires a reading interface and snapshot data through a blockchain;
the participating node writes a request model for acquiring data authentication content according to the acquired reading interface and sends the request model to the initiating node through the data service platform;
the initiating node returns the operation data to the participating node, and the participating node acquires snapshot data according to the operation data;
comparing the snapshot data acquired by the participating node according to the operation data with the snapshot data acquired by the participating node from the blockchain evidence supervisor, if the snapshot data are the same, verifying the snapshot data, randomly acquiring a section of sampling data in the target data according to the snapshot data by the participating node, and acquiring a hash value B of the sampling data; otherwise, returning to the step 1;
step 5, the participating nodes randomly acquire a section of sampling data in the target data according to the snapshot data, and acquire a hash value B of the sampling data;
5.1, the participating node acquires data information according to the snapshot data, wherein the data information comprises a data information interface, a program language for acquiring a hash value by an initiating node, a software environment parameter and a hardware environment parameter;
5.2, the participating node randomly reads a section of data in the target data of the initiating node according to the software environment parameters, the hardware environment parameters and the data interface of the snapshot data to obtain sampling data;
5.3, obtaining a hash value B of the sampling data according to a program language for obtaining the hash value by the initiating node;
and 6, judging whether the hash value A and the hash value B are in agreement or not by comparing the hash value A and the hash value B.
6.1, comparing the hash value A with the hash value B, and if the hash value B exists in the hash value A, enabling the participation node corresponding to the hash value B to pass through the consensus; if the hash value B does not exist in the hash value A, the participation node consensus corresponding to the hash value B does not pass;
6.2, acquiring the consensus passing rate of all the participating nodes, and if the passing rate is greater than or equal to a threshold Y, passing the consensus; if the passing rate is smaller than the threshold value Y, the consensus is not passed.
6.3, obtaining the consensus passing rate of all the participating nodes, and if the passing rate is greater than or equal to a threshold Y, passing the consensus;
and 6.4, acquiring the participation nodes which do not pass the consensus, and marking the participation nodes which do not pass the consensus in an early warning way.
Example III
Referring to fig. 2, fig. 2 is a schematic diagram of a multi-party asynchronous sampling consensus system based on a blockchain, and a second embodiment of the present invention provides a multi-party asynchronous sampling consensus system based on a blockchain, the system includes:
the first data information processing module is used for the initiating node to acquire target data according to the data information and obtain a hash value A of the target data;
the block chain evidence supervision module is used for storing the hash value A, the identity information and the data information of all the participating nodes;
the judging module is used for judging the identity information of the participating node sending the request for acquiring the data information to the blockchain evidence supervisor and sending the snapshot data to the participating node with accurate identity information;
the second data information processing module is used for participating in the random acquisition of a section of sampling data in the target data according to the snapshot data and acquiring a hash value B of the sampling data;
and the comparison module is used for judging whether the hash value A and the hash value B are in common or not.
And the snapshot module is used for carrying out snapshot processing on the hash value A and the data information to obtain snapshot data, and sending the snapshot data to the blockchain evidence supervision module.
In the third embodiment of the present invention, the blockchain evidence supervision module specifically includes: the block chain evidence supervision module is used for storing the hash value A, identity information of all the participating nodes and data information; the participating node sends a request for acquiring data information to the blockchain evidence supervisory party according to the consensus request, and the blockchain evidence supervisory party verifies the identity of the participating node after receiving the data information request, if the request passes, the participating node sends the hash value A and the data information to the participating node, and if the request does not pass, the participating node does not send the hash value A and the data information.
In the third embodiment of the present invention, the specific manner of the comparison module is: comparing the hash value A with the hash value B, and if the hash value B exists in the hash value A, performing digital signature authentication on the data consensus by the participating node corresponding to the hash value B, namely passing the consensus; if the hash value B does not exist in the hash value A, the participating node corresponding to the hash value B does not carry out digital signature authentication on the data consensus, namely the consensus is not passed; acquiring the consensus passing rate, comparing the consensus passing rate with a threshold Y, and if the consensus passing rate is greater than or equal to the threshold Y, consensus; if the consensus passing rate is smaller than the threshold value Y, the threshold value Y is 51% in the present embodiment, without consensus.
In the third embodiment of the present invention, the specific manner of the snapshot module is: and carrying out snapshot processing on the hash value A and the data information to obtain snapshot data, and sending the snapshot data to a blockchain evidence supervisor.
In a second embodiment of the present invention, the specific manner of the second data information processing module is: the participating node obtains the computing environment parameters of the participating node according to the software environment parameters, the hardware environment parameters and the program language of the initiating node for obtaining the hash value in the data information; the participating node reads a section of sampling data randomly in target data of the initiating node according to the data reading interface, and acquires a hash value B of the sampling data under the computing environment parameters of the participating node.
Example IV
An electronic device according to a fourth embodiment of the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the blockchain-based multi-party asynchronous sampling consensus method when executing the computer program.
The processor may be a central processing unit, or may be other general purpose processors, digital signal processors, application specific integrated circuits, off-the-shelf programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory may be used to store the computer program and/or the modules, and the processor may implement various functions of the blockchain-based multi-party asynchronous sampling consensus device of the present invention by executing or executing data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, application programs required for at least one function (such as a sound playing function, an image playing function, etc.), and the like. In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as a hard disk, memory, plug-in hard disk, smart memory card, secure digital card, flash memory card, at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
Example five
A fifth embodiment of the present invention provides a computer readable storage medium storing a computer program that, when executed by a processor, implements the steps of the blockchain-based multi-party asynchronous sampling consensus method.
The computer storage media of embodiments of the invention may take the form of any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium can be, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ReadOnlyMemory, ROM), an erasable programmable read-only memory ((ErasableProgrammableReadOnlyMemory, EPROM) or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present invention without departing from the spirit or scope of the invention. Thus, it is intended that the present invention also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.