Data query method and device based on block chain and homomorphic encryption and medium
By storing encrypted indexes and data on the blockchain, using homomorphic encryption and smart contract verification, security and privacy issues in the data query process are solved, and an accurate and privacy-protected data query solution is achieved.
Patent Information
- Application Number
- CN202410845047.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-11-08
AI Technical Summary
During the data query process, data security and the accuracy of query results are difficult to guarantee, especially in the process of data transmission, there is a risk of privacy leakage.
Using blockchain and homomorphic encryption data query method, the encrypted index and data are stored through the blockchain, and the query party queries and decrypts through the public and private keys, and uses smart contracts to verify the legality of the query results to ensure the query Accuracy and privacy of results.
It realizes the accuracy and privacy protection of query results, avoids the query party forgery of results and the third party obtaining sensitive information, and has less on-chain overhead and time complexity than other solutions.
Smart Images

Figure CN118921159A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a data query method, a system device and a storage medium based on blockchain and homomorphic encryption. Background Art
[0002] Blockchain is a decentralized ledger with the characteristics of immutable data, high security, and openness and transparency. Smart contracts are an automatically executed code based on blockchain technology. They are programs executed on them in a completely open and transparent manner. In other words, blockchain and smart contracts are the best way to ensure the open and transparent execution of the system.
[0003] With the development of network technology, the amount of data generated by various businesses has increased dramatically. In the process of business processing, data storage and storage-based queries are usually involved. However, during the data query process, data will be transmitted between devices, which will inevitably bring data security issues. At the same time, how to ensure the accuracy of query results is also a hot issue. Summary of the invention
[0004] The purpose of the embodiments of the present invention is to provide a data query method, device and storage medium based on blockchain and homomorphic encryption to ensure the accuracy of the query results and the privacy of both parties to the query.
[0005] To achieve the above objectives, in a first aspect, an embodiment of the present invention provides a data query method based on blockchain and homomorphic encryption, comprising:
[0006] The blockchain receives the public key H1 of the queried party, the public key H2 of the querying party, and the homomorphic number hnk of the index sequence plaintext i The homomorphic number of data corresponding to the index hnv i ;
[0007] The blockchain responds to the query request of the query party; the query request includes the index homomorphic number hnk of the query party;
[0008] If the query result is a query hit and the index homomorphic number hnk matches the index list stored on the chain, then based on the query party’s public key H2 and the homomorphic number hnv stored on the chain i The queried party provides the querying party with data corresponding to the query request.
[0009] As a specific implementation of this application, the blockchain receives the homomorphic number hnk of the indexed sequence plaintext i The homomorphic number of data corresponding to the index hnv i Specifically:
[0010] The queried party sorts all indexed plaintexts and obtains the index sequence plaintext ki , the index sequence plaintext k i The corresponding data are v i ;
[0011] The queried party uses the public key H1 to query the index sequence plaintext k i and the corresponding data v i Encryption, generate the homomorphic number hnk of the index sequence plaintext i The homomorphic number of data corresponding to the index hnv i , and wind it up.
[0012] As a specific implementation of the present application, the queried party provides the querying party with data corresponding to the query request, specifically:
[0013] The queried party calls the querying party's public key H2 to access the data v i Encrypt, generate the homomorphic number hnv, and record the random number y used to generate the homomorphic number hnv;
[0014] The queried party calls Algorithm 1 to generate a new equality proof; Algorithm 1 is a method for generating a new equality proof using two homomorphic numbers hnv i , hnv, the private key x used to generate the first homomorphic number, and the random number y used to generate the second homomorphic number as input, and output a new equality proof;
[0015] The queried party submits the homomorphic number hnv and the new equality proof to the smart contract for verification;
[0016] If the verification is successful, the querying party downloads the homomorphic number hnv from the chain and uses the querying party's private key x to decrypt the homomorphic number hnv to obtain the query result.
[0017] Among them, the queried party submits the homomorphic number hnv and the equality proof to the smart contract for verification, specifically:
[0018] The smart contract calls Algorithm 2 for verification; Algorithm 2 is a homomorphic number stored on the chain i , the homomorphic number hnv and the new equality proof submitted by the queried party are taken as input, and a Boolean value is output; if the Boolean value is true, the verification passes, indicating that the submission is legal, otherwise it means that the submission fails.
[0019] In a second aspect, an embodiment of the present invention provides another data query method based on blockchain and homomorphic encryption, including:
[0020] The homomorphic number hnk of the plaintext index sequence generated by the queried party i The homomorphic number of data corresponding to the index hnv i , and chain it up;
[0021] The queried party obtains the query index homomorphic number submitted by the querying party from the chain;
[0022] The queried party confirms the index list according to the query index homomorphic number. If a hit is found, the plaintext data v corresponding to the query index homomorphic number is obtained. i ;
[0023] The queried party uses the querier’s public key H2 to parse the plaintext data v i Encrypt to generate homomorphic number hnv and generate new equality proof;
[0024] The queried party submits the homomorphic number hnv and the new equality proof to the smart contract for verification;
[0025] If the verification is successful, the querying party downloads the homomorphic number hnv from the chain and uses the querying party's private key x to decrypt the homomorphic number hnv to obtain the query result.
[0026] In the third aspect, an embodiment of the present invention also provides a data query device based on blockchain and homomorphic encryption, comprising a processor, an input device, an output device and a memory, wherein the processor, input device, output device and memory are interconnected, wherein the memory is used to store a computer program, and the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method of the second aspect above.
[0027] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium storing a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the method of the second aspect.
[0028] The implementation of the embodiment of the present invention has the following advantages:
[0029] (1) The data query solution of the embodiment of the present invention is executed based on the blockchain. Specifically, the data owner uploads all indexes and data pairs to the blockchain for evidence storage. The querying party submits a query request for a certain index to the blockchain, and the blockchain can return the data corresponding to the query index. This ensures that the query result cannot be forged by the queried party, thereby ensuring the accuracy of the query result.
[0030] (2) All indexes and data should be stored in an encrypted form on the blockchain. No one can directly obtain the relevant information, which can protect the privacy of the queried party. At the same time, the solution can also achieve privacy protection of the query content of the query party. No one except the queried party and the query party can directly obtain the index and corresponding data of the query.
[0031] (3) Compared with other well-known zero-knowledge proof schemes such as zk-SNARK, the zero-knowledge proof scheme combined with homomorphic encryption used in the present invention does not need to rely on a trusted third party for trusted setup and has smaller on-chain overhead: the length of the proof and the on-chain time complexity are both at a constant level. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the specific implementation of the present invention or the technical solution in the prior art, the drawings required for use in the specific implementation or the description of the prior art are briefly introduced below.
[0033] Figure 1 is a flow chart of a data query method based on blockchain and homomorphic encryption provided by the first embodiment of the present invention;
[0034] Figure 2 is a flow chart of a data query method based on blockchain and homomorphic encryption provided by the second embodiment of the present invention;
[0035] Figure 3 It is a structural diagram of a data query device based on blockchain and homomorphic encryption provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0036] 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 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.
[0037] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0038] The data query solution based on blockchain and homomorphic encryption provided by the present invention includes the query party and the queried party. The queried party owns the data, and the data is stored in the form of index=>data (key=>value) pairing. The query request of the query party is an index, and the queried party needs to provide the data corresponding to the index.
[0039] It should be noted that the present invention is mainly implemented based on blockchain scenarios, but is not limited to other scenarios that can ensure the open and transparent operation of the system, such as third-party hosted databases, cloud computing, etc.
[0040] In addition, the encryption system of the present invention is the ElGamal encryption system, which is an encryption system based on discrete logarithms and has homomorphic properties.
[0041] The present invention relates to zero-knowledge proof technology, which can prove a certain point without revealing the evidence. Specifically, the technology used in the present invention is to prove that the plaintexts corresponding to two ciphertexts are the same without revealing the private key and the plaintext. Different from the prior art, the two ciphertexts of the present invention are encrypted with different public keys.
[0042] Please refer to Figure 1 , is a data query method based on blockchain and homomorphic encryption provided by an embodiment of the present invention, comprising:
[0043] S1, blockchain receives the public key H1 of the queried party, the public key H2 of the querying party, and the homomorphic number hnk of the index sequence plaintext i The homomorphic number of data corresponding to the index hnv i .
[0044] It should be noted that the data query method of the embodiment of the present invention mainly includes an initialization process and a query process, step S1 refers to the initialization process, and steps S2 and S3 refer to the query process. Specifically, the initialization process is as follows:
[0045] Assume that there is a cyclic group with a generator of G, an identity of O, and an order of q. Multiplication is used to represent group operations. The querying party and the queried party both establish a pair of public and private keys. The process is to randomly select x∈{1,...,q-1} as the private key and calculate the public key as H=G x Among them, H1 represents the public key of the queried party, and H2 represents the public key of the querying party. All public keys are published on the blockchain and recorded by the smart contract, hereinafter referred to as on-chain.
[0046] Assume that all indexes and data can be encoded into 1 to 2 in a way that is consistent between the querying party and the queried party. 31 numbers.
[0047] In this embodiment, the concept of homomorphic number is introduced, which includes a public key and a ciphertext obtained by encrypting a plaintext with the public key. A homomorphic number can be written in the form of hn = (C, D, H).
[0048] The queried party sorts all indexed plaintexts and obtains index sequence plaintexts k1, k2, ..., k n , and for each i=1,2,...,n-1,k i <k i+1 , where n is the total number of data. Assume that indexes k1, k2, ..., k n The corresponding data are v1, v2, ..., v n. The queried party then uses its own public key H1 to query the plaintext (k i , v i ) Generate homomorphic numbers (hnk i , hnv i ) and wind it up.
[0049] S2, the blockchain responds to the query request from the querying party.
[0050] The query request includes the index homomorphic number hnk of the querying party. Specifically, the querying party encrypts the query index k with the public key H1 to obtain the homomorphic number hnk.
[0051] S3: If the query result is a hit and the query party's index matches the index list stored on the chain, then based on the query party's public key H2 and the homomorphic number hnv stored on the chain i The queried party provides the querying party with data corresponding to the query request.
[0052] In fact, the query process of the present invention includes:
[0053] Part 1: Determine whether the index queried by the querying party is in the index list;
[0054] Part 2: The queried party provides the querying party with data corresponding to the index.
[0055] The following is a detailed description of the first part:
[0056] In fact, this part is a list query problem. The query request is the index homomorphic number hnk of the query party, and the list is the entire index list {hnk i |i=1,...,n}. The blockchain returns two results: (1) The query does not hit, that is, the index is not in the list, which means the query fails and the query process ends. (2) The query hits and matches the index hnk i Match, and then enter the second part. Note that in either case, the queried party needs to submit a zero-knowledge proof to prove the legitimacy of the result, ensuring that the queried party cannot tamper with the query result even if it does something malicious, and the privacy of the queried party will not be leaked.
[0057] The specific process of the second part is as follows:
[0058] 1. The queried party uses the querying party’s public key H2 to index the plaintext data v i Generate a homomorphic number hnv and record the random number y used to generate the homomorphic number hnv.
[0059] 2. The queried party calls Algorithm 1 to generate a new equality proof, using two homomorphic numbers hnv i,hnv, can decrypt the private key x of the first homomorphic number and the random number y used to generate the second homomorphic number as input to obtain an equality proof. The content of the proof is two homomorphic numbers hnv,hnv i The corresponding plaintext is the same.
[0060] Among them, Algorithm 1: New equality proof generation algorithm
[0061] Input: two homomorphic numbers (C1, D1, H1), (C2, D2, H2), a private key x that can decrypt the first homomorphic number, and a random number y that generates the second homomorphic number
[0062] v1←random(),v2←random()
[0063]
[0064] s1←xe+v1,s2←ye+v2
[0065] Output: e, s1, s2
[0066] 3. The queried party submits the HNV and the equality proof to the smart contract. The smart contract calls Algorithm 2 (new equality proof verification algorithm) to verify the HNV stored on the chain. i , the hnv and equality proof submitted by the queried party are used as input, and a Boolean value is output to indicate whether the verification is passed. If the verification is passed, it means that the submission is legal, and jump to 4; otherwise, it means that the submission fails, and jump to 1.
[0067] Among them, the new equality proof verification algorithm
[0068] Input: Two homomorphic numbers (C1, D1, H1), (C2, D2, H2), Proof (e, s1, s2)
[0069]
[0070] Output:
[0071] 4. After the querying party sees that the smart contract has been verified, it downloads hnv from the chain, and then uses its own private key x to decrypt the homomorphic number to obtain the query result. The process ends.
[0072] The implementation of the embodiment of the present invention has the following advantages:
[0073] (1) The data query solution of the embodiment of the present invention is executed based on the blockchain. Specifically, the data owner uploads all indexes and data pairs to the blockchain for evidence storage. The querying party submits a query request for a certain index to the blockchain, and the blockchain can return the data corresponding to the query index. This ensures that the query result cannot be forged by the queried party, thereby ensuring the accuracy of the query result.
[0074] (2) All indexes and data should be stored in an encrypted form on the blockchain. No one can directly obtain the relevant information, which can protect the privacy of the queried party. At the same time, the solution can also achieve privacy protection of the query content of the query party. No one except the queried party and the query party can directly obtain the index and corresponding data of the query.
[0075] (3) Compared with other well-known zero-knowledge proof schemes such as zk-SNARK, the zero-knowledge proof scheme combined with homomorphic encryption used in the present invention does not need to rely on a trusted third party for trusted setup and has smaller on-chain overhead: the length of the proof and the on-chain time complexity are both at a constant level.
[0076] Based on the same inventive concept, the embodiment of the present invention provides another data query method based on blockchain and homomorphic encryption, such as Figure 2 As shown, it includes:
[0077] 1. The queried party generates the homomorphic number hnk of the index sequence plaintext i The homomorphic number of data corresponding to the index hnv i , and wind it up.
[0078] In the specific implementation, all indexed plaintexts are sorted to obtain the index sequence plaintext k i , the index sequence plaintext k i The corresponding data are plaintext data v i ;
[0079] Use the public key H1 of the queried party to index the plaintext k i and the corresponding plaintext data v i Encryption, generate the homomorphic number hnk of the index sequence plaintext i The homomorphic number of data corresponding to the index hnv i .
[0080] 2. The queried party obtains the query index homomorphic number submitted by the querying party from the chain.
[0081] 3. The queried party obtains the query index homomorphic number from the chain.
[0082] 4. The queried party confirms the index list according to the query index homomorphic number. If a hit is found, the plaintext data v corresponding to the query index homomorphic number is obtained.i .
[0083] 5. The queried party uses the querier’s public key H2 to parse the plaintext data v i Encrypt to generate the homomorphic number hnv, and generate a new equality proof.
[0084] In the specific implementation, the random number y used to generate the homomorphic number hnov is recorded, and the algorithm 1 is called to generate a new equality proof; wherein the algorithm 1 is a method for generating a new equality proof using two homomorphic numbers hnov i , hnv, the private key x used to generate the first homomorphic number, and the random number y used to generate the second homomorphic number as input, and output a new equality proof.
[0085] 6. The queried party submits the homomorphic number hnv and the new equality proof to the smart contract for verification.
[0086] 7. The blockchain verifies the legitimacy of the new equality certificate.
[0087] The smart contract calls Algorithm 2 for verification; Algorithm 2 is a homomorphic number stored on the chain i , the homomorphic number hnv and the new equality proof submitted by the queried party are taken as input, and a Boolean value is output; if the Boolean value is true, the verification passes, indicating that the submission is legal, otherwise it means that the submission fails.
[0088] 8. The querying party downloads the homomorphic number hnv from the chain.
[0089] 9. The querying party uses its own private key to decrypt the homomorphic number hnv and obtain the query result.
[0090] It should be noted that Figure 2 For a more detailed description of the method flow shown, please refer to Figure 1 The description of the method flow shown will not be repeated here.
[0091] Furthermore, another embodiment of the present invention also provides a data query device based on blockchain and homomorphic encryption, such as Figure 3 As shown, the system may include: one or more processors 101, one or more input devices 102, one or more output devices 103 and a memory 104, wherein the processors 101, the input devices 102, the output devices 103 and the memory 104 are interconnected via a bus 105. The memory 104 is used to store a computer program, wherein the computer program includes program instructions, and the processor 101 is configured to call the program instructions to execute the method of the above method embodiment.
[0092] It should be understood that in the embodiment of the present invention, the processor 101 may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0093] The input device 102 may include a keyboard, etc., and the output device 103 may include a display (LCD, etc.), a speaker, etc.
[0094] The memory 104 may include a read-only memory and a random access memory, and provides instructions and data to the processor 101. A portion of the memory 104 may also include a non-volatile random access memory. For example, the memory 104 may also store information on the device type.
[0095] In a specific implementation, the processor 101, input device 102, and output device 103 described in the embodiment of the present invention can execute the implementation method described in the embodiment of the data query method based on blockchain and homomorphic encryption provided by the embodiment of the present invention, which will not be repeated here.
[0096] Accordingly, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the above-mentioned data query method based on blockchain and homomorphic encryption is implemented.
[0097] The computer-readable storage medium may be an internal storage unit of the system described in any of the foregoing embodiments, such as a hard disk or memory of the system. The computer-readable storage medium may also be an external storage device of the system, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the system. Furthermore, the computer-readable storage medium may also include both an internal storage unit of the system and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the system. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
[0098] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0099] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, or it can be an electrical, mechanical or other form of connection.
[0100] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present invention.
[0101] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0102] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0103] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A data query method based on blockchain and homomorphic encryption, characterized in that: include: The blockchain receives the public key H1 of the queried party, the public key H2 of the querying party, and the homomorphic number hnk of the index sequence plaintext i The homomorphic number of data corresponding to the index hnv i ; The blockchain responds to the query request of the query party; the query request includes the index homomorphic number hnk of the query party; If the query result is a query hit and the index homomorphic number hnk matches the index list stored on the chain, then based on the query party’s public key H2 and the homomorphic number hnv stored on the chain i The queried party provides the querying party with data corresponding to the query request.
2. The data query method according to claim 1, characterized in that: The blockchain receives the homomorphic number hnk of the indexed sequence plaintext i The homomorphic number of data corresponding to the index hnv i Specifically: The queried party sorts all indexed plaintexts and obtains the index sequence plaintext k i , the index sequence plaintext k i The corresponding data are v i ; The queried party uses the public key H1 to query the index sequence plaintext k i and the corresponding data v i Encryption, generate the homomorphic number hnv of the index sequence plaintext i The homomorphic number of data corresponding to the index hnv i , and wind it up.
3. The data query method according to claim 1, characterized in that: The queried party provides the querying party with data corresponding to the query request, specifically: The queried party calls the querying party's public key H2 to access the data v i Encrypt, generate the homomorphic number hnv, and record the random number y used to generate the homomorphic number hnv; The queried party calls Algorithm 1 to generate a new equality proof; Algorithm 1 is a method for generating a new equality proof using two homomorphic numbers hnv i ,hnv, the private key x used to generate the first homomorphic number, and the random number y used to generate the second homomorphic number as input, and output a new equality proof; The queried party submits the homomorphic number hnv and the new equality proof to the smart contract for verification; If the verification is successful, the querying party downloads the homomorphic number hnv from the chain and uses the querying party's private key x to decrypt the homomorphic number hnv to obtain the query result.
4. The data query method according to claim 3, characterized in that: The queried party submits the homomorphic number hnv and the equality proof to the smart contract for verification, specifically: The smart contract calls Algorithm 2 for verification; Algorithm 2 is a homomorphic number stored on the chain i , the homomorphic number hnv and the new equality proof submitted by the queried party are taken as input, and a Boolean value is output; If the Boolean value is true, the verification passes, indicating that the submission is legal; otherwise, the submission fails.
5. A data query method based on blockchain and homomorphic encryption, characterized in that: include: The homomorphic number hnk of the plaintext index sequence generated by the queried party i The homomorphic number of data corresponding to the index hnv i , and chain it up; The queried party obtains the query index homomorphic number submitted by the querying party from the chain; The queried party confirms the index list according to the query index homomorphic number. If a hit is found, the plaintext data v corresponding to the query index homomorphic number is obtained. i ; The queried party uses the querier’s public key H2 to parse the plaintext data v i Encrypt to generate homomorphic number hnv and generate new equality proof; The queried party submits the homomorphic number hnv and the new equality proof to the smart contract for verification; If the verification is successful, the querying party downloads the homomorphic number hnv from the chain and uses the querying party's private key x to decrypt the homomorphic number hnv to obtain the query result.
6. The data query method according to claim 5, characterized in that: The queried party generates the homomorphic number hnk i and homomorphic number hnv i , specifically: Sort all indexed plaintexts to get index sequence plaintext k i , the index sequence plaintext k i The corresponding data are plaintext data v i ; Use the public key H1 of the queried party to index the plaintext k i and the corresponding plaintext data v i Encryption, generate the homomorphic number hnk of the index sequence plaintext i The homomorphic number of data corresponding to the index hnv i .
7. The data query method according to claim 5, characterized in that: After generating the homomorphic number hnv, the data query method further includes recording the random number y used to generate the homomorphic number hnv; Generate a new equality proof as follows: Call Algorithm 1 to generate a new equality proof; Algorithm 1 is to use two homomorphic numbers hnv i ,hnv, the private key x used to generate the first homomorphic number, and the random number y used to generate the second homomorphic number as input, and output a new equality proof.
8. The data query method according to claim 5, characterized in that: Submit the homomorphic number hnv and the equality proof to the smart contract for verification, specifically: The smart contract calls Algorithm 2 for verification; Algorithm 2 is a homomorphic number stored on the chain i , the homomorphic number hnv and the new equality proof submitted by the queried party are taken as input, and a Boolean value is output; If the Boolean value is true, the verification passes, indicating that the submission is legal; otherwise, the submission fails.
9. A data query device based on blockchain and homomorphic encryption, characterized in that: The method comprises a processor, an input device, an output device and a memory, wherein the processor, the input device, the output device and the memory are interconnected, wherein the memory is used to store a computer program, the computer program comprises program instructions, and the processor is configured to call the program instructions to execute the method according to any one of claims 5 to 8.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the method according to any one of claims 5 to 8.
