Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
As shown in fig. 1, an embodiment of the present invention provides a data transaction method based on a blockchain, including:
step 101: the data purchasing end sends purchasing transaction to the data transaction device; the data transaction device is applied to node equipment of the block chain, and the purchase transaction comprises the following steps: zero knowledge proof and transaction encryption information; the transaction encryption information is obtained by encrypting transaction plaintext information.
In order to avoid storing the transaction plaintext information in the blockchain, the embodiment of the invention encrypts the transaction plaintext information through a cryptographic algorithm to obtain the transaction encrypted information.
Step 102: and the data transaction device calls a verification intelligent contract which is pre-deployed on the block chain according to the purchase transaction so as to verify the zero knowledge proof, and if the verification is passed, the transaction encryption information is uploaded to the block chain.
When the intelligent contract is called, the following verification method is executed: and verifying the zero knowledge proof, and uploading transaction encryption information to the blockchain if the verification is passed.
If the verification is not passed, an authenticity verification non-passing notice is sent to the data purchasing end, and the data purchasing end can inquire a verification result from the data transaction device.
Step 103: and the data purchasing end sends transaction plaintext information to the data providing end.
In order to improve the security of the transaction plaintext information in the transmission process and prevent the transaction plaintext information from being tampered, the data purchasing end can send the transaction plaintext information through a trusted communication channel under the chain, the transaction plaintext information can be encrypted and signed, and the data providing end verifies whether the transaction plaintext information is sent by the data purchasing end or not based on the signature.
Step 104: and the data providing end verifies the transaction plaintext information according to the transaction encryption information stored in the block chain, and if the verification is passed, the data providing end sends target data corresponding to the transaction plaintext information to the data purchasing end.
If the verification is not passed, a transaction plaintext information verification failure notice is sent to the data purchasing end, or the data purchasing end actively acquires a verification result from the data providing end.
Step 105: the data purchasing end receives the target data and sends a confirmation transaction to the data transaction device according to the confirmation operation of the data purchasing end.
The target data is data purchased by the data purchaser from the data provider. The data purchasing end and the data providing end can be two APPs or two modes of the same APP.
Step 106: and the data transaction device calls a pre-deployed transfer intelligent contract on the block chain according to the confirmed transaction, and transfers the resources of the data buyer to the data provider.
When the intelligent transfer contract is called, the following transfer method is executed: resources of the data purchaser are transferred to the data provider.
The resources may be in the form of tokens, credits, or the like.
The verification intelligent contract and the transfer intelligent contract can be two intelligent contracts, and a verification method and a transfer method can be respectively realized through two methods in one intelligent contract. The subsequent intelligent contract management is similar, and the query method, the verification method and the transfer method can be realized through the same intelligent contract.
Only transaction encryption information is stored in the block chain, but transaction plaintext information is not stored, so that privacy and safety of all parties of data transaction are improved. The data transaction arrangement may verify the authenticity of the purchase transaction by a zero knowledge proof submitted by the data purchaser, ensuring that the transaction encryption information stored in the blockchain is generated by the purchase transaction provided by the data purchaser. The data provider can verify the legality of the transaction plaintext information provided by the data purchasing end based on the transaction encryption information stored in the block chain, and the safety of data transaction is ensured in a mode of combining the block chain with the block chain.
In one embodiment of the invention, the method further comprises:
the data providing end determines the description information of the target data and sends the description information to the data transaction device;
the data transaction device calls a management intelligent contract which is pre-deployed on the block chain, and description information is uploaded into the block chain;
the data purchasing end sends a query request to the data transaction device according to the query operation of the data purchasing end;
the data transaction device calls the management intelligent contract to inquire the description information meeting the conditions according to the inquiry request, and feeds the inquiry result back to the data purchasing end.
In order to enable the data purchaser to know the information of the data to be transacted, but improve the privacy and the safety of the data related to transaction at the same time, the embodiment of the invention stores the description information of the data in the block chain and provides query service for the data purchaser, and the data purchaser can query the data to be transacted in the block chain through the data purchaser and determine the content of the purchase transaction according to the data to be transacted in the block chain.
The description information can be uploaded to the block chain in a set format, for example, the format of the description information is < Data ID, metaData: { JSON }, rand (R) >. The Data ID is used for representing the Data identification, is composed of a string of randomly generated characters, and is a Data global unique ID. The MetaData is MetaData, can adopt JSON format, has kept several fields about description information, can be customized by the data provider, can deal with different data content under different scenes. And Rand (R) is a third random number.
In one embodiment of the invention, the transaction plaintext information comprises: identification of target data, an input UTXO (Unspent Transaction Output) list, a signature of each input UTXO, and an Output UTXO list;
the input UTXO list comprises a plurality of input UTXOs;
the output UTXO list comprises a plurality of output UTXOs;
inputting the UTXO as a triple comprising a public key of the data purchaser, a face value of the UTXO and a first random number;
the output UTXO is a triple comprising a public key of a data purchaser or a public key of a data provider, a face value of the output UTXO and a second random number;
embodiments of the present invention use UTXO to characterize resources and the following embodiments will be described with reference to tokens as an example. A UTXO is a triplet that contains three fields, namely < PK, value, R ρ >, where PK is used to characterize the owner's public key, value is used to characterize the face Value of the current UTXO, and R ρ is used to characterize the random number.
The transaction plaintext information provided by the data purchasing end can be in the following form:<Data_ID, Input: [{UTXO1 :{PKi, value1 , Rρ1 }}], Output: [{UTXO2 :{PKo, value2 , Rρ2 }}]>。
data _ ID is the identification of the target Data. The data buyer can be offline with the data provider for the data to be purchased, and can also determine the identification of the data that the data provider can sell through the intelligent contract. For example, the identification, description information and selling price of the data which can be sold are stored in the intelligent contract, and if the price information contained in the purchase transaction meets the selling price requirement in the intelligent contract, the identification of the target data which can be sold is determined by the intelligent contract. In this case, the data trafficking device may invoke an intelligent contract pre-deployed in the blockchain to determine the identity of the target data according to the price information in the purchase traffic.
Input: [{UTXO1 :{PKi, value1 , Rρ1 }}]For characterizing a list of input UTXOs, including one or more input UTXOs attributed to a data purchaser1 For characterizing the input UTXO, PKi being the public key, rp, of the data purchaser1 Is a first random number, value1 Is input intoThe denomination of the UTXO.
Output: [{UTXO2 :{PKo, value2 , Rρ2 }}]For characterizing the output UTXO list, containing one or more outputs UTXO, UTXO2 For characterizing the output UTXO. Wherein, part of the output UTXO belongs to the data provider, and the other output UTXO belongs to the data purchaser for changing. Thus, PKo may be the public key of the data purchaser or the public key of the data provider. value2 For outputting the face value of UTXO, rp2 Is a second random number.
The embodiment of the invention uses the UTXO to represent the resources, is convenient to record the circulation of the resources in the transaction process and provides convenience for hiding the clear text information of the transaction by a cryptographic method.
In one embodiment of the invention, the transaction encryption information includes: a cryptographic commitment of the identity of the target data, a hash of each output UTXO, and a hash of each first random number;
the method further comprises the following steps:
the data purchasing end carries out hash operation on the identifier of the target data and the third random number to obtain a cryptology promise of the identifier of the target data; performing hash operation on each output UTXO to obtain the hash of each output UTXO; and carrying out hash operation on each first random number to obtain the hash of each first random number.
The transaction encryption information is as follows: < commit (Data _ ID), [ Hash (Outputs) ], [ Hash (Inputs R ρ) ] >, where commit (Data _ ID) is used to characterize the cryptographic Commitment of the identity of the target Data, i.e. adding Data _ ID to Rand (R), followed by a Hash operation.
The Hash (Outputs) is used for representing a Hash list of the output UTXO, and the Hash is finally stored on the block chain instead of the UTXO itself, so that other users cannot know the owner and face value of the UTXO.
[Hash(Inputs Rρ)]For characterizing a first random number Rp in an input UTXO1 The hash list uses the hash of the first random number, so that other users can be prevented from deducing the output UTXO in the block chain corresponding to the input UTXO, and the privacy of transaction data is improved.
In an actual application scenario, the cryptographic commitment may be replaced by a hash of the identifier of the target data, which is not limited to the above-mentioned embodiment, as long as the transaction plaintext information can be hidden.
The embodiment of the invention hides the transaction plaintext information by a cryptography method, and stores the cryptography commitment or hash in the block chain instead of directly storing the transaction plaintext information, thereby protecting the privacy of each party of the transaction.
In one embodiment of the invention, the method further comprises:
the data purchasing end generates a zero-knowledge proof according to preset constraint conditions;
the constraint conditions include: the hash of each input UTXO can be inquired in the hash of the output UTXO recorded in the blockchain, the signature of each input UTXO is generated by the private key of the corresponding data purchaser, the hashes of the first random numbers do not belong to the hashes of the first random numbers recorded in the blockchain, the sum of the face values of the input UTXOs of the input UTXO list is equal to the sum of the face values of the output UTXOs of the output UTXO list, and the sum of the face values of the output UTXOs corresponding to the output UTXO containing the public key of the data provider is not lower than any one or more of preset resource limits;
verifying the zero knowledge proof, including:
the zero knowledge proof is verified based on the constraint conditions.
The resource limit is preset by the data provider and is the minimum resource amount which the data buyer needs to pay for the target data.
The hash of each input UTXO can be queried in the hash of the output UTXO recorded in the blockchain, which indicates that the source of the hash of each input UTXO is recorded on the blockchain and is a legal source. The hash of each first random number does not belong to the hash of the first random number recorded in the block chain, which indicates that each input UTXO is an unconsumed token, and thus the token is prevented from being repeatedly consumed. The sum of the face values of the input UTXO list is equal to the sum of the face values of the output UTXO list, which shows that the input and the output are conservative, and the safety of data transaction can be submitted through various constraint conditions.
For example, if the constraints include the five items, then zero knowledge proves that it is necessary to prove that the transaction plaintext information satisfies the five items, and if so, that the purchase transaction is indeed initiated by the data purchaser. The authenticity of the purchase transaction can be verified through zero knowledge proof, and the transaction safety is improved.
In one embodiment of the present invention, the data providing end verifies the transaction plaintext information according to the transaction encrypted information stored in the blockchain, including:
and the data providing end verifies whether the hash of each output UTXO in the transaction encryption information stored in the block chain corresponds to the hash of each output UTXO in the transaction plaintext information one by one, if so, the verification is passed, otherwise, the verification is not passed.
The data providing end can determine transaction encryption information corresponding to the transaction plaintext information, determine whether the transaction encryption information is obtained by calculating the transaction plaintext information through a cryptographic algorithm, determine whether the transaction plaintext information is tampered through the transaction plaintext information and the transaction encryption information, and improve transaction safety. And if the hash of each output UTXO in the transaction encryption information is the same as the hash of each corresponding output UTXO in the transaction plaintext information, the transaction plaintext information is proved not to be tampered. In an actual application scenario, the hash of each output UTXO in the transaction plaintext information is calculated first, and then the transaction encrypted information is compared.
In an actual application scenario, the transaction plaintext information may also be verified through one or more of the above constraints. Taking one of the items as an example, the data providing end verifies the transaction plaintext information according to the transaction encryption information stored in the block chain, and the method comprises the following steps: the data providing end verifies whether the hash of each input UTXO can be inquired in the hash of the output UTXO recorded by the block chain. If the inquiry can be made, the verification is passed, otherwise, the verification is not passed. Of course, the above verification methods may also be combined to verify the transaction plaintext information, for example, the data providing end verifies the transaction plaintext information according to the transaction encryption information stored in the block chain, including: and the data providing terminal verifies whether the hash of each output UTXO in the transaction encryption information stored in the block chain is in one-to-one correspondence with the hash of each output UTXO in the transaction plaintext information, if so, verifies whether the signature of each input UTXO is generated by the private key of the corresponding data purchaser, if so, the signature passes the verification, otherwise, the signature does not pass the verification. And verifying whether the purchase transaction is initiated by the data purchaser by verifying the signature, thereby further improving the security of the data transaction.
In an actual application scenario, the transaction plaintext information may also be verified through the identifier of the target data and the random number in the corresponding description information, for example, the data providing end verifies the transaction plaintext information according to the transaction encryption information stored in the block chain, including: and the data providing end verifies whether the identifier of the target data and the hash of the third random number are equal to the cryptographic commitment in the transaction encryption information in the block chain, if so, the verification is passed, and otherwise, the verification is not passed. This verification process may be used in conjunction with the verification process of the transaction plaintext information described previously.
In one embodiment of the invention, the method further comprises:
the data transaction device marks the state of the transaction encryption information as to be confirmed based on the verification intelligent contract;
after the data transaction device receives the confirmed transaction, marking the state of the transaction encryption information as confirmed;
the data providing end verifies the transaction plaintext information according to the transaction encryption information stored in the block chain, and the method comprises the following steps:
and the data providing end verifies the transaction plaintext information according to the confirmed transaction encryption information stored in the block chain.
The data transaction device can change the state of the transaction encryption information stored in the blockchain to ensure the accuracy of the verification result and the accuracy of the resource transfer.
Each node of the block chain stores: a cryptographic commitment of an identification of the target data, a hash of each output UTXO, and a hash of each first random number.
For example, three lists, such as table 1-table 3, are stored in the blockchain for storing the above three data, and when the transaction encryption information is uploaded to the blockchain, the information in the three lists is updated synchronously. All tables are only increased and not decreased.
TABLE 1 Cryptographic promise of identification of target data
Table 2 hashing of output UTXO
Table 3 hashing of a first random number
As shown in fig. 2, an embodiment of the present invention provides a data transaction system based on a blockchain, including: the data purchasing terminal, the data transaction device and the data providing terminal; the data transaction device is applied to the node equipment of the block chain;
the data purchasing end is used for sending purchasing transaction to the data transaction device; wherein the purchase transaction includes: zero knowledge proof and transaction encryption information; the transaction encryption information is obtained by encrypting transaction plaintext information; transmitting transaction plaintext information to a data providing end; receiving target data corresponding to transaction plaintext information sent by a data providing end, and sending a confirmation transaction to a data transaction device according to a confirmation operation of a data purchaser;
the data transaction device is used for calling a verification intelligent contract which is pre-deployed on the block chain according to the purchase transaction so as to verify the zero knowledge certificate, uploading transaction encryption information to the block chain if the verification is passed, and marking the state of the transaction encryption information as to-be-confirmed; according to the confirmed transaction, calling a pre-deployed transfer intelligent contract on the block chain, transferring the resources of the data purchaser to a data provider, and marking the transaction encryption information in the state of waiting for confirmation as confirmed;
and the data providing end is used for verifying the transaction plaintext information according to the confirmed transaction encryption information stored in the block chain, and if the verification is passed, sending the target data to the data purchasing end.
The embodiment of the invention realizes data transaction based on the blockchain, can ensure the legality of the data transaction process, ensures that transaction data is not tampered, and ensures the benefits of all parties of the transaction. Based on zero knowledge proof and a cryptographic algorithm, the privacy safety of each party of transaction is ensured, and the transaction safety is improved.
In an embodiment of the present invention, the data transaction apparatus is configured to invoke a management intelligent contract pre-deployed on the blockchain, and upload description information to the blockchain; calling and managing an intelligent contract according to the query request to query the description information meeting the conditions, and feeding back the query result to the data purchasing end;
and the data purchasing end is used for sending a query request to the data transaction device according to the query operation of the data purchasing end.
In one embodiment of the invention, the transaction plaintext information comprises: identification of target data, an input UTXO list, a signature of each input UTXO and an output UTXO list;
the input UTXO list comprises a plurality of input UTXOs;
the output UTXO list comprises a plurality of output UTXOs;
inputting the UTXO as a triple comprising a public key of the data purchaser, a face value of the UTXO and a first random number;
the output UTXO is a triple comprising a public key of a data purchaser or a public key of a data provider, a face value of the output UTXO and a second random number;
in one embodiment of the invention, the transaction encryption information comprises: a cryptographic commitment of the identity of the target data, a hash of each output UTXO, and a hash of each first random number;
the data purchasing end is used for carrying out hash operation on the identifier of the target data and the third random number to obtain a cryptology promise of the identifier of the target data; performing hash operation on each output UTXO to obtain the hash of each output UTXO; and carrying out hash operation on each first random number to obtain the hash of each first random number.
In an embodiment of the invention, the data purchasing end is used for generating a zero-knowledge proof according to a preset constraint condition;
the constraint conditions include: the hash of each input UTXO can be inquired in the hash of the output UTXO recorded in the block chain, the signature of each input UTXO is generated by a private key of the corresponding data purchaser, the hashes of the first random numbers do not belong to the hashes of the first random numbers recorded in the block chain, the sum of the face values of the input UTXOs of the input UTXO list is equal to the sum of the face values of the output UTXOs of the output UTXO list, and the sum of the face values of the output UTXOs corresponding to the output UTXOs containing the public keys of the data providers is not lower than any one or more of preset resource limit;
and the data transaction device is used for verifying the zero knowledge proof based on the constraint condition.
In an embodiment of the present invention, the data providing end is configured to verify whether the hash of each output UTXO in the transaction encryption information stored in the block chain corresponds to the hash of each output UTXO in the transaction plaintext information one-to-one, and if so, the verification is passed, otherwise, the verification is not passed.
In one embodiment of the invention, the data transaction device is used for marking the state of the transaction encryption information as to be confirmed based on the verification intelligent contract; after the data transaction device receives the confirmed transaction, marking the state of the transaction encryption information as confirmed;
and the data providing end is used for verifying the transaction plaintext information according to the confirmed transaction encryption information stored in the block chain.
Referring now to FIG. 3, a block diagram of acomputer system 300 suitable for use with a terminal device implementing an embodiment of the invention is shown. The terminal device shown in fig. 3 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 3, thecomputer system 300 includes a Central Processing Unit (CPU) 301 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM) 302 or a program loaded from astorage section 308 into a Random Access Memory (RAM) 303. In theRAM 303, various programs and data necessary for the operation of thesystem 300 are also stored. TheCPU 301,ROM 302, andRAM 303 are connected to each other via abus 304. An input/output (I/O)interface 305 is also connected tobus 304.
The following components are connected to the I/O interface 305: aninput portion 306 including a keyboard, a mouse, and the like; anoutput section 307 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; astorage section 308 including a hard disk and the like; and acommunication section 309 including a network interface card such as a LAN card, a modem, or the like. Thecommunication section 309 performs communication processing via a network such as the internet. Adrive 310 is also connected to the I/O interface 305 as needed. Aremovable medium 311 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on thedrive 310 as necessary, so that a computer program read out therefrom is mounted into thestorage section 308 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer-readable medium, the computer program comprising program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through thecommunication section 309, and/or installed from theremovable medium 311. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 301.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (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 the present invention, 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. In contrast, in the present invention, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a sending module, an obtaining module, a determining module, and a first processing module. The names of these modules do not form a limitation on the modules themselves in some cases, and for example, the sending module may also be described as a "module sending a picture acquisition request to a connected server".
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.