Data query method and device, equipment, medium and program product
By using hash bucket allocation and key mechanisms, and leveraging bucket indexes and query masks for data retrieval, the problem of balancing efficiency and security in existing technologies is solved, achieving efficient and secure retrieval of privacy-preserving information.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-23
- Publication Date
- 2026-03-27
AI Technical Summary
Existing data query technologies cannot balance efficiency and security, especially when dealing with large amounts of data, where computational complexity is high and security is insufficient.
By employing a hash bucket allocation and key mechanism, data is distributed into B hash buckets. Querying is performed using bucket indexes and query masks. Matching keys and encryption keys are generated through an unintentional pseudo-random function, enabling privacy information retrieval while reducing computation and communication load.
While enabling the retrieval of private information, it significantly reduces computing, storage, and communication overhead, improves query efficiency and response speed, and balances efficiency and security.
Smart Images

Figure CN121743344A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information security technology, and in particular to a data query method, apparatus, device, medium, and program product. Background Technology
[0002] With the development of big data and cloud computing technologies, more and more users are entrusting cloud servers or third-party service providers to store and manage their local data. Against this backdrop, how to protect user privacy while ensuring data availability has become a crucial issue in the field of data security. Taking a typical query scenario as an example, users often want to retrieve a specific record from a remote database, but do not want the server to know their actual query target or interests.
[0003] To resolve the aforementioned contradictions, related technologies have proposed Private Information Retrieval (PIR) technology. The basic goal of PIR is to enable clients to retrieve the required data items from the database stored on the server without disclosing the query index or query content.
[0004] Related PIR (Proof-of-Reference) technologies, such as homomorphic PIR, encrypt the query content. The server processes the query and returns the encrypted result, which the user then decrypts to obtain the final result. While this approach effectively protects data privacy, it suffers from high computational complexity and long processing time, especially when dealing with large datasets. Conversely, while not using PIR can improve data query efficiency, it can compromise data security. Therefore, existing data query technologies suffer from a trade-off between efficiency and security. Summary of the Invention
[0005] This application provides a data query method, apparatus, device, medium, and program product, which can solve the problem that existing data query technologies cannot simultaneously achieve both efficiency and security.
[0006] In a first aspect, embodiments of this application provide a data query method applied to a server, the method comprising: Upon receiving a query request from a client, the system responds to the query request by performing a query in B hash buckets based on the bucket index and query mask in the query request to obtain the query result. Each of the B hash buckets stores N data items from the original dataset, and each hash bucket stores at least one of the N data items and a corresponding data tag. The data tag indicates the storage location of the corresponding data within the hash bucket. The hash distance between data items stored in the same hash bucket is less than a preset distance. Each of the B hash buckets corresponds one-to-one with B key information items, including a matching key and an encryption key. The encryption key is used to encrypt the data tags to obtain encrypted tags. B is an integer greater than 1, and N is an integer greater than or equal to B. The query result includes a mask-style unintentional pseudo-random function value, a first matching key, and a first encrypted tag set. The first encrypted tag set consists of encrypted tags in the hash bucket corresponding to the bucket index, and the first matching key is the matching key in the hash bucket corresponding to the bucket index. The query results are sent to the client.
[0007] Optionally, before receiving a query request from the client, the method further includes: The hash value of the first user identifier corresponding to the N data is calculated using the first hash function to obtain N first hash values; Each of the N first hash values is modulo B to obtain N bucket index values that correspond one-to-one with the N data; Based on the N bucket index values, the N data are assigned to corresponding hash buckets. The hash bucket number to which the first data is assigned is consistent with the bucket index value of the first data. The first data is any one of the N data. The hash buckets among the B hash buckets have different numbers.
[0008] Optionally, after allocating the N data items to corresponding hash buckets based on the N bucket index values, the method further includes: Obtain the preset private key and the preset generators of Elliptic Curve Cryptography (ECC); Based on the preset private key, the preset generator, and the data stored in the first hash bucket, calculate the set of unintentional pseudo-random function outputs of the first hash bucket, where the first hash bucket is any one of the B hash buckets; Based on the output set of the unintentional pseudo-random function, a matching key and an encryption key corresponding to the first hash bucket are generated.
[0009] Optionally, obtaining the query result based on the bucket index, query mask, and the hash bucket corresponding to the bucket index among the B hash buckets in the query request includes: Based on the bucket index, a second hash bucket is determined from the B hash buckets, and a first matching key corresponding to the second hash bucket is obtained from the second hash bucket. The number of the second hash bucket is the same as the value of the bucket index. Based on the data stored in the second hash bucket, an unintentional pseudo-random function is calculated on the query mask to obtain the mask-type unintentional pseudo-random function value.
[0010] Optionally, after sending the query result to the client, the method further includes: Receive feedback results sent by the client; Wherein, when the second matching key and the first matching key are the same, the feedback result is used to indicate that the query result is correct. The second matching key and the first encryption key are both keys extracted from the privacy-inadvertent pseudo-random function value. The privacy-inadvertent pseudo-random function value is obtained by removing the mask of the masked uninadvertent pseudo-random function value. If the second matching key and the first matching key are not the same, the feedback result is used to indicate that the query result is incorrect.
[0011] Secondly, embodiments of this application also provide a data query method applied to a client, the method comprising: Send a query request to the server, the query request including a bucket index and a query mask; The system receives a query result sent by the server. The query result includes a masked unintentional pseudo-random function value, a first matching key, and a first encrypted tag set. The query result is obtained by querying B hash buckets based on the bucket index and the query mask. The first encrypted tag set consists of encrypted tags of the hash bucket corresponding to the bucket index. The first matching key is the matching key in the hash bucket corresponding to the bucket index. The B hash buckets store N data items included in the original dataset. Each hash bucket stores at least one of the N data items and a data tag corresponding to the stored data. The data tag indicates the storage location of the corresponding data in the hash bucket. The hash distance between data items stored in the same hash bucket is less than a preset distance. The B hash buckets correspond one-to-one with B key information items. The key information includes a matching key and an encryption key. The encryption key is used to encrypt the data tags to obtain encrypted tags. B is an integer greater than 1, and N is an integer greater than or equal to B.
[0012] Optionally, after receiving the query result sent by the server, the method further includes: Remove the mask from the masked unintentional pseudo-random function value to obtain the privacy unintentional pseudo-random function value; Extract the second matching key and the first encryption key from the value of the privacy-inadvertent pseudo-random function; If the second matching key and the first matching key are the same, a feedback result indicating that the query result is correct is sent to the server; or, if the second matching key and the first matching key are different, a feedback result indicating that the query result is incorrect is sent to the server.
[0013] Optionally, before sending a query request to the server, the method further includes: Obtain the client's second user identifier, a preset random number, and a preset generator, as well as the first hash function and the number of hash buckets B on the server; The second hash value is obtained by calculating the hash value of the second user identifier based on the first hash function; The second hash value is modulo B to obtain the bucket index; The query mask is calculated based on the second hash value, the preset random number, and the preset generator.
[0014] Thirdly, embodiments of this application also provide a data query device applied to a server, the device comprising: The first receiving module is configured to respond to a query request sent by a client upon receiving the query request, and perform a query in B hash buckets based on the bucket index and query mask in the query request to obtain a query result. The B hash buckets store N data items included in the original dataset, and each hash bucket stores at least one of the N data items and a data tag corresponding to the stored data. The data tag indicates the storage location of the corresponding data in the hash bucket. The hash distance between data items stored in the same hash bucket is less than a preset distance. The B hash buckets correspond one-to-one with B key information items. The key information includes a matching key and an encryption key. The encryption key is used to encrypt the data tags to obtain encrypted tags. B is an integer greater than 1, and N is an integer greater than or equal to B. The query result includes a mask-style unintentional pseudo-random function value, a first matching key, and a first encrypted tag set. The first encrypted tag set consists of encrypted tags in the hash bucket corresponding to the bucket index, and the first matching key is the matching key in the hash bucket corresponding to the bucket index. The first sending module is used to send the query result to the client.
[0015] Fourthly, embodiments of this application also provide a data query device applied to a client, the device comprising: The second sending module is used to send a query request to the server, the query request including a bucket index and a query mask; The second receiving module is used to receive the query result sent by the server. The query result includes a masked unintentional pseudo-random function value, a first matching key, and a first encrypted tag set. The query result is obtained by querying B hash buckets based on the bucket index and the query mask. The first encrypted tag set is the encrypted tag of the hash bucket corresponding to the bucket index. The first matching key is the matching key in the hash bucket corresponding to the bucket index. The B hash buckets store N data items included in the original dataset. Each hash bucket stores at least one of the N data items and a data tag corresponding to the stored data. The data tag is used to indicate the storage location of the corresponding data in the hash bucket. The hash distance between data items stored in the same hash bucket is less than a preset distance. The B hash buckets correspond one-to-one with B key information items. The key information includes a matching key and an encryption key. The encryption key is used to encrypt the data tag to obtain an encrypted tag. B is an integer greater than 1, and N is an integer greater than or equal to B.
[0016] Fifthly, embodiments of this application also provide an electronic device, including a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the data query method as described in the first or second aspect.
[0017] In a sixth aspect, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the data query method as described in the first or second aspect.
[0018] A seventh aspect provides a computer program product including computer instructions that, when executed by a processor, implement the steps of the data query method as described in the first or second aspect.
[0019] In this embodiment, upon receiving a query request from a client, the system responds to the query request by performing a query in B hash buckets based on the bucket index and query mask in the query request to obtain a query result. Each of the B hash buckets stores N data items from the original dataset, and each hash bucket stores at least one of the N data items and a corresponding data tag. The data tag indicates the storage location of the corresponding data within the hash bucket. The hash distance between data items stored in the same hash bucket is less than a preset distance. Each of the B hash buckets corresponds one-to-one with B key information items, including a matching key and an encryption key. The encryption key is used to encrypt the data tags to obtain encrypted tags. B is an integer greater than 1, and N is an integer greater than or equal to B. The query result includes a mask-style unintentional pseudo-random function value, a first matching key, and a first encrypted tag set. The first encrypted tag set consists of encrypted tags in the hash bucket corresponding to the bucket index, and the first matching key is the matching key in the hash bucket corresponding to the bucket index. The system then sends the query result to the client. In this method, the data used by the client for data querying is replaced by bucket indexes and query masks, which does not disclose the identity information of the user corresponding to the client or the query content. Furthermore, the query results sent by the server to the client do not display the queried data in plaintext, thus achieving privacy-preserving information retrieval. Based on this, the original dataset in the server is distributed into B hash buckets. When querying data, it is not necessary to traverse the entire original dataset; each query only processes the data related to the hash bucket corresponding to the bucket index. This significantly reduces the computational and communication load, lowering computational, storage, and communication overhead, and reducing the amount of data processed per query, thereby improving query efficiency and response speed. Therefore, the method of this application embodiment can improve query efficiency while achieving privacy-preserving information retrieval, thus balancing high efficiency and security in data querying. Attached Figure Description
[0020] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart of a data query method provided in an embodiment of this application; Figure 2 This is a flowchart of data bucketing provided in an embodiment of this application; Figure 3 This is a flowchart illustrating the generation of key information provided in an embodiment of this application; Figure 4 This is a schematic diagram of the algorithm flow of the data query method provided in the embodiments of this application; Figure 5 This is a flowchart of another data query method provided in the embodiments of this application; Figure 6 This is a structural diagram of a data query device provided in an embodiment of this application; Figure 7 This is a structural diagram of another data query device provided in an embodiment of this application; Figure 8 This is a structural diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0022] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0023] This application provides a data query method applied to a server, such as... Figure 1 As shown, the data query method includes the following steps: Step 101: Upon receiving a query request from the client, respond to the query request and, based on the bucket index and query mask in the query request, perform a query in B hash buckets to obtain the query result. The B hash buckets store N data items included in the original dataset, and each hash bucket stores at least one of the N data items and a data tag corresponding to the stored data. The data tag is used to indicate the storage location of the corresponding data in the hash bucket. The hash distance between data items stored in the same hash bucket is less than a preset distance. The B hash buckets correspond one-to-one with B key information items. The key information includes a matching key and an encryption key. The encryption key is used to encrypt the data tag to obtain an encrypted tag. B is an integer greater than 1, and N is an integer greater than or equal to B. The query result includes a mask-style unintentional pseudo-random function value, a first matching key, and a first encrypted tag set. The first encrypted tag set consists of encrypted tags in the hash bucket corresponding to the bucket index, and the first matching key is the matching key in the hash bucket corresponding to the bucket index. Step 102: Send the query result to the client.
[0024] In this embodiment, the server receives a query request sent by the client, which carries a bucket index and a query mask. The bucket index and query mask can be determined by a second user identifier associated with the client. Neither the bucket index nor the query mask explicitly displays the user identity corresponding to the client (the second user identifier can indicate the user identity), meaning that the user identity corresponding to the query request cannot be obtained from the server.
[0025] Based on the bucket index, the server can determine the first hash bucket corresponding to the bucket index and the first matching key corresponding to the second hash bucket. Then, based on the query mask, the server determines the corresponding first encrypted tag set from the second hash bucket and calculates the masked unintentional pseudo-random function value. After determining the masked unintentional pseudo-random function value, the first matching key, and the first encrypted tag set, the server sends the query result to the client, which can then obtain the data it needs based on the query result.
[0026] The application scenario of this embodiment can be: For a given application, the server stores user data for multiple users of the application, with the user data stored in B hash buckets. When a user uses the application, the application needs to retrieve the user data. The client sends a query request to the server. In a non-PIR (Proof-of-Input) scenario, the client can directly send the user's second user identifier (e.g., phone number, nickname, ID). In this embodiment, the client sends the bucket index and query mask to the server. Both the bucket index and query mask are determined by the second user identifier, but neither the bucket index nor the query mask explicitly displays the second user identifier. Furthermore, the query results sent by the server to the client do not explicitly display the user data, thus achieving PIR.
[0027] In the data query method of this application embodiment, the second user identifier used by the client for data querying is replaced by a bucket index and a query mask. This avoids disclosing the identity information of the user corresponding to the client and the query content, and the query results sent by the server to the client do not display the queried data in plaintext, thereby achieving privacy information retrieval. Based on this, the original dataset in the server is distributed into B hash buckets. When querying data, it is not necessary to traverse the entire original dataset; each query only needs to process the data related to the hash bucket corresponding to the bucket index. This significantly reduces the computational and communication load, lowering computational, storage, and communication overhead, and reducing the amount of data processed per query, thereby improving query efficiency and response speed. Therefore, the method of this application embodiment can improve query efficiency while achieving privacy information retrieval, thus balancing high efficiency and security in data querying.
[0028] The data query method of this application can be divided into two stages: an offline setup stage and an online query stage. In the offline setup stage, the data held by the data sender is preprocessed, including data bucketing, key generation, encryption, etc. The online query stage includes the above steps 101-102.
[0029] Optionally, before receiving a query request from the client, i.e., during the offline setup phase, the method further includes: The hash value of the first user identifier corresponding to the N data is calculated using the first hash function to obtain N first hash values; Each of the N first hash values is modulo B to obtain N bucket index values that correspond one-to-one with the N data; Based on the N bucket index values, the N data are assigned to corresponding hash buckets. The hash bucket number to which the first data is assigned is consistent with the bucket index value of the first data. The first data is any one of the N data. The hash buckets among the B hash buckets have different numbers.
[0030] In this embodiment, as Figure 2 As shown, before calculating the first hash value, the data preprocessing can be completed by preliminarily cleaning and standardizing the data held by the data sender and the corresponding labels to obtain the original dataset, which includes the N data.
[0031] After obtaining the N data, initial bucketing with equal hash distance can be performed, including: calculating the hash value of the first user identifier corresponding to the N data using the first hash function to obtain N first hash values; Each of the N first hash values is modulo B to obtain N bucket index values that correspond one-to-one with the N data; Based on the N bucket index values, the N data are allocated to the corresponding hash buckets.
[0032] The formula for calculating the bucket index value can be: ,in, The identifier (first user identifier) representing the user corresponding to the data. This represents the first hash value obtained by calculating the hash value of the first user identifier using the first hash function. This indicates modulo calculation.
[0033] The corresponding hash bucket can be determined based on the bucket index value. The hash bucket number can be from 0 to B-1.
[0034] It should be noted that while storing data in the corresponding hash bucket, the corresponding data tag can also be stored in the hash bucket. The data tag embeds the data location information of the corresponding data (such as geographical location, timestamp, user ID) to ensure that it can still be correctly aligned to the corresponding bucket after encryption.
[0035] The data items and labels stored in each hash bucket (Bucketi) are denoted as (Yi, Labeli), where Yi is the dataset in the bucket and Labeli is the corresponding label set.
[0036] In this embodiment, data is divided into multiple buckets using a hash function. Each bucket contains a certain number of data items and tags, enabling distributed bucketing, key binding, and tag alignment operations for tens of millions of data points, reducing the system's computational burden and query response latency. Compared to traditional solutions, this embodiment introduces a dynamic bucketing strategy based on query attributes (user identifiers) to achieve semantic mapping between data and bucket structures, thereby significantly improving the locality and hit rate of data access. Especially in environments with complex data dimensions, if a fixed bucketing strategy fails, the dynamic mapping mechanism can proactively reconstruct the bucket partitioning based on query characteristics, effectively improving query efficiency.
[0037] Optionally, please see further. Figure 2 After the initial bucketing, the method further includes: The number of data entries in each hash bucket is counted (count_i). If count_i < a preset threshold, the data is bucketed. If the number of data entries in a hash bucket exceeds the preset threshold, secondary hashing is initiated. A rebalancing mechanism is adopted, using another hash function H2(x) to redistribute the data in the hash bucket into b sub-buckets, i.e., b "secondary balanced buckets" (the allocation logic is the same as the allocation logic based on the first hash function). This dynamic adjustment is used to maintain the balance of data in each bucket and prevent bucket skew.
[0038] Optionally, in the offline setup phase, after allocating the N data items to their corresponding hash buckets based on the N bucket index values, the method further includes: Obtain the preset private key and the preset generators of Elliptic Curve Cryptography (ECC); Based on the preset private key, the preset generator, and the data stored in the first hash bucket, calculate the set of unintentional pseudo-random function outputs of the first hash bucket, where the first hash bucket is any one of the B hash buckets; Based on the output set of the unintentional pseudo-random function, a matching key and an encryption key corresponding to the first hash bucket are generated.
[0039] like Figure 3 As shown, after completing data bucketing, obtain the preset private key. And the predefined generator G of Elliptic Curve Cryptography (ECC). Extract data from the first hash bucket. Using a preset private key and generator, the output set of the Oblivious PseudoRandom Function (OPRF) of the first hash bucket is calculated. )= ,in, This indicates that the data in the hash bucket is processed using the first hash function. Calculate the hash value.
[0040] According to OPRF ( Generate matching key and encryption key The method can be: Based on OPRF ( ) and matching key Encryption key Relationship between OPRF ( )= ,in," " indicates concatenation, therefore, the OPRF is obtained ( After that, the matching key can be determined based on the preset string length. and encryption key For example, OPRF ( The key is 32 bytes long, and the first 16 bytes can be used as the matching key. The last 16 bytes are used as the encryption key. .
[0041] Among them, encryption key It can be used to encrypt tags, resulting in encrypted tags. The encrypted tags are stored in the corresponding hash buckets for online querying.
[0042] In this embodiment, for massive datasets of tens of billions of records, data bucketing preprocessing is performed offline. Innovatively, OPRF computation is strongly bound to the bucket structure. The OPRF for each bucket is calculated to generate the matching key and symmetric encryption key. Each computation is limited to a specific bucket domain, thus achieving bucket-level key generation and ciphertext response. This design not only improves computational parallelism but also effectively avoids the potential "horizontal full-table decoding" vulnerability that may occur in traditional schemes by limiting the decryptable range, thereby enhancing privacy protection under the principle of minimum data visibility.
[0043] Optionally, obtaining the query result based on the bucket index, query mask, and the hash bucket corresponding to the bucket index among the B hash buckets in the query request includes: Based on the bucket index, a second hash bucket is determined from the B hash buckets, and a first matching key corresponding to the second hash bucket is obtained from the second hash bucket. The number of the second hash bucket is the same as the value of the bucket index. Based on the data stored in the second hash bucket, an unintentional pseudo-random function is calculated on the query mask to obtain the mask-type unintentional pseudo-random function value.
[0044] In this embodiment, the bucket index is described as follows: The client calculates the bucket index Bx = H(x)% B of the target bucket using the second user identifier x of the target user and the first hash function. The bucket domain structure synchronized with the server is used to determine which data bucket the query request will be routed to, avoiding full table scans and improving query efficiency.
[0045] The query mask is explained as follows: A random number r (used for blind signature) and its inverse r-1 are generated, and a dynamic random factor r is introduced to achieve blinding processing, ensuring the anonymity of the query request. The hash value of H(x) and the query item is weighted using the random number r, and the query mask maskedX = r·H(x)·G is calculated. The masked query content maskedX and the bucket index Bx are then sent to the server. maskedX simultaneously serves as both a query mask and a protocol shared key negotiation mechanism. As a query mask, maskedX protects the user's identity (x) from being seen by the server. Compared to existing schemes based on ECDH or traditional blind signature technology, this embodiment proposes an implicit blind signature mechanism combining a bucket domain structure. maskedX not only serves as the encrypted form of the client's query item but also carries the shared key negotiation and signature binding functions based on elliptic curve cryptography during the blind signature process.
[0046] After determining the bucket index and query mask, the client sends the bucket index and query mask to the server, requesting routing within the bucket level. Combined with ECC security features, this enables anonymous queries without exposing the second user identifier x.
[0047] It should be noted that both the random number r and the aforementioned preset key β are randomly generated integer keys, designed to provide encryption protection for both the data sender and receiver. maskedX uses ECDH (Elliptic Curve Cryptography) blind signature technology (this scheme utilizes ECC to construct an implicit blind signature mechanism; the signature does not exist independently but is "embedded" into the computation process, eliminating the need for additional signature communication and saving interaction rounds), allowing two parties to generate a shared secret key without prior sharing of secret information, for subsequent symmetric encryption.
[0048] After receiving maskedX and bucket index Bx, the server first determines the second hash bucket from the B hash buckets based on the bucket index, and then obtains the first matching key matchKeysB and the first encrypted label set EncLabelsB corresponding to the second hash bucket from the second hash bucket. The number of the second hash bucket is the same as the value of the bucket index.
[0049] Based on maskedOPRF(X) = β×maskedX, the value of the masked unintentional pseudo-random function maskedOPRF(X) can be determined.
[0050] After the server calculates the query results, it sends them to the client.
[0051] In this embodiment, the client does not expose the user's identity. The server calculates and returns the query results without revealing the encryption key. The entire process balances privacy protection, data security, and query efficiency, making it suitable for data scales of millions or even hundreds of millions.
[0052] Optionally, after sending the query result to the client, the method further includes: Receive feedback results sent by the client; Wherein, when the second matching key and the first matching key are the same, the feedback result is used to indicate that the query result is correct. The second matching key and the first encryption key are both keys extracted from the privacy-inadvertent pseudo-random function value. The privacy-inadvertent pseudo-random function value is obtained by removing the mask of the masked uninadvertent pseudo-random function value. If the second matching key and the first matching key are not the same, the feedback result is used to indicate that the query result is incorrect.
[0053] In this embodiment, the client removes the mask OPRF(X) = • maskOPRF(X) to obtain OPRF(X), and extract the second matching key matchKeyx and the first encryption key aesKeyx from OPRF(X).
[0054] like Figure 4 The diagram shows the algorithm flow of the data query method in this embodiment. In the online stage, after removing the mask, the algorithm is based on OPRF(X) = matchKeyx. The query `aesKeyx` yields a second matching key `matchKeyx` and a first encryption key `aesKeyx`. The second matching key `matchKeyx` is compared with the first matching key `matchKeysB`. If they match, the first encryption key `aesKeyx` is used to decrypt the first encrypted tag set `EncLabelsB`, resulting in decrypted tags. The feedback result indicates that the query result is correct. From the decrypted tags, the tag corresponding to the second user identifier can be determined, thus retrieving the data corresponding to the second user identifier. If the second matching key `matchKeyx` and the first matching key `matchKeysB` are different, it indicates an error in the hash bucket being queried, and the first encryption key `aesKeyx` cannot decrypt the first encrypted tag set. The feedback result in this case indicates an error in the query result.
[0055] Compared with the prior art, the method of this application proposes a novel structured data encryption query mechanism in terms of the integrated design of bucketing mechanism, OPRF calculation and blind signature key generation process. It is an integrated innovation that addresses the pain points of operators in high-concurrency and strong privacy protection scenarios. It has clear technical breakthroughs and improved practical effects, ensuring efficient and secure operation of user data in the process of processing and querying tens of billions of large-scale data, and has broad market application prospects.
[0056] See Figure 5 , Figure 5 This is a flowchart illustrating a data query method applied to a client-side application, as provided in an embodiment of this application, including the following: Step 401: Send a query request to the server, the query request including the bucket index and the query mask; Step 402: Receive the query result sent by the server. The query result includes a masked unintentional pseudo-random function value, a first matching key, and a first encrypted tag set. The query result is obtained by querying B hash buckets based on the bucket index and the query mask. The first encrypted tag set is the encrypted tag of the hash bucket corresponding to the bucket index. The first matching key is the matching key in the hash bucket corresponding to the bucket index. The B hash buckets store N data items included in the original dataset, and each hash bucket stores at least one of the N data items and a data tag corresponding to the stored data. The data tag is used to indicate the storage location of the corresponding data in the hash bucket. The hash distance between data items stored in the same hash bucket is less than a preset distance. The B hash buckets correspond one-to-one with B key information items. The key information includes a matching key and an encryption key. The encryption key is used to encrypt the data tag to obtain an encrypted tag. B is an integer greater than 1, and N is an integer greater than or equal to B.
[0057] The method of this embodiment and Figure 1 The methods in the illustrated embodiments are identical and can achieve the same technical effects and solve the same technical problems, so they will not be described in detail here.
[0058] Optionally, after receiving the query result sent by the server, the method further includes: Remove the mask from the masked unintentional pseudo-random function value to obtain the privacy unintentional pseudo-random function value; Extract the second matching key and the first encryption key from the value of the privacy-inadvertent pseudo-random function; If the second matching key and the first matching key are the same, a feedback result indicating that the query result is correct is sent to the server; or, if the second matching key and the first matching key are different, a feedback result indicating that the query result is incorrect is sent to the server.
[0059] In this embodiment, based on OPRF(X) = matchKeyx The query `aesKeyx` yields a second matching key `matchKeyx` and a first encryption key `aesKeyx`. The second matching key `matchKeyx` is compared with the first matching key `matchKeysB`. If they match, the first encryption key `aesKeyx` is used to decrypt the first encrypted tag set `EncLabelsB`, resulting in decrypted tags. The feedback result indicates that the query result is correct. From the decrypted tags, the tag corresponding to the second user identifier can be determined, thus retrieving the data corresponding to the second user identifier. If the second matching key `matchKeyx` and the first matching key `matchKeysB` are different, it indicates an error in the hash bucket being queried, and the first encryption key `aesKeyx` cannot decrypt the first encrypted tag set. The feedback result in this case indicates an error in the query result.
[0060] Optionally, before sending a query request to the server, the method further includes: Obtain the client's second user identifier, a preset random number, and a preset generator, as well as the first hash function and the number of hash buckets B on the server; The second hash value is obtained by calculating the hash value of the second user identifier based on the first hash function; The second hash value is modulo B to obtain the bucket index; The query mask is calculated based on the second hash value, the preset random number, and the preset generator.
[0061] In this embodiment, the client calculates the second hash value H(x) using the first hash function based on the second user identifier x of the target user, and further calculates the bucket index Bx = H(x)% B. By adopting a bucket domain structure synchronized with the server, the client determines which data bucket the query request will be routed to, avoiding full table scans and improving query efficiency.
[0062] A random number r (used for blind signature of data) and its inverse r-1 are generated. A dynamic random factor r is introduced to achieve blinding processing and ensure the anonymity of the query request. The query mask maskedX = r·H(x)·G is calculated by weighting the hash values of H(x) and the query item using the random number r.
[0063] See Figure 6 , Figure 6 This is a structural diagram of a data query device provided in an embodiment of this application. For example... Figure 6 As shown, the device 600 includes: The first receiving module 601 is configured to respond to a query request sent by a client upon receiving the query request, and perform a query in B hash buckets based on the bucket index and query mask in the query request to obtain a query result. The B hash buckets store N data items included in the original dataset, and each hash bucket stores at least one of the N data items and a data tag corresponding to the stored data. The data tag is used to indicate the storage location of the corresponding data in the hash bucket. The hash distance between data items stored in the same hash bucket is less than a preset distance. The B hash buckets correspond one-to-one with B key information items. The key information includes a matching key and an encryption key. The encryption key is used to encrypt the data tag to obtain an encrypted tag. B is an integer greater than 1, and N is an integer greater than or equal to B. The query result includes a mask-style unintentional pseudo-random function value, a first matching key, and a first encrypted tag set. The first encrypted tag set consists of encrypted tags in the hash bucket corresponding to the bucket index, and the first matching key is the matching key in the hash bucket corresponding to the bucket index. The first sending module 602 is used to send the query result to the client.
[0064] Optionally, the device 600 also includes: The first calculation module is used to calculate the hash value of the first user identifier corresponding to the N data using the first hash function, so as to obtain N first hash values; The second calculation module is used to take the modulo of the N first hash values with B respectively to obtain N bucket index values that correspond one-to-one with the N data; The allocation module is used to allocate the N data to corresponding hash buckets based on the N bucket index values. The hash bucket number to which the first data is allocated is consistent with the bucket index value of the first data. The first data is any one of the N data. The hash buckets among the B hash buckets have different numbers.
[0065] Optionally, the device 600 also includes: The first acquisition module is used to acquire the preset private key and the preset generator of Elliptic Curve Cryptography (ECC). The third calculation module is used to calculate the set of unintentional pseudo-random function outputs of the first hash bucket based on the preset private key, the preset generator and the data stored in the first hash bucket, wherein the first hash bucket is any one of the B hash buckets; The first generation module is used to generate a matching key and an encryption key corresponding to the first hash bucket based on the output set of the unintentional pseudo-random function.
[0066] Optionally, obtaining the query result based on the bucket index, query mask, and the hash bucket corresponding to the bucket index among the B hash buckets in the query request includes: Based on the bucket index, a second hash bucket is determined from the B hash buckets, and a first matching key and a first encrypted tag set corresponding to the second hash bucket are obtained from the second hash bucket. The number of the second hash bucket is the same as the value of the bucket index. Based on the data stored in the second hash bucket, an unintentional pseudo-random function is calculated on the query mask to obtain the mask-type unintentional pseudo-random function value.
[0067] Optionally, the device 600 also includes: The third receiving module is used to receive the feedback result sent by the client; Wherein, when the second matching key and the first matching key are the same, the feedback result is used to indicate that the query result is correct. The second matching key and the first encryption key are both keys extracted from the privacy-inadvertent pseudo-random function value. The privacy-inadvertent pseudo-random function value is obtained by removing the mask of the masked uninadvertent pseudo-random function value. If the second matching key and the first matching key are not the same, the feedback result is used to indicate that the query result is incorrect.
[0068] The device in this embodiment can achieve... Figure 1 To avoid repetition, all steps of the method and the corresponding technical effects of the illustrated embodiment will not be described again.
[0069] like Figure 7 As shown, Figure 7 This is a structural diagram of a data query device provided in an embodiment of this application. For example... Figure 7 As shown, the device 700 includes: The second sending module 701 is used to send a query request to the server, the query request including a bucket index and a query mask; The second receiving module 702 is used to receive the query result sent by the server. The query result includes a masked unintentional pseudo-random function value, a first matching key, and a first encrypted tag set. The query result is obtained by querying B hash buckets based on the bucket index and the query mask. The first encrypted tag set is the encrypted tag of the hash bucket corresponding to the bucket index. The first matching key is the matching key in the hash bucket corresponding to the bucket index. The B hash buckets store N data items included in the original dataset. Each hash bucket stores at least one of the N data items and a data tag corresponding to the stored data. The data tag is used to indicate the storage location of the corresponding data in the hash bucket. The hash distance between data items stored in the same hash bucket is less than a preset distance. The B hash buckets correspond one-to-one with B key information items. The key information includes a matching key and an encryption key. The encryption key is used to encrypt the data tag to obtain an encrypted tag. B is an integer greater than 1, and N is an integer greater than or equal to B.
[0070] Optionally, the device 700 also includes: The mask removal module is used to remove the mask of the masked unintentional pseudo-random function value to obtain the privacy unintentional pseudo-random function value. The extraction module is used to extract the second matching key and the first encryption key from the privacy-inadvertent pseudo-random function value; The third sending module is configured to send a feedback result indicating that the query result is correct to the server when the second matching key and the first matching key are the same; or, when the second matching key and the first matching key are different, send a feedback result indicating that the query result is incorrect to the server.
[0071] Optionally, the device 700 also includes: The second acquisition module is used to acquire the client's second user identifier, a preset random number, and a preset generator, as well as to acquire the first hash function and the number of hash buckets B of the server; The fourth calculation module is used to calculate the hash value of the second user identifier based on the first hash function to obtain the second hash value; The fifth calculation module is used to take the second hash value modulo B to obtain the bucket index; The sixth calculation module is used to calculate the query mask based on the second hash value, the preset random number, and the preset generator.
[0072] The device in this embodiment can achieve... Figure 5 To avoid repetition, all steps of the method and the corresponding technical effects of the illustrated embodiment will not be described again.
[0073] This application also provides an electronic device. Since the principle by which the electronic device solves the problem is similar to the data query method in this application, the implementation of this electronic device can refer to the implementation of the data query method described above, and repeated details will not be repeated. Figure 8 As shown, the electronic device according to an embodiment of this application includes: a processor 800, configured to read a program from a memory 820 and execute the following processes: Upon receiving a query request from a client, the system responds to the query request by performing a query in B hash buckets based on the bucket index and query mask in the query request to obtain the query result. Each of the B hash buckets stores N data items from the original dataset, and each hash bucket stores at least one of the N data items and a corresponding data tag. The data tag indicates the storage location of the corresponding data within the hash bucket. The hash distance between data items stored in the same hash bucket is less than a preset distance. Each of the B hash buckets corresponds one-to-one with B key information items, including a matching key and an encryption key. The encryption key is used to encrypt the data tags to obtain encrypted tags. B is an integer greater than 1, and N is an integer greater than or equal to B. The query result includes a mask-style unintentional pseudo-random function value, a first matching key, and a first encrypted tag set. The first encrypted tag set consists of encrypted tags in the hash bucket corresponding to the bucket index, and the first matching key is the matching key in the hash bucket corresponding to the bucket index. The query results are sent to the client.
[0074] Among them, Figure 8 In this context, the bus architecture can include any number of interconnected buses and bridges, specifically linking various circuits together, represented by one or more processors (processor 800) and memory (memory 820). The bus architecture can also link various other circuits such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. The bus interface provides the interface. Processor 800 is responsible for managing the bus architecture and general processing, and memory 820 can store data used by processor 800 during operation.
[0075] Optionally, the processor 800 is configured to read the program from the memory 820 and execute the following processes: The hash value of the first user identifier corresponding to the N data is calculated using the first hash function to obtain N first hash values; Each of the N first hash values is modulo B to obtain N bucket index values that correspond one-to-one with the N data; Based on the N bucket index values, the N data are assigned to corresponding hash buckets. The hash bucket number to which the first data is assigned is consistent with the bucket index value of the first data. The first data is any one of the N data. The hash buckets among the B hash buckets have different numbers.
[0076] Optionally, the processor 800 is configured to read the program from the memory 820 and execute the following processes: Obtain the preset private key and the preset generators of Elliptic Curve Cryptography (ECC); Based on the preset private key, the preset generator, and the data stored in the first hash bucket, calculate the set of unintentional pseudo-random function outputs of the first hash bucket, where the first hash bucket is any one of the B hash buckets; Based on the output set of the unintentional pseudo-random function, a matching key and an encryption key corresponding to the first hash bucket are generated.
[0077] Optionally, the processor 800 is configured to read the program from the memory 820 and execute the following processes: Based on the bucket index, a second hash bucket is determined from the B hash buckets, and a first matching key and a first encrypted tag set corresponding to the second hash bucket are obtained from the second hash bucket. The number of the second hash bucket is the same as the value of the bucket index. Based on the data stored in the second hash bucket, an unintentional pseudo-random function is calculated on the query mask to obtain the mask-type unintentional pseudo-random function value.
[0078] Optionally, the processor 800 is configured to read the program from the memory 820 and execute the following processes: Receive feedback results sent by the client; Wherein, when the second matching key and the first matching key are the same, the feedback result is used to indicate that the query result is correct. The second matching key and the first encryption key are both keys extracted from the privacy-inadvertent pseudo-random function value. The privacy-inadvertent pseudo-random function value is obtained by removing the mask of the masked uninadvertent pseudo-random function value. If the second matching key and the first matching key are not the same, the feedback result is used to indicate that the query result is incorrect.
[0079] Optionally, the processor 800 is configured to read the program from the memory 820 and execute the following processes: Send a query request to the server, the query request including a bucket index and a query mask; The system receives a query result sent by the server. The query result includes a masked unintentional pseudo-random function value, a first matching key, and a first encrypted tag set. The query result is obtained by querying B hash buckets based on the bucket index and the query mask. The first encrypted tag set consists of encrypted tags of the hash bucket corresponding to the bucket index. The first matching key is the matching key in the hash bucket corresponding to the bucket index. The B hash buckets store N data items included in the original dataset. Each hash bucket stores at least one of the N data items and a data tag corresponding to the stored data. The data tag indicates the storage location of the corresponding data in the hash bucket. The hash distance between data items stored in the same hash bucket is less than a preset distance. The B hash buckets correspond one-to-one with B key information items. The key information includes a matching key and an encryption key. The encryption key is used to encrypt the data tags to obtain encrypted tags. B is an integer greater than 1, and N is an integer greater than or equal to B.
[0080] Optionally, the processor 800 is configured to read the program from the memory 820 and execute the following processes: Remove the mask from the masked unintentional pseudo-random function value to obtain the privacy unintentional pseudo-random function value; Extract the second matching key and the first encryption key from the value of the privacy-inadvertent pseudo-random function; If the second matching key and the first matching key are the same, a feedback result indicating that the query result is correct is sent to the server; or, if the second matching key and the first matching key are different, a feedback result indicating that the query result is incorrect is sent to the server.
[0081] Optionally, the processor 800 is configured to read the program from the memory 820 and execute the following processes: Obtain the client's second user identifier, a preset random number, and a preset generator, as well as the first hash function and the number of hash buckets B on the server; The second hash value is obtained by calculating the hash value of the second user identifier based on the first hash function; The second hash value is modulo B to obtain the bucket index; The query mask is calculated based on the second hash value, the preset random number, and the preset generator.
[0082] This application also provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the various processes of the above-described data query method embodiments and achieves the same technical effects. To avoid repetition, it will not be described again here. The computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc.
[0083] This application also provides a computer program product, including computer instructions. When executed by a processor, the computer instructions implement the various processes of the above-described data query method embodiments and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0084] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0085] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0086] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A data query method, applied to a server, characterized in that, The method includes: Upon receiving a query request from a client, the system responds to the query request by performing a query in B hash buckets based on the bucket index and query mask in the query request to obtain the query result. Each of the B hash buckets stores N data items from the original dataset, and each hash bucket stores at least one of the N data items and a corresponding data tag. The data tag indicates the storage location of the corresponding data within the hash bucket. The hash distance between data items stored in the same hash bucket is less than a preset distance. Each of the B hash buckets corresponds one-to-one with B key information items, including a matching key and an encryption key. The encryption key is used to encrypt the data tags to obtain encrypted tags. B is an integer greater than 1, and N is an integer greater than or equal to B. The query result includes a mask-style unintentional pseudo-random function value, a first matching key, and a first encrypted tag set. The first encrypted tag set consists of encrypted tags in the hash bucket corresponding to the bucket index, and the first matching key is the matching key in the hash bucket corresponding to the bucket index. The query results are sent to the client.
2. The method according to claim 1, characterized in that, Before receiving a query request from the client, the method further includes: The hash value of the first user identifier corresponding to the N data is calculated by the first hash function to obtain N first hash values; Each of the N first hash values is modulo B to obtain N bucket index values that correspond one-to-one with the N data; Based on the N bucket index values, the N data are assigned to corresponding hash buckets. The hash bucket number to which the first data is assigned is consistent with the bucket index value of the first data. The first data is any one of the N data. The hash buckets among the B hash buckets have different numbers.
3. The method according to claim 2, characterized in that, After allocating the N data items to their corresponding hash buckets based on the N bucket index values, the method further includes: Obtain the preset private key and the preset generators of Elliptic Curve Cryptography (ECC); Based on the preset private key, the preset generator, and the data stored in the first hash bucket, calculate the set of unintentional pseudo-random function outputs of the first hash bucket, where the first hash bucket is any one of the B hash buckets; Based on the output set of the unintentional pseudo-random function, a matching key and an encryption key corresponding to the first hash bucket are generated.
4. The method according to claim 2, characterized in that, The query result, obtained based on the bucket index, query mask, and the hash bucket corresponding to the bucket index among the B hash buckets in the query request, includes: Based on the bucket index, a second hash bucket is determined from the B hash buckets, and a first matching key and a first encrypted tag set corresponding to the second hash bucket are obtained from the second hash bucket. The number of the second hash bucket is the same as the value of the bucket index. Based on the data stored in the second hash bucket, an unintentional pseudo-random function is calculated on the query mask to obtain the mask-type unintentional pseudo-random function value.
5. The method according to any one of claims 1 to 4, characterized in that, After sending the query result to the client, the method further includes: Receive feedback results sent by the client; Wherein, when the second matching key and the first matching key are the same, the feedback result is used to indicate that the query result is correct. The second matching key and the first encryption key are both keys extracted from the privacy-inadvertent pseudo-random function value. The privacy-inadvertent pseudo-random function value is obtained by removing the mask of the masked uninadvertent pseudo-random function value. If the second matching key and the first matching key are not the same, the feedback result is used to indicate that the query result is incorrect.
6. A data query method, applied to a client, characterized in that, The method includes: Send a query request to the server, the query request including a bucket index and a query mask; The system receives a query result sent by the server. The query result includes a masked unintentional pseudo-random function value, a first matching key, and a first encrypted tag set. The query result is obtained by querying B hash buckets based on the bucket index and the query mask. The first encrypted tag set consists of encrypted tags of the hash bucket corresponding to the bucket index. The first matching key is the matching key in the hash bucket corresponding to the bucket index. The B hash buckets store N data items included in the original dataset. Each hash bucket stores at least one of the N data items and a data tag corresponding to the stored data. The data tag indicates the storage location of the corresponding data in the hash bucket. The hash distance between data items stored in the same hash bucket is less than a preset distance. The B hash buckets correspond one-to-one with B key information items. The key information includes a matching key and an encryption key. The encryption key is used to encrypt the data tags to obtain encrypted tags. B is an integer greater than 1, and N is an integer greater than or equal to B.
7. The method according to claim 6, characterized in that, After receiving the query result sent by the server, the method further includes: Remove the mask from the masked unintentional pseudo-random function value to obtain the privacy unintentional pseudo-random function value; Extract the second matching key and the first encryption key from the value of the privacy-inadvertent pseudo-random function; If the second matching key and the first matching key are the same, a feedback result indicating that the query result is correct is sent to the server; or, if the second matching key and the first matching key are different, a feedback result indicating that the query result is incorrect is sent to the server.
8. The method according to claim 6, characterized in that, Before sending a query request to the server, the method further includes: Obtain the client's second user identifier, a preset random number, and a preset generator, as well as the first hash function and the number of hash buckets B on the server; The second hash value is obtained by calculating the hash value of the second user identifier based on the first hash function; The second hash value is modulo B to obtain the bucket index; The query mask is calculated based on the second hash value, the preset random number, and the preset generator.
9. A data query device, applied to a server, characterized in that, The device includes: The first receiving module is configured to respond to a query request sent by a client upon receiving the query request, and perform a query in B hash buckets based on the bucket index and query mask in the query request to obtain a query result. The B hash buckets store N data items included in the original dataset, and each hash bucket stores at least one of the N data items and a data tag corresponding to the stored data. The data tag indicates the storage location of the corresponding data in the hash bucket. The hash distance between data items stored in the same hash bucket is less than a preset distance. The B hash buckets correspond one-to-one with B key information items. The key information includes a matching key and an encryption key. The encryption key is used to encrypt the data tags to obtain encrypted tags. B is an integer greater than 1, and N is an integer greater than or equal to B. The query result includes a mask-style unintentional pseudo-random function value, a first matching key, and a first encrypted tag set. The first encrypted tag set consists of encrypted tags in the hash bucket corresponding to the bucket index, and the first matching key is the matching key in the hash bucket corresponding to the bucket index. The first sending module is used to send the query result to the client.
10. A data query device, applied to a client, characterized in that, The device includes: The second sending module is used to send a query request to the server, the query request including a bucket index and a query mask; The second receiving module is used to receive the query result sent by the server. The query result includes a masked unintentional pseudo-random function value, a first matching key, and a first encrypted tag set. The query result is obtained by querying B hash buckets based on the bucket index and the query mask. The first encrypted tag set is the encrypted tag of the hash bucket corresponding to the bucket index. The first matching key is the matching key in the hash bucket corresponding to the bucket index. The B hash buckets store N data items included in the original dataset. Each hash bucket stores at least one of the N data items and a data tag corresponding to the stored data. The data tag is used to indicate the storage location of the corresponding data in the hash bucket. The hash distance between data items stored in the same hash bucket is less than a preset distance. The B hash buckets correspond one-to-one with B key information items. The key information includes a matching key and an encryption key. The encryption key is used to encrypt the data tag to obtain an encrypted tag. B is an integer greater than 1, and N is an integer greater than or equal to B.
11. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the data query method as described in any one of claims 1 to 8.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the data query method as described in any one of claims 1 to 8.
13. A computer program product, characterized in that, It includes computer instructions that, when executed by a processor, implement the steps of the data query method as described in any one of claims 1 to 8.