Data transmission method and device based on zero knowledge proof, equipment and storage medium
By generating the private and public keys of the data demander, encrypting the data using the ElGamal algorithm and generating zero-knowledge proof parameters, the problem of lack of privacy protection for data transmission in blockchain smart contracts is solved, and the security of data transmission and the automated execution of smart contracts are realized, and the production efficiency is improved.
Patent Information
- Application Number
- CN202510847383.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-24
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2045-06-24
AI Technical Summary
In the process of data transmission based on zero-knowledge proof, the open and transparent nature of blockchain smart contracts leads to a lack of privacy protection in data transmission and the inability to verify encrypted data, affecting the security and automated execution of data transmission operations.
By generating the private and public keys of the data demander, the data is encrypted using the ElGamal algorithm, and zero-knowledge proof parameters are generated, combining the marking method and data delivery method of the smart contract, ensuring the security of data delivery.
It improves the security of data delivery operations, ensures data privacy protection, and supports the automated execution of smart contracts, improving the efficiency and user experience of the production process.
Smart Images

Figure CN120358029A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of cryptography, and particularly relates to a data transmission method, device, equipment and storage medium based on zero-knowledge proof. Background Art
[0002] Currently, in the process of data transmission, using blockchain technology can enable smart contracts to automatically execute some data transmission operations to simplify the data transmission process; it can also ensure that the target data is not tampered with to enhance the credibility of data transmission operations. However, the public and transparent nature of blockchain smart contracts will result in the lack of privacy protection for the data transmitted in data transmission operations. Therefore, most blockchains should only transmit encrypted data into blockchain smart contracts. But this approach will cause new problems in data transmission operations: the smart contract cannot verify the encrypted data, making it difficult to ensure the authenticity and effectiveness of the data, and also affecting the subsequent automated execution of the data transmission operation in the smart contract; if the data is decrypted and verified on the smart contract, it means that the plaintext and the key are made public, and the data privacy is not well protected.
[0003] As can be seen from the above, how to improve the security of data transmission operations in the process of data transmission based on zero-knowledge proof is an urgent problem to be solved at present. Summary of the Invention
[0004] In view of this, the purpose of the present invention is to provide a data transmission method, device, equipment and storage medium based on zero-knowledge proof, which can improve the security of data transmission operations in the process of data transmission based on zero-knowledge proof. The specific solutions are as follows:
[0005] In the first aspect, the present application provides a data transmission method based on zero-knowledge proof, which is applied to a data provider and includes:
[0006] Obtain the first private key generated by the data requester based on the key generation request and the first public key corresponding to the first private key, and use the second public key issued by the data platform to the smart contract and the ElGamal algorithm to encrypt the target data to be transmitted, so as to obtain the first encrypted data;
[0007] Obtain the first encrypted data marked as compliant by the data platform by calling the preset marking method in the smart contract, and associate the local data to be processed, and then use the first public key to encrypt the data to be processed, so as to obtain the second encrypted data; the data to be processed is the data obtained by the data platform decrypting the first encrypted data with the second private key corresponding to the second public key;
[0008] Generate zero - knowledge proof parameters based on the first encrypted data and the second encrypted data, and call the data transfer method in the smart contract based on the zero - knowledge proof parameters to send the second encrypted data to the smart contract, so that the data requester can obtain the second encrypted data from the smart contract and decrypt the second encrypted data with the first private key to obtain the target data.
[0009] Optionally, the process by which the data requester generates the first private key and the first public key corresponding to the first private key based on a key generation request includes:
[0010] Call a preset key generation center to determine a target prime number, determine a target primitive element based on the target prime number, and record the target prime number and the target primitive element in the smart contract of the blockchain;
[0011] Call the preset key generation center to generate the first private key using the target prime number;
[0012] Determine the first public key corresponding to the first private key based on the first private key and a preset public key determination formula, send the first private key to the user corresponding to the data requester, and then record the first public key in the smart contract of the blockchain.
[0013] Optionally, encrypt the target data to be transmitted using the second public key sent by the data platform party to the smart contract and the ElGamal algorithm to obtain the first encrypted data, including:
[0014] Obtain the second public key sent by the data platform party to the smart contract from the smart contract, determine a first target integer using a preset integer determination rule, then determine the first ciphertext corresponding to the target data to be transmitted based on the first target integer, the target primitive element, and the second public key, and determine the second ciphertext based on the target data to be transmitted, the target prime number, the first target integer, and the second public key, so as to determine the first encrypted data based on the first ciphertext and the second ciphertext;
[0015] Judge whether the current number of data transfer vouchers is less than a first preset number. If the current number of data transfer vouchers is not less than the first preset number, then freeze the first preset number of data transfer vouchers of the data provider by calling the preset evaluation method in the smart contract in the blockchain based on the first encrypted data and the second public key, so as to use the first preset number of frozen data transfer vouchers of the data provider to transfer the target data to be transmitted.
[0016] Optionally, the data platform party calls the preset marking method in the smart contract to mark the first encrypted data that passes the verification on the smart contract as compliant, including:
[0017] The data platform party monitors the smart contract. If it monitors that the preset evaluation method in the smart contract is called and the second public key is included in the preset evaluation method, it decrypts the first encrypted data with the second private key to obtain the data to be processed;
[0018] Call the data platform party and use the preset evaluation method to evaluate the data to be processed to obtain an evaluation result. If the evaluation result indicates that the data is non-compliant, call the smart contract to record the data corresponding to the evaluation result and destroy the first preset number of data transfer vouchers of the data provider;
[0019] If the evaluation result indicates that the data is compliant, call the data platform party and based on the data to be processed, the first ciphertext, and the first preset number of frozen data transfer vouchers, call the preset marking method in the smart contract to pre-mark the first encrypted data corresponding to the data to be processed as compliant in the smart contract and attach data description information.
[0020] Optionally, the encrypting the data to be processed with the first public key to obtain second encrypted data includes:
[0021] Call the data requester and determine the required data in the data platform party according to the additional data description information based on its own requirements, and then call the smart contract to determine whether the number of data transfer vouchers corresponding to the data requester is less than a second preset number;
[0022] If the number of data transfer vouchers corresponding to the data requester is not less than the second preset number, call the preset data acquisition method in the smart contract based on the first public key to obtain the data to be processed with the preset data acquisition method and freeze the second preset number of data transfer vouchers of the data requester for transferring the data to be processed with the second preset number of frozen data transfer vouchers of the data requester;
[0023] Determine a second target integer through the data provider, determine a third ciphertext corresponding to the data to be processed based on the second target integer and the target primitive element, determine a fourth ciphertext based on the data to be processed, the target prime number, and the second target integer, and then determine the second encrypted data based on the third ciphertext and the fourth ciphertext.
[0024] Optionally, the generating zero-knowledge proof parameters based on the first encrypted data and the second encrypted data includes:
[0025] Determine a first random integer based on the target prime number, and determine first data to be calculated based on the target prime number, the first random integer, and the first target integer. Determine second data to be calculated based on the second target integer, the first random integer, and the target prime number. Determine third data to be calculated based on the first random integer, the second target integer, and the target primitive element. Determine fourth data to be calculated based on the data to be processed and the first random integer;
[0026] Determine a second random integer based on the target prime number, and determine fifth data to be calculated based on the second random integer, the target prime number, and the first target integer. Determine sixth data to be calculated based on the second random integer, the target prime number, and the second target integer. Determine seventh data to be calculated based on the second random integer and the target primitive element. Determine eighth data to be calculated based on the data to be processed and the second random integer;
[0027] Use a preset hash function, and determine a hash value based on the first data to be calculated, the second data to be calculated, the third data to be calculated, the fourth data to be calculated, the fifth data to be calculated, the sixth data to be calculated, the seventh data to be calculated, and the eighth data to be calculated, and determine zero-knowledge proof parameters based on the hash value.
[0028] Optionally, the step of using a preset hash function and determining a hash value based on the first data to be calculated, the second data to be calculated, the third data to be calculated, the fourth data to be calculated, the fifth data to be calculated, the sixth data to be calculated, the seventh data to be calculated, and the eighth data to be calculated includes:
[0029] Use a number of preset verification formulas to respectively verify specific combinations of the first data to be calculated, the second data to be calculated, the third data to be calculated, the fourth data to be calculated, the fifth data to be calculated, the sixth data to be calculated, the seventh data to be calculated, and the eighth data to be calculated, and obtain corresponding verification results respectively;
[0030] If all the verification results indicate that the verification is passed, then call the data provider to use a preset hash function and determine a hash value based on the first data to be calculated, the second data to be calculated, the third data to be calculated, the fourth data to be calculated, the fifth data to be calculated, the sixth data to be calculated, the seventh data to be calculated, and the eighth data to be calculated.
[0031] In a second aspect, the present application provides a data transfer device based on zero-knowledge proof, which is applied to a data provider and includes:
[0032] The first encrypted data determination module is configured to obtain the first private key generated by the data requester based on the key generation request and the first public key corresponding to the first private key, and encrypt the target data to be transmitted by using the second public key sent by the data platform party to the smart contract and the ElGamal algorithm to obtain the first encrypted data;
[0033] The second encrypted data determination module is configured to obtain the first encrypted data marked as compliant by the data platform party by invoking the preset marking method in the smart contract, associate the local data to be processed, and then encrypt the data to be processed by using the first public key to obtain the second encrypted data; the data to be processed is the data obtained by the data platform party decrypting the first encrypted data by using the second private key corresponding to the second public key;
[0034] The target data determination module is configured to generate zero-knowledge proof parameters based on the first encrypted data and the second encrypted data, and call the data transfer method in the smart contract based on the zero-knowledge proof parameters to send the second encrypted data to the smart contract, so that the data requester can obtain the second encrypted data from the smart contract and decrypt the second encrypted data by using the first private key to obtain the target data.
[0035] In a third aspect, the present application provides an electronic device, including:
[0036] A memory for storing a computer program;
[0037] A processor for executing the computer program to implement the foregoing data transfer method based on zero-knowledge proof.
[0038] In a fourth aspect, the present application provides a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the foregoing data transfer method based on zero-knowledge proof.
[0039] As can be seen from the above, before performing data transmission based on zero-knowledge proof, this application needs to generate a private key and a first public key corresponding to the private key based on a key generation request, and call the data platform party to generate a second public key. Then, call the data provider and use the ElGamal algorithm to encrypt the target data to be transmitted with the second public key to obtain the first encrypted data; call the data platform party and use the private key to decrypt the first encrypted data to obtain the original data. After auditing and compliance, call the preset marking method in the smart contract to mark the first encrypted data corresponding to the original data as compliant and attach data description information; call the data requester and use the preset data acquisition method in the smart contract to obtain the required target data in the data platform party according to the attached data description information. Then, pass through the data provider and use the first public key to encrypt the target data to obtain the second encrypted data; call the data provider and generate zero-knowledge proof parameters based on the first encrypted data and the second encrypted data, and call the data transmission method in the smart contract based on the second encrypted data and the zero-knowledge proof parameters to send the second encrypted data to the data requester, so that the data requester can use the private key to decrypt the second encrypted data to obtain the target data.
[0040] As can be seen, this application first needs to generate a private key and a first public key corresponding to the private key based on a key generation request, and call the data platform party to generate a second public key. Then, call the data provider and use the ElGamal algorithm to encrypt the target data to be transmitted with the second public key to obtain the first encrypted data; secondly, call the data platform party and use the private key to decrypt the first encrypted data to obtain the original data. After auditing and compliance, call the preset marking method in the smart contract to mark the first encrypted data corresponding to the original data as compliant and attach data description information; then, call the data requester and use the preset data acquisition method in the smart contract to obtain the required target data in the data platform party according to the attached data description information. Then, pass through the data provider and use the first public key to encrypt the target data to obtain the second encrypted data; finally, call the data provider and generate zero-knowledge proof parameters based on the first encrypted data and the second encrypted data, and call the data transmission method in the smart contract based on the second encrypted data and the zero-knowledge proof parameters to send the second encrypted data to the data requester, so that the data requester can use the private key to decrypt the second encrypted data to obtain the target data. In this way, the security of data transmission operations is improved, thereby improving the efficiency of the production process and further enhancing the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0042] Figure 1 A flow chart of a data transmission method based on zero-knowledge proof disclosed in this application;
[0043] Figure 2 A flowchart of information generation in the preparation phase of a key generation system disclosed in the present application;
[0044] Figure 3 This is a schematic diagram of the structure of a data transmission device based on zero-knowledge proof disclosed in this application;
[0045] Figure 4 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION
[0046] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0047] At present, in the process of data transmission, the use of blockchain technology can allow smart contracts to automatically execute part of the data transmission operation to simplify the data transmission process. However, the open and transparent nature of blockchain smart contracts makes the data transmitted in the data transmission operation lack privacy protection. Therefore, most blockchains should only encrypt the data and pass it to the blockchain smart contract. However, this approach will cause the smart contract to be unable to verify the encrypted data, making it difficult to ensure the authenticity and validity of the data, and also affecting the subsequent automatic execution of the data transmission operation in the smart contract; if the data is decrypted and verified on the smart contract, it means that the plaintext and key are disclosed, and the data privacy is not protected. To this end, the present application provides a data transmission method based on zero-knowledge proof, which can improve the security of data transmission operations in the data transmission process based on zero-knowledge proof.
[0048] See also Figure 1 As shown, an embodiment of the present invention discloses a data transmission method based on zero-knowledge proof, which is applied to a data provider, including:
[0049] Step S11: Obtain the first private key generated by the data requester based on the key generation request and the corresponding first public key, and use the second public key issued by the data platform to the smart contract and the ElGamal algorithm to encrypt the target data to be transmitted, obtaining the first encrypted data.
[0050] In this embodiment, in the preparation stage, the key generation system needs to generate public parameters and keys, and distribute the private keys. The flowchart of the preparation stage is as Figure 2 shown. In addition, the data requester can obtain the data exchange voucher in a certain way. Among them, in the process of generating public parameters by using the key generation system, a large prime number needs to be randomly selected , and the above large prime number satisfies having a large prime factor. Subsequently, based on the modulus determine the corresponding primitive element , and record and in the smart contract of the blockchain. It is worth mentioning that the modulo operation needs to be performed in all subsequent calculation formulas. The subsequent calculation formulas in this embodiment will not be listed again.
[0051] In this embodiment, when a new data requester registers, it needs to send a key application request to the key generation system so that the key generation system can select an integer as the private key of the data requester. Among them, the value range of the integer needs to satisfy . Subsequently, based on the public key calculation formula, determine the public key corresponding to the data requester, and the expression of the public key calculation formula is as follows:
[0052] ;
[0053] where is the public key corresponding to the data requester.
[0054] Subsequently, the key generation center needs to securely distribute the generated private key to the corresponding data requester, record the first public key corresponding to the data requester in the smart contract of the blockchain, and the smart contract can allocate a certain number of data exchange vouchers to the data requester. Further, the data requester can select some data exchange voucher acquisition methods to obtain a certain number of data exchange vouchers.
[0055] Specifically, the process by which the data requester generates the first private key and the first public key corresponding to the first private key based on the key generation request includes: calling a preset key generation center to determine a target prime number, determining a target primitive element based on the target prime number, and recording the target prime number and the target primitive element in the smart contract of the blockchain; calling the preset key generation center to generate the first private key using the target prime number; determining the first public key corresponding to the first private key based on the first private key and the preset public key determination formula, and sending the first private key to the user corresponding to the data requester, and then recording the first public key in the smart contract of the blockchain.
[0056] In this embodiment, the data to be encrypted needs to be evaluated. Among them, the data provider needs to use the public key corresponding to the data platform party to encrypt the data to be encrypted, and then synchronize the obtained first ciphertext to the data platform party through the blockchain contract. Specifically, encrypting the target data to be transmitted using the second public key sent by the data platform party to the smart contract and the ElGamal algorithm to obtain the first encrypted data may include: obtaining the second public key sent by the data platform party to the smart contract from the smart contract, and determining the first target integer using the preset integer determination rule, and then determining the first ciphertext corresponding to the target data to be transmitted based on the first target integer, the target primitive element, and the second public key, and determining the second ciphertext based on the target data to be transmitted, the target prime number, the first target integer, and the second public key, so as to determine the first encrypted data based on the first ciphertext and the second ciphertext; determining whether the current number of data transfer vouchers is less than the first preset number, and if the current number of data transfer vouchers is not less than the first preset number, freezing the first preset number of data transfer vouchers of the data provider by calling the preset evaluation method in the smart contract in the blockchain based on the first encrypted data and the second public key, so as to use the first preset number of frozen data transfer vouchers of the data provider to transmit the target data to be transmitted.
[0057] In a specific implementation manner, the data provider can obtain the second public key corresponding to the data platform party through the smart contract of the blockchain , so as to perform ElGamal encryption on the data to be encrypted. Among them, the process of encrypting the data is as follows:
[0058] First, select an integer , and save it in the local storage space of the client. And the value range corresponding to the above integer satisfies:
[0059] ;
[0060] Subsequently, encrypt the data to be encrypted based on the following encryption algorithm formula: and , so as to obtain the first encrypted data: 。
[0061] Further, the embodiment of the present application can be based on the first encrypted data and the second public key corresponding to the data platform party invoke the evaluation method in the smart contract on the blockchain to lock part of the data exchange vouchers of the data provider. If the data provider holds insufficient data exchange vouchers, the evaluation method cannot be invoked.
[0062] Step S12: Obtain the first encrypted data marked as compliant by the data platform party invoking the preset marking method in the smart contract, and associate the local data to be processed. Then, encrypt the data to be processed using the first public key to obtain the second encrypted data; the data to be processed is the data obtained by the data platform party decrypting the first encrypted data using the second private key corresponding to the second public key.
[0063] In this embodiment, after the client of the data platform party monitors that the evaluation method in the smart contract on the blockchain is invoked and the parameters used in the evaluation method include after that, the private key can be used to decrypt the first encrypted data to obtain the data to be processed, and the decryption expression is as follows:
[0064] 。
[0065] Further, the data platform party needs to evaluate the data to be processed. If the obtained evaluation result indicates non-compliant data, the data platform party needs to invoke the smart contract on the blockchain to record that the data to be processed is non-compliant and invoke the smart contract to automatically destroy the locked data exchange vouchers of the data provider; if the obtained evaluation result indicates that the data is compliant, then, the data platform party needs to invoke the preset marking method in the smart contract on the blockchain to mark the first encrypted data that passes the verification on the smart contract as compliant based on the data exchange vouchers and the first encrypted data.
[0066] Specifically, the data platform party calls the preset marking method in the smart contract to mark the first encrypted data that passes the verification on the smart contract as compliant, which may include: The data platform party monitors the smart contract. If it monitors that the preset evaluation method in the smart contract is called and the preset evaluation method includes a second public key, it decrypts the first encrypted data with the second private key to obtain the data to be processed; calls the data platform party and uses the preset evaluation method to evaluate the data to be processed to obtain an evaluation result. If the evaluation result indicates that the data is non-compliant, it calls the smart contract to record the data corresponding to the evaluation result and destroys the first preset number of data transfer vouchers of the data provider; if the evaluation result indicates that the data is compliant, it calls the data platform party and calls the preset marking method in the smart contract based on the data to be processed, the first ciphertext, and the first preset number of frozen data transfer vouchers, so as to use the preset marking method to preliminarily mark the first encrypted data corresponding to the data to be processed as compliant on the smart contract and append data description information.
[0067] Step S13: Generate zero-knowledge proof parameters based on the first encrypted data and the second encrypted data, and call the data transfer method in the smart contract based on the zero-knowledge proof parameters to send the second encrypted data to the smart contract, so that the data requester can obtain the second encrypted data from the smart contract and decrypt the second encrypted data with the first private key to obtain the target data.
[0068] In this embodiment, the data acquirer can view the data that has been uploaded and marked in the smart contract of the blockchain, and determine the data to be obtained according to its own needs and additional data information, so as to use the first public key to call the data acquisition method of the blockchain smart contract for data acquisition operations. That is, the smart contract can query the number of data exchange vouchers of the data acquirer. If the number of data exchange vouchers in the acquirer's account is less than the number of data exchange vouchers corresponding to the data to be processed, it returns a failure message and the data information acquisition fails; otherwise, the smart contract can lock the corresponding number of data exchange vouchers of the data acquirer.
[0069] In addition, in the data delivery stage, the data provider needs to encrypt the data to generate corresponding second encrypted data and proof parameters, so as to call the smart contract based on the second encrypted data and the proof. If the smart contract passes the verification, it can provide the data exchange voucher to the data provider. If the smart contract fails the verification, it cancels the corresponding number of data exchange vouchers of the locked data provider. Further, after the data provider monitors through the client that the acquisition method of the smart contract on the blockchain is called and the acquired data is provided by the data provider, it needs to query the first public key to use the first public key pk b for the data Perform encryption. In a specific embodiment, the data is encrypted using the first public key The process of encrypting is as follows:
[0070] First, randomly select an integer , and the value range of satisfies ; Subsequently, based on and perform the second encrypted data calculation to obtain the second encrypted data .
[0071] Specifically, encrypting the data to be processed using the first public key to obtain the second encrypted data may include: calling the data requester and determining the required data in the data platform party according to the additional data description information based on its own needs, and then calling the smart contract to judge whether the number of data transfer vouchers corresponding to the data requester is less than the second preset number; if the number of data transfer vouchers corresponding to the data requester is not less than the second preset number, then call the preset data acquisition method in the smart contract based on the first public key to obtain the data to be processed using the preset data acquisition method, and freeze the second preset number of data transfer vouchers of the data requester, so as to use the second preset number of frozen data transfer vouchers of the data requester to transfer the data to be processed; determine the second target integer through the data provider, and determine the third ciphertext corresponding to the data to be processed based on the second target integer and the target primitive element, and determine the fourth ciphertext based on the data to be processed, the target prime number and the second target integer, and then determine the second encrypted data based on the third ciphertext and the fourth ciphertext.
[0072] It is worth mentioning that is the data obtained after correct encryption using the first public key pk b , is the data obtained after encryption using the second public key, and and are the data obtained after encrypting the same data.
[0073] In this embodiment, the data provider first needs to select a random number , and the random number has a value range of: , Subsequently, based on and , , and perform calculations to obtain , , and .
[0074] Subsequently, select a random number , satisfy , and then based on , , and determine , , and .
[0075] Furthermore, the embodiments of the present application need to use a hash function and determine a hash value based on the parameters calculated above, and the hash value is as follows:
[0076] ;
[0077] Specifically, using a preset hash function and determining a hash value based on the first data to be calculated, the second data to be calculated, the third data to be calculated, the fourth data to be calculated, the fifth data to be calculated, the sixth data to be calculated, the seventh data to be calculated, and the eighth data to be calculated may include: using a number of preset verification formulas to respectively verify specific combinations of the first data to be calculated, the second data to be calculated, the third data to be calculated, the fourth data to be calculated, the fifth data to be calculated, the sixth data to be calculated, the seventh data to be calculated, and the eighth data to be calculated, and obtaining the respectively corresponding verification results; if each verification result indicates that the verification is passed, then call the data provider to use the preset hash function and determine a hash value based on the first data to be calculated, the second data to be calculated, the third data to be calculated, the fourth data to be calculated, the fifth data to be calculated, the sixth data to be calculated, the seventh data to be calculated, and the eighth data to be calculated.
[0078] Then, the embodiments of the present application need to use corresponding formulas to determine , and , and the expressions are as follows:
[0079] ;
[0080] ;
[0081] ;
[0082] After obtaining , and , the embodiments of the present application can use a preset parameter determination formula to determine zero-knowledge proof parameters, and the expression of the preset parameter determination formula is as follows:
[0083] ;
[0084] It is worth mentioning that after obtaining the zero-knowledge proof parameters, the data provider needs to use the second encrypted data through the client and invoke the data transfer method of the smart contract in the blockchain to transfer the data.
[0085] Specifically, generating zero-knowledge proof parameters based on the first encrypted data and the second encrypted data may include: determining a first random integer based on a target prime number, and determining first data to be calculated based on the target prime number, the first random integer, and a first target integer, determining second data to be calculated based on a second target integer, the first random integer, and the target prime number, determining third data to be calculated based on the first random integer, the second target integer, and the target primitive element, determining fourth data to be calculated based on the data to be processed and the first random integer; determining a second random integer based on the target prime number, and determining fifth data to be calculated based on the second random integer, the target prime number, and the first target integer, determining sixth data to be calculated based on the second random integer, the target prime number, and the second target integer, determining seventh data to be calculated based on the second random integer and the target primitive element, determining eighth data to be calculated based on the data to be processed and the second random integer; using a preset hash function, and determining a hash value based on the first data to be calculated, the second data to be calculated, the third data to be calculated, the fourth data to be calculated, the fifth data to be calculated, the sixth data to be calculated, the seventh data to be calculated, and the eighth data to be calculated, and determining the zero-knowledge proof parameters based on the hash value.
[0086] Further, after obtaining the zero-knowledge proof parameters this embodiment of the present application needs to verify for correctness, that is, to verify whether the following equalities all hold:
[0087] ;
[0088] ;
[0089] ;
[0090] ;
[0091] ;
[0092] ;
[0094] Among them, the first three verification formulas above are used to verify whether the random numbers used by the data provider are the same random number, and to verify whether is the value obtained after randomization, whether is the value obtained after randomization, Whether it is The value obtained after randomization.
[0095] In addition, the fourth and fifth verification formulas are used to verify Whether it is with As the base of the discrete logarithm, and Whether it is with As the base of the discrete logarithm. Also, since the above three verification formulas have verified , Are the values obtained after randomization using the same random number, it can be obtained that Is the original data After randomization, and the data encrypted twice Is the same data. It is worth mentioning that if the data provider acts fraudulently during the data exchange process, that is, uses different data After encryption and randomization to obtain , but because it is necessary to use After calculation, it can pass the verification of the fourth and fifth verification formulas, and this is a difficult discrete logarithm problem to calculate. Therefore, if it passes, it can be confirmed that And Are operations for encrypting the same data.
[0096] Furthermore, the fifth and sixth verification formulas are used to verify that the two parts of the encrypted data calculated by the same encryption random number in the embodiment of the present application are, that is And The corresponding discrete logarithm and And The corresponding discrete logarithm is the same discrete logarithm, indicating that the encrypted data is the data calculated according to the preset encryption standard process.
[0097] It is worth mentioning that if the above formulas all hold, then through the verification of the parameters, the smart contract can be called to mark the data as delivered, and the frozen data exchange voucher of the data acquirer can be transferred to the data exchange voucher of the data provider; conversely, if one of the equations does not hold, the frozen data exchange voucher of the data provider is destroyed, and the frozen data exchange voucher in the data acquirer is thawed.
[0098] In this embodiment, after the data acquirer obtains the encrypted data, the first private key can be used to decrypt the data to obtain the decrypted data. In a specific implementation manner, after the data acquirer monitors through the client that the data delivery method in the blockchain smart contract is successfully called, the second encrypted data in the contract can be obtained , and use the first private key To decrypt the above second encrypted data to obtain the target data: 。
[0099] As can be seen from the above, before performing data transfer based on zero - knowledge proof in the embodiments of the present application, it is first necessary to generate a private key and a first public key corresponding to the private key based on a key generation request, and call the data platform party to generate a second public key. Then, call the data provider and use the ElGamal algorithm to encrypt the data to be encrypted with the second public key to obtain the first encrypted data. Secondly, call the data platform party and use the private key to decrypt the first encrypted data to obtain the data to be processed, and call the preset marking method in the smart contract to mark the first encrypted data corresponding to the data to be processed as legal and attach data description information. Then, call the data requester and use the preset data acquisition method in the smart contract to obtain the target data in the data platform party according to the attached description information, and then pass through the data provider and use the first public key to encrypt the target data to obtain the second encrypted data. Finally, call the data provider and generate zero - knowledge proof parameters based on the first encrypted data and the second encrypted data, and call the data transfer method in the smart contract based on the second encrypted data and the zero - knowledge proof parameters to send the second encrypted data to the data requester, so that the data requester can use the private key to decrypt the second encrypted data to obtain the target data. In this way, the security of the data transfer operation is improved, thereby improving the efficiency of the production process.
[0100] Correspondingly, as shown in Figure 3 the present application also provides a data transfer device based on zero - knowledge proof, including:
[0101] The first encrypted data determination module 11 is configured to obtain the first private key generated by the data requester based on the key generation request and the first public key corresponding to the first private key, and use the second public key sent by the data platform party to the smart contract and the ElGamal algorithm to encrypt the target data to be transmitted to obtain the first encrypted data;
[0102] The second encrypted data determination module 12 is configured to obtain the first encrypted data marked as legal in the smart contract by the data platform party calling the preset marking method in the smart contract, associate the local data to be processed, and then use the first public key to encrypt the data to be processed to obtain the second encrypted data; the data to be processed is the data obtained by the data platform party decrypting the first encrypted data with the second private key corresponding to the second public key;
[0103] The target data determination module 13 is configured to generate zero-knowledge proof parameters based on the first encrypted data and the second encrypted data, and call the data transfer method in the smart contract based on the zero-knowledge proof parameters to send the second encrypted data to the smart contract, so that the data requester can obtain the second encrypted data from the smart contract, and decrypt the second encrypted data using the first private key to obtain the target data.
[0104] As can be seen from the above, before performing data transfer based on zero-knowledge proof in the embodiments of the present application, it is first necessary to generate a private key and a corresponding first public key based on a key generation request, and call the data platform party to generate a second public key. Then, call the data provider and encrypt the data to be encrypted using the ElGamal algorithm and the second public key to obtain the first encrypted data. Secondly, call the data platform party and decrypt the first encrypted data using the private key to obtain the data to be processed, and call the preset marking method in the smart contract to mark the first ciphertext data corresponding to the data to be processed as compliant on the smart contract, and attach data description information. Then, call the data requester and use the preset data acquisition method in the smart contract to obtain the target data in the data platform party according to the attached data description information, and then encrypt the target data using the first public key through the data provider to obtain the second encrypted data. Finally, call the data provider and generate zero-knowledge proof parameters based on the first encrypted data and the second encrypted data, and call the data transfer method in the smart contract based on the second encrypted data and the zero-knowledge proof parameters to send the second encrypted data to the data requester, so that the data requester can decrypt the second encrypted data using the private key to obtain the target data. In this way, the security of the data transfer operation is improved, thereby improving the efficiency of the production process.
[0105] In some specific embodiments, the first encrypted data determination module 11 may specifically include:
[0106] A prime number determination unit is configured to call a preset key generation center to determine a target prime number, determine a target primitive element based on the target prime number, and record the target prime number and the target primitive element in the smart contract of the blockchain;
[0107] A first private key determination unit is configured to call the preset key generation center to generate a first private key using the target prime number;
[0108] A public key recording unit is configured to determine a first public key corresponding to the first private key based on the first private key and a preset public key determination formula, send the first private key to the user corresponding to the data requester, and then record the first public key in the smart contract of the blockchain.
[0109] In some specific embodiments, the first encrypted data determination module 11 may specifically include:
[0110] The first encrypted data determination subunit is configured to obtain the second public key sent by the data platform party to the smart contract from the smart contract, determine a first target integer by using a preset integer determination rule, and then determine a first ciphertext corresponding to the target data to be transmitted based on the first target integer, the target primitive element, and the second public key, and determine a second ciphertext based on the target data to be transmitted, the target prime number, the first target integer, and the second public key, so as to determine the first encrypted data based on the first ciphertext and the second ciphertext;
[0111] The first voucher quantity judgment unit is configured to judge whether the current data transfer voucher quantity is less than a first preset quantity. If the current data transfer voucher quantity is not less than the first preset quantity, then based on the first encrypted data and the second public key, call a preset evaluation method in the smart contract in the blockchain to freeze the first preset quantity of data transfer vouchers of the data provider, so as to use the first preset quantity of frozen data transfer vouchers of the data provider to transfer the target data to be transmitted.
[0112] In some specific embodiments, the second encrypted data determination module 12 may specifically include:
[0113] The data decryption unit is configured to monitor the smart contract by the data platform party. If it is monitored that the preset evaluation method in the smart contract is called and the second public key is included in the preset evaluation method, then use the second private key to decrypt the first encrypted data to obtain the data to be processed;
[0114] The evaluation result determination unit is configured to call the data platform party and use the preset evaluation method to evaluate the data to be processed to obtain an evaluation result. If the evaluation result indicates that the data is non-compliant, then call the smart contract to record the data corresponding to the evaluation result and destroy the first preset quantity of data transfer vouchers of the data provider;
[0115] The marking method call unit is configured to, if the evaluation result indicates that the data is compliant, then call the data platform party and call a preset marking method in the smart contract based on the data to be processed, the first ciphertext, and the first preset quantity of frozen data transfer vouchers, so as to use the preset marking method to pre-mark the first ciphertext data corresponding to the data to be processed as compliant on the smart contract and attach data description information.
[0116] In some specific embodiments, the target data determination module 13 may specifically include:
[0117] A second voucher quantity judgment unit, configured to call the data requester and determine the required data in the data platform party based on its own requirements according to the additional data description information, and then call the smart contract to judge whether the quantity of data transfer vouchers corresponding to the data requester is less than a second preset quantity;
[0118] A transfer voucher freezing unit, configured to, if the quantity of data transfer vouchers corresponding to the data requester is not less than the second preset quantity, call a preset data acquisition method in the smart contract based on the first public key, so as to acquire the data to be processed by using the preset data acquisition method, and freeze a second preset quantity of data transfer vouchers of the data requester, so as to transfer the data to be processed by using the second preset quantity of frozen data transfer vouchers of the data requester;
[0119] A second encrypted data determination subunit, configured to determine a second target integer through the data provider, determine a third ciphertext corresponding to the data to be processed based on the second target integer and the target primitive element, determine a fourth ciphertext based on the data to be processed, the target prime number and the second target integer, and then determine second encrypted data based on the third ciphertext and the fourth ciphertext.
[0120] In some specific embodiments, the target data determination module 13 may specifically include:
[0121] A first data to be processed determination unit, configured to determine a first random integer based on the target prime number, determine a first data to be calculated based on the target prime number, the first random integer and the first target integer, determine a second data to be calculated based on the second target integer, the first random integer and the target prime number, determine a third data to be calculated based on the first random integer, the second target integer and the target primitive element, and determine a fourth data to be calculated based on the data to be processed and the first random integer;
[0122] A second data to be processed determination unit, configured to determine a second random integer based on the target prime number, determine a fifth data to be calculated based on the second random integer, the target prime number and the first target integer, determine a sixth data to be calculated based on the second random integer, the target prime number and the second target integer, determine a seventh data to be calculated based on the second random integer and the target primitive element, and determine an eighth data to be calculated based on the data to be processed and the second random integer;
[0123] A zero - knowledge proof parameter determination unit is configured to use a preset hash function and determine a hash value based on the first data to be calculated, the second data to be calculated, the third data to be calculated, the fourth data to be calculated, the fifth data to be calculated, the sixth data to be calculated, the seventh data to be calculated, and the eighth data to be calculated, and determine zero - knowledge proof parameters based on the hash value.
[0124] In some specific embodiments, the target data determination module 13 may specifically include:
[0125] A verification result determination unit is configured to use a number of preset verification formulas to respectively verify specific combinations of the first data to be calculated, the second data to be calculated, the third data to be calculated, the fourth data to be calculated, the fifth data to be calculated, the sixth data to be calculated, the seventh data to be calculated, and the eighth data to be calculated, and obtain corresponding verification results respectively;
[0126] A hash value determination unit is configured to, if all the verification results indicate that the verification is passed, call the data provider to use a preset hash function and determine a hash value based on the first data to be calculated, the second data to be calculated, the third data to be calculated, the fourth data to be calculated, the fifth data to be calculated, the sixth data to be calculated, the seventh data to be calculated, and the eighth data to be calculated.
[0127] Furthermore, an embodiment of the present application also discloses an electronic device. Figure 4 It is a structural diagram of an electronic device 20 shown according to an exemplary embodiment, and the content in the figure cannot be considered as any limitation on the scope of use of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input - output interface 25, and a communication bus 26. Among them, the memory 22 is used to store a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the data transfer method based on zero - knowledge proof disclosed in any of the foregoing embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0128] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows is any communication protocol applicable to the technical solution of the present application, and no specific limitation is imposed on it here; the input - output interface 25 is used to obtain external input data or output data to the outside, and its specific interface type can be selected according to specific application needs, and no specific limitation is made here.
[0129] In addition, as a carrier for storing resources, the memory 22 can be a read-only memory, a random access memory, a magnetic disk, an optical disc, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be transient storage or permanent storage.
[0130] Among them, the operating system 221 is used to manage and control each hardware device and the computer program 222 on the electronic device 20, and it can be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program that can be used to complete the data transfer method based on zero-knowledge proof executed by the electronic device 20 disclosed in any of the foregoing embodiments, the computer program 222 can further include computer programs that can be used to complete other specific tasks.
[0131] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the data transfer method based on zero-knowledge proof disclosed above. For the specific steps of this method, reference can be made to the corresponding content disclosed in the foregoing embodiments, and details will not be repeated here.
[0132] In this specification, the various embodiments are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the various embodiments, reference can be made to each other. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and reference can be made to the method part for related details.
[0133] Those skilled in the art can further realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed in this document can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been generally described according to their functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.
[0134] The steps of the methods or algorithms described in combination with the embodiments disclosed in this document can be directly implemented by hardware, software modules executed by a processor, or a combination of the two. The software modules can be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs, or any other form of storage medium well-known in the technical field.
[0135] Finally, it should also be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising said element.
[0136] The technical solutions provided in this application have been introduced in detail above. Specific examples are used in this text to elaborate on the principle and implementation manner of this application. The description of the above embodiments is only used to help understand the method and its core idea of this application; at the same time, for those of ordinary skill in the art, according to the idea of this application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to this application.
Claims
1. A data transfer method based on zero - knowledge proof, characterized in that, Applied to the data provider, including: Obtain the first private key generated by the data requester based on the key generation request and the first public key corresponding to the first private key, and use the second public key issued by the data platform party to the smart contract and the ElGamal algorithm to encrypt the target data to be transmitted, obtaining the first encrypted data; Obtain the first encrypted data marked as compliant by the data platform party by calling the preset marking method in the smart contract, and associate the local data to be processed, and then use the first public key to encrypt the data to be processed, obtaining the second encrypted data; the data to be processed is the data obtained by the data platform party decrypting the first encrypted data with the second private key corresponding to the second public key; Generate zero-knowledge proof parameters based on the first encrypted data and the second encrypted data, and call the data transfer method in the smart contract based on the zero-knowledge proof parameters to send the second encrypted data to the smart contract, so that the data requester can obtain the second encrypted data from the smart contract and use the first private key to decrypt the second encrypted data to obtain the target data.
2. The data transfer method based on zero-knowledge proof according to claim 1, wherein The process of the data requester generating the first private key and the first public key corresponding to the first private key based on the key generation request includes: Call the preset key generation center to determine the target prime number, and determine the target primitive element based on the target prime number, and record the target prime number and the target primitive element in the smart contract of the blockchain; Call the preset key generation center to generate the first private key using the target prime number; Determine the first public key corresponding to the first private key based on the first private key and the preset public key determination formula, and send the first private key to the user corresponding to the data requester, and then record the first public key in the smart contract of the blockchain.
3. The data transfer method based on zero-knowledge proof according to claim 2, wherein The process of using the second public key issued by the data platform party to the smart contract and the ElGamal algorithm to encrypt the target data to be transmitted, obtaining the first encrypted data, includes: Obtain the second public key issued by the data platform party to the smart contract from the smart contract, and use the preset integer determination rule to determine the first target integer, and then determine the first ciphertext corresponding to the target data to be transmitted based on the first target integer, the target primitive element and the second public key, and determine the second ciphertext based on the target data to be transmitted, the target prime number, the first target integer and the second public key, so as to determine the first encrypted data based on the first ciphertext and the second ciphertext; Judge whether the current number of data transfer vouchers is less than the first preset number. If the current number of data transfer vouchers is not less than the first preset number, then freeze the first preset number of data transfer vouchers of the data provider by calling the preset evaluation method in the smart contract in the blockchain based on the first encrypted data and the second public key, so as to use the first preset number of frozen data transfer vouchers of the data provider to transfer the target data to be transmitted.
4. The data transfer method based on zero-knowledge proof according to claim 3, wherein The data platform party calls a preset marking method in the smart contract to mark the first encrypted data that has passed the verification on the smart contract as compliant, including: The data platform party monitors the smart contract. If it is monitored that the preset evaluation method in the smart contract is called and the second public key is included in the preset evaluation method, the first encrypted data is decrypted using the second private key to obtain the data to be processed; Call the data platform party and use the preset evaluation method to evaluate the data to be processed to obtain an evaluation result. If the evaluation result indicates that the data is non-compliant, call the smart contract to record the data corresponding to the evaluation result and destroy the first preset number of data transfer vouchers of the data provider; If the evaluation result indicates that the data is compliant, call the data platform party and, based on the data to be processed, the first ciphertext, and the first preset number of frozen data transfer vouchers, call the preset marking method in the smart contract to pre-mark the first encrypted data corresponding to the data to be processed as compliant in the smart contract and append data description information.
5. The data transfer method based on zero-knowledge proof according to claim 4, wherein, The encrypting the data to be processed using the first public key to obtain second encrypted data includes: Call the data requester and, based on its own needs, determine the required data in the data platform party according to the additional data description information, and then call the smart contract to determine whether the number of data transfer vouchers corresponding to the data requester is less than the second preset number; If the number of data transfer vouchers corresponding to the data requester is not less than the second preset number, call the preset data acquisition method in the smart contract based on the first public key to obtain the data to be processed using the preset data acquisition method and freeze the second preset number of data transfer vouchers of the data requester for transferring the data to be processed using the second preset number of frozen data transfer vouchers of the data requester; Determine a second target integer through the data provider, determine a third ciphertext corresponding to the data to be processed based on the second target integer and the target primitive element, determine a fourth ciphertext based on the data to be processed, the target prime number, and the second target integer, and then determine the second encrypted data based on the third ciphertext and the fourth ciphertext.
6. The data transfer method based on zero-knowledge proof according to claim 5, characterized in that, The generating zero-knowledge proof parameters based on the first encrypted data and the second encrypted data includes: Determine a first random integer based on the target prime number, determine a first data to be calculated based on the target prime number, the first random integer, and the first target integer, determine a second data to be calculated based on the second target integer, the first random integer, and the target prime number, determine a third data to be calculated based on the first random integer, the second target integer, and the target primitive element, and determine a fourth data to be calculated based on the data to be processed and the first random integer; Determine a second random integer based on the target prime number, and determine fifth data to be calculated based on the second random integer, the target prime number, and the first target integer. Determine sixth data to be calculated based on the second random integer, the target prime number, and the second target integer. Determine seventh data to be calculated based on the second random integer and the target primitive element. Determine eighth data to be calculated based on the data to be processed and the second random integer; Use a preset hash function, and determine a hash value based on the first data to be calculated, the second data to be calculated, the third data to be calculated, the fourth data to be calculated, the fifth data to be calculated, the sixth data to be calculated, the seventh data to be calculated, and the eighth data to be calculated, and determine zero-knowledge proof parameters based on the hash value.
7. The data transfer method based on zero-knowledge proof according to claim 6, wherein The step of using a preset hash function and determining a hash value based on the first data to be calculated, the second data to be calculated, the third data to be calculated, the fourth data to be calculated, the fifth data to be calculated, the sixth data to be calculated, the seventh data to be calculated, and the eighth data to be calculated includes: Use a number of preset verification formulas to respectively verify specific combinations of the first data to be calculated, the second data to be calculated, the third data to be calculated, the fourth data to be calculated, the fifth data to be calculated, the sixth data to be calculated, the seventh data to be calculated, and the eighth data to be calculated, and obtain respectively corresponding verification results; If each of the verification results indicates that the verification is passed, then call the data provider to use a preset hash function and determine a hash value based on the first data to be calculated, the second data to be calculated, the third data to be calculated, the fourth data to be calculated, the fifth data to be calculated, the sixth data to be calculated, the seventh data to be calculated, and the eighth data to be calculated.
8. A data transfer device based on zero-knowledge proof, characterized in that Applied to a data provider, it includes: A first encrypted data determination module, configured to obtain a first private key generated by a data requester based on a key generation request and a first public key corresponding to the first private key, and use a second public key sent by a data platform party to a smart contract and the ElGamal algorithm to encrypt target data to be transmitted, so as to obtain first encrypted data; A second encrypted data determination module, configured to obtain the first encrypted data marked as compliant by the data platform party by calling a preset marking method in the smart contract, and associate local data to be processed, and then use the first public key to encrypt the data to be processed, so as to obtain second encrypted data; the data to be processed is the data obtained by the data platform party decrypting the first encrypted data using a second private key corresponding to the second public key; A target data determination module, configured to generate zero-knowledge proof parameters based on the first encrypted data and the second encrypted data, and call a data transfer method in the smart contract based on the zero-knowledge proof parameters to send the second encrypted data to the smart contract, so that the data requester can obtain the second encrypted data from the smart contract and decrypt the second encrypted data using the first private key to obtain the target data.
9. An electronic device, characterized in that, Comprising: A memory for storing computer programs; A processor for executing the computer programs to implement the zero-knowledge proof-based data transfer method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, For storing computer programs, wherein when the computer programs are executed by the processor, the zero-knowledge proof-based data transfer method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Block chain-based private data mapping method and device, medium and electronic equipment
CN113536384A
Face recognition privacy protection identity authentication method based on zero knowledge proof
CN114598479A
Homomorphic encryption system meeting zero knowledge proof
CN116015592A
Blockchain e-voting system and operating method thereof
US20220141020A1