Data query method, device, equipment and medium

Through the combination of inadvertent pseudo-random functions, hash functions, key derivation functions and symmetric encryption algorithms, the problem of low data query efficiency caused by the complexity of fully homomorphic encryption algorithms is solved, and efficient and secure tracking queries are achieved.

CN116361344BActive Publication Date: 2024-09-06BEIJING VOLCANO ENGINE TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202310347782.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-03
Publication Date
2024-09-06
Estimated Expiration
2043-04-03

AI Technical Summary

Technical Problem

In the existing technology, the operation process of fully homomorphic encryption algorithm used for trace query is complicated, resulting in low efficiency of data query.

Method used

Using inadvertent pseudo-random functions, hash functions, key derivation functions and symmetric encryption algorithms, the client encrypts the query keywords and generates hash values ​​and keys, which are used to decrypt the ciphertext data packets returned by the server. Anonymous inquiry.

Benefits of technology

It improves the efficiency and security of data query, reduces data processing overhead, and avoids query information leakage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116361344B
    Figure CN116361344B
Patent Text Reader

Abstract

The present disclosure provides a data query method, device, equipment and medium, the method comprising: obtaining a first keyword to be queried; encrypting the first keyword based on an inadvertent pseudo-random function to obtain a first inadvertent pseudo-random function value corresponding to the first keyword; determining a first hash value of the first keyword based on the first inadvertent pseudo-random function value and a hash function, and determining a first key of the first keyword based on a key derivation function; decrypting a ciphertext data packet provided by a server based on the first hash value, the first key and a symmetric encryption algorithm to obtain a query result corresponding to the data query operation. The embodiments of the present disclosure are conducive to improving the efficiency of data query.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of data query, and in particular to a data query method, device, electronic device and storage medium. Background Art

[0002] Private Information Retrieval (PIR) refers to obtaining content corresponding to query conditions from the server without exposing the query conditions on the client side. In related technologies, fully homomorphic encryption algorithms are usually used. However, the operation process of fully homomorphic encryption algorithms is relatively complicated. For example, operations such as homomorphic encryption and homomorphic multiplication are required, which leads to low efficiency of data query based on fully homomorphic encryption. Summary of the invention

[0003] The embodiments of the present disclosure at least provide a data query method, device, electronic device, and storage medium, which can improve the efficiency of data query.

[0004] The present disclosure provides a data query method, the method comprising:

[0005] In response to the data query operation, obtaining a first keyword to be queried;

[0006] encrypting the first keyword based on the oblivious pseudo-random function to obtain a first oblivious pseudo-random function value corresponding to the first keyword;

[0007] Determine a first Hash value corresponding to the first keyword based on the first inadvertent pseudo-random function value and a preset Hash function, and determine a first key corresponding to the first keyword based on a key derivation function; there is a corresponding relationship between the first Hash value and the first key corresponding to the same first keyword;

[0008] Based on the first hash value, the first key and the symmetric encryption algorithm, the ciphertext data packet provided by the server is decrypted to obtain a query result corresponding to the data query operation; the ciphertext data packet is obtained by the server encrypting the data in the database based on the oblivious pseudo-random function, the hash function, the key derivation function and the symmetric encryption algorithm pre-agreed with the client.

[0009] In the disclosed embodiment, the first keyword to be queried by the client is encrypted by an inadvertent pseudo-random function, and a first hash value is generated based on a hash function, and a first key corresponding to the first keyword is determined by a key derivation function, and the ciphertext data packet returned by the server is also encrypted based on the above function, so that the client can decrypt the ciphertext data packet sent back by the server. Compared with the solution of realizing anonymous query based on complex homomorphic encryption algorithm in the related technology, anonymous query can be realized by the above functions, which can improve the efficiency of data query. In addition, the client encrypts the first keyword by an inadvertent pseudo-random function, so that the server cannot obtain any query information, which can improve the security of the query.

[0010] In a possible implementation, the ciphertext data packet includes a plurality of ciphertext data pairs, each ciphertext data pair includes a second hash value and ciphertext data corresponding to the second hash value, the second hash value is obtained by processing the data in the database based on the inadvertent pseudo-random function and the hash function; the ciphertext data packet provided by the server is decrypted based on the first hash value, the first key, and the symmetric encryption algorithm to obtain a query result corresponding to the data query operation, including:

[0011] For each ciphertext data pair, when the second hash value in the ciphertext data pair is the same as the first hash value, decrypt the ciphertext data corresponding to the second hash value based on the symmetric encryption algorithm and the first key corresponding to the first hash value to obtain plaintext data;

[0012] The plaintext data is used as a query result of the first keyword corresponding to the first Hash value to obtain a query result corresponding to the data query operation.

[0013] In the disclosed embodiment, for each ciphertext data pair, if the second hash value in the ciphertext data pair is the same as the first hash value, it means that the client has the first key that can decrypt the ciphertext data pair to obtain plaintext data. In this way, the specificity and accuracy of the decryption can be improved.

[0014] In a possible implementation, the format of the first inadvertent pseudo-random function value is a character string; and determining the first Hash value corresponding to the first keyword based on the first inadvertent pseudo-random function value and a preset Hash function includes:

[0015] Splitting the first inadvertent pseudo-random function value in a character string format corresponding to the first keyword into a first sub-function value and a second sub-function value according to a preset first split character length;

[0016] Based on the preset hash function, determine a sub-hash value corresponding to one of the first sub-function value and the second sub-function value, and determine the sub-hash value as a first hash value corresponding to the first keyword;

[0017] The determining, based on a key derivation function, a first key corresponding to the first keyword comprises:

[0018] Based on the key derivation function, a subkey corresponding to the other of the first sub-function value and the second sub-function value is determined, and the subkey is determined as a first key corresponding to the first keyword.

[0019] In the disclosed embodiment, the first inadvertent pseudo-random function value is split into a first sub-function value and a second sub-function value to determine the first hash value and the first key, thereby improving the diversity of determination methods.

[0020] In a possible implementation, determining the first key corresponding to the first keyword based on a key derivation function includes:

[0021] determining a first key corresponding to the first keyword based on the key derivation function and a first oblivious pseudo-random function value corresponding to the first keyword; or,

[0022] Based on the key derivation function and a first hash value corresponding to the first keyword, a first key corresponding to the first keyword is determined.

[0023] In the embodiment of the present disclosure, the first key may be determined based on the first inadvertent pseudo-random function value or the first Hash value, thereby increasing the diversity of the methods for determining the first key.

[0024] In a possible implementation manner, the format of the first Hash value is a character string; and determining the first key corresponding to the first keyword based on the key derivation function and the first Hash value corresponding to the first keyword includes:

[0025] Splitting the first hash value in a character string format corresponding to the first keyword into a first sub-hash value and a second sub-hash value according to a preset second splitting character length;

[0026] One of the first sub-hash value and the second sub-hash value is determined as the first hash value, and the first key is determined based on the key derivation function and the other of the first sub-hash value and the second sub-hash value.

[0027] In the disclosed embodiment, the first hash value may be split, and then the first hash value and the first key may be re-determined according to the sub-hash values ​​obtained by the splitting. In this way, the diversity of the methods for determining the first hash value and the first key may be improved.

[0028] In a possible implementation, the method further includes:

[0029] In a case where the first Hash value is different from each second Hash value, the query result of the first keyword corresponding to the first Hash value is determined to be a null value.

[0030] In the disclosed embodiment, if the first hash value is different from each second hash value, it means that the client does not have the corresponding first key to decrypt the ciphertext data corresponding to the second hash value. At this time, the query result of the first keyword corresponding to the first hash value can be assigned a null value. In this way, the integrity of the query result can be improved.

[0031] The present disclosure also provides a data query method, including:

[0032] Obtaining a second key corresponding to the oblivious pseudo-random function, and encrypting the data in the database based on the second key; wherein each data in the database is stored in the form of a key-value pair, each key-value pair includes a second keyword and a key value corresponding to the second keyword, and encrypting the data in the database based on the second key means encrypting the second keyword in each key-value pair to obtain a second oblivious pseudo-random function value corresponding to each second keyword;

[0033] For each second keyword, determine a second hash value corresponding to the second keyword based on the second inadvertent pseudo-random function value and a preset hash function, and determine a third key corresponding to the second keyword based on a key derivation function;

[0034] Based on a symmetric encryption algorithm and a third key corresponding to the second keyword, encrypt the key value corresponding to the second keyword to obtain ciphertext data corresponding to the second keyword; there is a second corresponding relationship between the ciphertext data corresponding to the same second keyword and the second Hash value;

[0035] Based on the second hash value corresponding to the second keyword and the ciphertext data corresponding to the second keyword, a ciphertext data pair is generated, and a ciphertext data packet is generated based on each ciphertext data pair, and the ciphertext data packet is sent to the client, so that the client decrypts the ciphertext data packet based on the hash function, the oblivious pseudo-random function, the key derivation function and the symmetric encryption algorithm pre-agreed with the server.

[0036] In the disclosed embodiment, each key-value pair is encrypted based on an inadvertent pseudo-random function, a hash function, a key derivation function, and a symmetric encryption algorithm. Compared with the homomorphic encryption algorithm in the related art, the data processing overhead can be reduced and the encryption efficiency can be improved. In addition, the server uses the above encryption method to encrypt the data in the database, so that the data returned by the server can only be decrypted by the first hash value and the first key in the client, and other data that cannot be decrypted will not be leaked, so that the security of the data can be improved.

[0037] The present disclosure provides a data query device, the device comprising:

[0038] An acquisition module, used for acquiring a first keyword to be queried in response to a data query operation;

[0039] an encryption module, configured to encrypt the first keyword based on an inadvertent pseudo-random function to obtain a first inadvertent pseudo-random function value corresponding to the first keyword;

[0040] a determination module, configured to determine a first Hash value corresponding to the first keyword based on the first inadvertent pseudo-random function value and a preset Hash function, and to determine a first key corresponding to the first keyword based on a key derivation function; there is a corresponding relationship between the first Hash value corresponding to the same first keyword and the first key;

[0041] A decryption module is used to decrypt the ciphertext data packet provided by the server based on the first hash value, the first key and the symmetric encryption algorithm to obtain a query result corresponding to the data query operation; the ciphertext data packet is obtained by the server encrypting the data in the database based on the oblivious pseudo-random function, the hash function, the key derivation function and the symmetric encryption algorithm pre-agreed with the client.

[0042] In a possible implementation, the ciphertext data packet includes a plurality of ciphertext data pairs, each ciphertext data pair includes a second Hash value and ciphertext data corresponding to the second Hash value, the second Hash value is obtained based on the inadvertent pseudo-random function and the Hash function to process the data in the database; the decryption module is specifically used to:

[0043] For each ciphertext data pair, when the second hash value in the ciphertext data pair is the same as the first hash value, decrypt the ciphertext data corresponding to the second hash value based on the symmetric encryption algorithm and the first key corresponding to the first hash value to obtain plaintext data;

[0044] The plaintext data is used as a query result of the first keyword corresponding to the first Hash value to obtain a query result corresponding to the data query operation.

[0045] In a possible implementation, the format of the first inadvertent pseudo-random function value is a character string; and the determination module is specifically configured to:

[0046] Splitting the first inadvertent pseudo-random function value in a character string format corresponding to the first keyword into a first sub-function value and a second sub-function value according to a preset first split character length;

[0047] Based on the preset hash function, determine a sub-hash value corresponding to one of the first sub-function value and the second sub-function value, and determine the sub-hash value as a first hash value corresponding to the first keyword;

[0048] The determining module is further specifically used for:

[0049] Based on the key derivation function, a subkey corresponding to the other of the first sub-function value and the second sub-function value is determined, and the subkey is determined as a first key corresponding to the first keyword.

[0050] In a possible implementation manner, the determining module is specifically configured to:

[0051] determining a first key corresponding to the first keyword based on the key derivation function and a first oblivious pseudo-random function value corresponding to the first keyword; or,

[0052] Based on the key derivation function and a first hash value corresponding to the first keyword, a first key corresponding to the first keyword is determined.

[0053] In a possible implementation manner, the format of the first Hash value is a character string; and the determining module is specifically configured to:

[0054] Splitting the first hash value in a character string format corresponding to the first keyword into a first sub-hash value and a second sub-hash value according to a preset second splitting character length;

[0055] One of the first sub-hash value and the second sub-hash value is determined as the first hash value, and the first key is determined based on the key derivation function and the other of the first sub-hash value and the second sub-hash value.

[0056] In a possible implementation manner, the determining module is further configured to:

[0057] In a case where the first Hash value is different from each second Hash value, the query result of the first keyword corresponding to the first Hash value is determined to be a null value.

[0058] The present disclosure provides a data query device, the device comprising:

[0059] A keyword encryption module, used for obtaining a second key corresponding to the oblivious pseudo-random function, and encrypting the data in the database based on the second key; wherein each data in the database is stored in the form of a key-value pair, each key-value pair includes a second keyword and a key value corresponding to the second keyword, and encrypting the data in the database based on the second key means encrypting the second keyword in each key-value pair to obtain a second oblivious pseudo-random function value corresponding to each second keyword;

[0060] a key determination module, configured to determine, for each second keyword, a second hash value corresponding to the second keyword based on the second inadvertent pseudo-random function value and a preset hash function, and determine a third key corresponding to the second keyword based on a key derivation function;

[0061] a key value encryption module, configured to encrypt the key value corresponding to the second keyword based on a symmetric encryption algorithm and a third key corresponding to the second keyword to obtain ciphertext data corresponding to the second keyword; a second corresponding relationship exists between the ciphertext data corresponding to the same second keyword and the second Hash value;

[0062] A ciphertext generation module is used to generate a ciphertext data pair based on the second hash value corresponding to the second keyword and the ciphertext data corresponding to the second keyword, and to generate a ciphertext data packet based on each ciphertext data pair, and to send the ciphertext data packet to the client, so that the client decrypts the ciphertext data packet based on the hash function, the oblivious pseudo-random function, the key derivation function and the symmetric encryption algorithm pre-agreed with the server.

[0063] An embodiment of the present disclosure also provides an electronic device, including: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the data query method described in any possible implementation manner described above are performed.

[0064] The embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the data query method described in any possible implementation manner described above are executed.

[0065] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0066] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.

[0067] Figure 1 A flow chart showing a data query method provided by some embodiments of the present disclosure is shown;

[0068] Figure 2 A flowchart of a method for decrypting a ciphertext data packet provided by some embodiments of the present disclosure is shown;

[0069] Figure 3 A flowchart showing a data query method provided by other embodiments of the present disclosure is shown;

[0070] Figure 4 A schematic diagram showing a data query device provided by some embodiments of the present disclosure is shown;

[0071] Figure 5 A schematic diagram showing a data query device provided by other embodiments of the present disclosure;

[0072] Figure 6 A schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0073] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.

[0074] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0075] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.

[0076] When performing data query, the client usually obtains data corresponding to the query conditions from the server based on some query conditions (such as keywords, etc.). If the client directly submits the query conditions to the server, the query conditions will be completely exposed to the server. Alternatively, if the server returns the query results directly to the client, the query results will also be completely leaked to the client.

[0077] Research has found that in order to solve the pain points of the above-mentioned data query, related technologies usually use fully homomorphic encryption algorithms for anonymous query. However, since the operation process of the fully homomorphic encryption algorithm is relatively complicated, it requires operations such as homomorphic encryption and homomorphic multiplication, which consumes a lot of data processing time, resulting in low data query efficiency.

[0078] Based on the above research, the present disclosure provides a data query method, device, equipment and storage medium. First, in response to the data query operation, a first keyword to be queried is obtained; secondly, the first keyword is encrypted based on an inadvertent pseudo-random function to obtain a first inadvertent pseudo-random function value corresponding to the first keyword; then, a first hash value corresponding to the first keyword is determined based on the first inadvertent pseudo-random function value and a preset hash function, and a first key corresponding to the first keyword is determined based on a key derivation function; there is a corresponding relationship between the first hash value and the first key corresponding to the same first keyword; finally, based on the first hash value, the first key and the symmetric encryption algorithm, a ciphertext data packet provided by the server is decrypted to obtain a query result corresponding to the data query operation; the ciphertext data packet is obtained by the server encrypting the data in the database based on the inadvertent pseudo-random function, the hash function, the key derivation function and the symmetric encryption algorithm pre-agreed with the client. In this way, the client can decrypt the ciphertext data packet sent back by the server. Compared with the scheme of realizing anonymous query based on a complex homomorphic encryption algorithm in the related art, anonymous query can be realized through the above functions, which can improve the efficiency of data query. In addition, the client encrypts the first keyword by an inadvertent pseudo-random function, so that the server cannot obtain any query information, which can improve the security of the query.

[0079] To facilitate understanding of this embodiment, the execution subject of the data query method provided by the embodiment of the present disclosure is first introduced in detail. The execution subject of the data query method provided by the embodiment of the present disclosure is an electronic device. In this embodiment, the electronic device may be a terminal device. Among them, the terminal device may be a mobile device, a user terminal, a handheld device, a computing device, a wearable device, etc. In addition, the data query method may also be implemented by a processor calling a computer-readable instruction stored in a memory.

[0080] The data query method provided by the embodiment of the present application is described in detail below with reference to the accompanying drawings. Figure 1 FIG. 1 is a flowchart of a data query method provided by an embodiment of the present disclosure, wherein the method includes steps S101 to S104, wherein:

[0081] S101, in response to a data query operation, obtaining a first keyword to be queried.

[0082] For example, a user can enter a query condition (i.e., the first keyword to be queried) in a preset data query interface and execute a data query operation (e.g., trigger a query button, etc.), so that the client can respond to the data query operation and obtain the first keyword to be queried. The number of the first keywords can be one or more, which is not limited here.

[0083] It should be noted that the format of the first keyword is not limited, for example, it can be numbers, letters or text, etc., which is not limited here.

[0084] In the disclosed embodiment, the data in the server database is in the form of key-value pairs. Therefore, when querying, the user can enter the corresponding first keyword (ie, the key value), so that the server returns the data corresponding to the first keyword (ie, the value).

[0085] S102, encrypting the first keyword based on an inadvertent pseudo-random function to obtain first inadvertent pseudo-random function values ​​corresponding to the first keyword.

[0086] Among them, the Obvious Pseudo-Random Function (OPRF) is a two-party protocol pre-agreed between the client and the server. The client and the server interact through the protocol to obtain the OPRF output. For the specific function expression, please refer to formula (1):

[0087]

[0088] Among them, the key of the inadvertent pseudo-random function f is k oprf , the input is x; the input of the server is k oprf , the output is a null value (*); the client input is x, the output is After the client and the server run the OPRF protocol, the server cannot obtain any information about the client's input x, and similarly, the client cannot obtain any information about k oprf any information.

[0089] For the client, the first keyword can be encrypted based on an inadvertent pseudo-random function to obtain an OPRF output, that is, the OPRF output is the OPRF value of its input value (that is, the first keyword). The OPRF function can be implemented based on the following formula (2):

[0090] OPRF(k oprf , x i )∈{0,1} k (2)

[0091] Among them, k oprf is the key of the random pseudo-random function, x i is the first keyword, that is, through the OPRF function, the first keyword can be encrypted into a character string with a length of k characters containing only 0 and 1.

[0092] It should be noted that although formula (2) has k oprf , but the client cannot obtain the key. This formula indicates the OPRF output used to describe the client.

[0093] In addition, the client and the server also agree on a collision-resistant hash function HF, a key derivation function KDF, and a symmetric encryption algorithm SE. The specific application of the above functions will be explained in the subsequent steps.

[0094] S103, determining a first hash value corresponding to the first keyword based on the first inadvertent pseudo-random function value and a preset hash function, and determining a first key corresponding to the first keyword based on a key derivation function; there is a corresponding relationship between the first hash value and the first key corresponding to the same first keyword.

[0095] Hash function (HF), also known as hash function, is a method of creating a small digital "fingerprint" from any data. It can compress a string into a string of preset length. In this way, querying based on the compressed string can improve the efficiency of data query. Common hash functions include SHA2, SHA3 and SM3. Hash function can be implemented based on the following formula (3):

[0096]

[0097] Among them, λ 1 is a preset character length, that is, the first random pseudo-random function value can be compressed into a character length of λ by the hash function. 1 The string.

[0098] A key derivation function (KDF) can derive one or more keys based on an inadvertent pseudo-random function. Commonly used key derivation functions include HKDF. The key derivation function can be implemented based on the following formula (4):

[0099]

[0100] Among them, λ 2 is the preset character length, that is, the key derivation function can generate a character length of λ 2 The first key.

[0101] Based on formula (3) and formula (4), it can be seen that when determining the first hash value corresponding to the first keyword based on a preset hash function, the first hash value corresponding to the first keyword can be determined based on the preset hash function and the OPRF value corresponding to the first keyword; when determining the first key corresponding to the first keyword based on a key derivation function, the first key corresponding to the first keyword can be determined based on the preset key derivation function and the OPRF value corresponding to the first keyword.

[0102] S104, decrypting the ciphertext data packet provided by the server based on the first hash value, the first key and the symmetric encryption algorithm to obtain a query result corresponding to the data query operation; the ciphertext data packet is obtained by encrypting the data in the database by the server based on the oblivious pseudo-random function, the hash function, the key derivation function and the symmetric encryption algorithm pre-agreed with the client.

[0103] Here, the ciphertext data packet provided by the server can be sent by the server to the client, or the client can send a data acquisition request to the server, and the server can send it to the client in response to the data acquisition request, which is not limited here. In this way, the client can decrypt the ciphertext data packet according to the first hash value and the first key determined in the above steps, so as to obtain the key value corresponding to the first keyword.

[0104] In the disclosed embodiment, the first keyword to be queried by the client is encrypted by an inadvertent pseudo-random function, and a first hash value is generated based on a hash function, and a key corresponding to the first keyword is determined by a key derivation function, and the ciphertext data packet returned by the server is also encrypted based on the above function, so that the client can decrypt the ciphertext data packet sent back by the server. Compared with the solution of realizing anonymous query based on complex homomorphic encryption algorithm in the related technology, anonymous query can be realized by the above functions, which can improve the efficiency of data query. In addition, the client encrypts the first keyword by an inadvertent pseudo-random function, so that the server cannot obtain any query information, which can improve the security of the query.

[0105] Optionally, since the format of the first oblivious pseudo-random function value is a string, when determining the first hash value corresponding to the first keyword based on a preset hash function, the first oblivious pseudo-random function value in the string format corresponding to the first keyword can be split into a first sub-function value and a second sub-function value according to a preset first splitting character length, and based on the preset hash function, a sub-hash value corresponding to one of the first sub-function value and the second sub-function value can be determined, and the sub-hash value can be determined as the first hash value corresponding to the first keyword, and when determining the first key corresponding to the first keyword based on a key derivation function, a sub-key corresponding to the other of the first sub-function value and the second sub-function value can be determined based on the key derivation function, and the sub-key can be determined as the first key corresponding to the first keyword.

[0106] Among them, the preset first split character length can be half of the character length of the first inadvertent pseudo-random function value. For example, if the character length of the first inadvertent pseudo-random function value is 256, the first 128 characters can be used as the first sub-function value, and the last 128 characters can be used as the second sub-function value, or the last 128 characters can be used as the first sub-function value, and the first 128 characters can be used as the second sub-function value, and the first sub-function value is determined as the first hash value. At the same time, based on the key derivation function, the sub-key corresponding to the second sub-function value is determined, and the sub-key is determined as the first key corresponding to the first keyword.

[0107] In some implementations, with respect to step S104, when determining the first key corresponding to the first keyword based on the key derivation function, the following two methods may be included:

[0108] The first method is: based on the key derivation function and the first inadvertent pseudo-random function value corresponding to the first keyword, determine the first key corresponding to the first keyword. For the specific determination method, please refer to the embodiment corresponding to formula (4), which will not be described here.

[0109] The second method is: based on the key derivation function and the first Hash value corresponding to the first keyword, determine the first key corresponding to the first keyword. It can be understood that since the first Hash value is also in a string format and the first Hash value is obtained by compressing the first random pseudo-random function value, the corresponding first key can be determined based on the first Hash value.

[0110] Optionally, when determining the first key corresponding to the first keyword based on the key derivation function and the first hash value corresponding to the first keyword, it includes: splitting the first hash value in a string format corresponding to the first keyword into a first sub-hash value and a second sub-hash value according to a preset second splitting character length, and then determining one of the first sub-hash value and the second sub-hash value as the first hash value, and determining the first key based on the key derivation function and the other of the first sub-hash value and the second sub-hash value.

[0111] Exemplarily, if the character length of the first hash value is 128 characters, the 128 characters can be split into a first sub-hash value and a second sub-hash value of 64 characters, and then one of the first sub-hash value and the second sub-hash value can be determined as the first hash value, and the first key can be determined based on the key derivation function and the other of the first sub-hash value and the second sub-hash value.

[0112] In the aforementioned embodiment, it is mentioned that the server sends the ciphertext data packet to the client, which may be sent upon receiving a data acquisition request sent by the client, or the server may actively send it, which is not limited here.

[0113] Next, with respect to step S104, when the ciphertext data packet provided by the server is decrypted based on the first hash value, the first key, and the symmetric encryption algorithm to obtain a query result corresponding to the data query operation, see Figure 2 , the method includes S1041-S1042:

[0114] S1041. For each ciphertext data pair, when the second hash value in the ciphertext data pair is the same as the first hash value, decrypt the ciphertext data corresponding to the second hash value based on a symmetric encryption algorithm and a first key corresponding to the first hash value to obtain plaintext data.

[0115] It can be understood that for each ciphertext data pair, if the second hash value in the ciphertext data pair is the same as the first hash value, that is, there is Can make Since the hash function is collision-resistant, that is, if This means that there exists x i So that x i = j , indicating that the client currently has a first key that can decrypt the ciphertext data corresponding to the second hash value For the specific decryption process, please refer to formula (8) and formula (9):

[0116]

[0117]

[0118] In this way, based on the first key Ciphertext data returned by the server Decrypt and get the ciphertext data The corresponding plaintext data.

[0119] In some implementations, for each ciphertext data pair, if the second hash value in the ciphertext data pair is different from the first hash value, it means that the client does not have the corresponding first key. The ciphertext data can be decrypted, and a query result of the first keyword corresponding to the first Hash value is determined to be a null value.

[0120] S1042: Use the plaintext data as a query result of the first keyword corresponding to the first Hash value to obtain a query result corresponding to the data query operation.

[0121] It can be understood that after obtaining the plaintext data, the plaintext data can be used as the query result of the first keyword corresponding to the first hash value, that is, the data (value) corresponding to the first keyword can be determined, and then the query result corresponding to the data query operation can be obtained.

[0122] Combine the following Figure 3 This paper introduces the data encryption process on the server side in detail.

[0123] See also Figure 3 , which is a flow chart of another data query method provided in an embodiment of the present disclosure. In this embodiment, the executor of the data query method is a server, which can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud storage, big data and artificial intelligence platforms.

[0124] like Figure 3 As shown, the data query method includes the following steps S301 to S304:

[0125] S301, obtaining a second key corresponding to an oblivious pseudo-random function, and encrypting data in a database based on the second key; wherein each data in the database is stored in the form of a key-value pair, each key-value pair includes a second keyword and a key value corresponding to the second keyword, and encrypting the data in the database based on the second key means encrypting the second keyword in each key-value pair to obtain a second oblivious pseudo-random function value corresponding to each second keyword.

[0126] Here, when the server and the client run the OPRF protocol at the same time, the server can obtain the key of the oblivious pseudo-random function (i.e., the second key), and then encrypt the plaintext data packet based on the second key. It should be noted that the second key is the key k of the oblivious pseudo-random function f involved in the above embodiment. oprf .

[0127] The data in the database is plain text data, and the plain text data is in the form of key-value pairs.

[0128] S302: For each second keyword, determine a second hash value corresponding to the second keyword based on the second inadvertent pseudo-random function value and a preset hash function, and determine a third key corresponding to the second keyword based on a key derivation function.

[0129] For example, the mathematical expression of each key-value pair can be Based on the preset random pseudo-random function, a second random pseudo-random function value corresponding to the second keyword in the key-value pair can be determined, and a second hash value corresponding to the second keyword can be determined based on the hash function. and determining a third key corresponding to the second keyword based on the key derivation function For specific formulas, please refer to formula (5) to formula (7):

[0130] OPRF(k oprf ,y j )∈{0,1} k (5)

[0131]

[0132]

[0133] Since the encryption functions (accidental pseudo-random function, hash function, key derivation function and symmetric encryption algorithm) used by the server and the client are the same, the specific encryption process can be found in the above embodiment and will not be described here.

[0134] In some embodiments, when determining the second hash value corresponding to the second keyword based on a preset hash function, and determining the third key corresponding to the second keyword based on a key derivation function, the second hash value and the third key can also be determined according to the character splitting method described in the above embodiments. The specific splitting process can be referred to the above embodiments and will not be repeated here.

[0135] S303, based on the symmetric encryption algorithm and the third key corresponding to the second keyword, encrypt the data corresponding to the second keyword to obtain the ciphertext data corresponding to the second keyword; there is a second corresponding relationship between the ciphertext data corresponding to the same second keyword and the second hash value.

[0136] Among them, the symmetric encryption algorithm (SE) consists of three algorithms: key generation, encryption and decryption. The key generation algorithm outputs a key k according to a specific distribution; when the key k and plaintext m are input, the encryption algorithm outputs the ciphertext c of the plaintext, abbreviated as c=SE.Enc(k,m); when the key k and ciphertext c are input, the decryption algorithm SE.Dec outputs the plaintext m corresponding to the ciphertext c ′ , abbreviated as m ′ =SE.Dec(k,c). Commonly used symmetric encryption algorithms include AES, Chacha20 and SM4.

[0137] For the specific symmetric encryption formula, please refer to formula (8):

[0138]

[0139] in, is a third key determined based on a key derivation function and each second keyword, are the data corresponding to each second keyword, It is the ciphertext data corresponding to each second keyword.

[0140] It should be noted that the server only encrypts the data through a symmetric encryption algorithm, and the decryption process is performed on the client.

[0141] In this implementation, the symmetric encryption algorithm supports encryption of data of any length, so data corresponding to the second keyword with a longer character length can also be encrypted, thereby reducing the restriction of encryption.

[0142] S304, generating a ciphertext data pair based on the second hash value corresponding to the second keyword and the ciphertext data corresponding to the second keyword, and generating a ciphertext data packet based on each ciphertext data pair, and sending the ciphertext data packet to the client, so that the client decrypts the ciphertext data packet based on the hash function, the oblivious pseudo-random function, the key derivation function and the symmetric encryption algorithm pre-agreed with the server.

[0143] It can be understood that after generating the ciphertext data corresponding to each second keyword, the ciphertext data pair can be generated based on each second hash value and the corresponding ciphertext data. A ciphertext data packet is generated and sent to the client, so that the client can decrypt the ciphertext data packet based on the first hash value, the first key and the symmetric encryption algorithm, and then determine the plaintext data matching the first keyword from the decrypted data.

[0144] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.

[0145] Based on the same inventive concept, a data query device corresponding to the data query method is also provided in the embodiment of the present disclosure. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned data query method in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0146] Reference Figure 4 FIG. 4 is a schematic diagram of a data query device 400 provided in an embodiment of the present disclosure, wherein the device includes:

[0147] The acquisition module 401 is used to acquire a first keyword to be queried in response to a data query operation;

[0148] An encryption module 402 is used to encrypt the first keyword based on an inadvertent pseudo-random function to obtain a first inadvertent pseudo-random function value corresponding to the first keyword;

[0149] A determination module 403, configured to determine a first Hash value corresponding to the first keyword based on the first inadvertent pseudo-random function value and a preset Hash function, and to determine a first key corresponding to the first keyword based on a key derivation function; there is a corresponding relationship between the first Hash value corresponding to the same first keyword and the first key;

[0150] The decryption module 404 is used to decrypt the ciphertext data packet provided by the server based on the first hash value, the first key and the symmetric encryption algorithm to obtain a query result corresponding to the data query operation; the ciphertext data packet is obtained by the server encrypting the data in the database based on the inadvertent pseudo-random function, the hash function, the key derivation function and the symmetric encryption algorithm pre-agreed with the client.

[0151] In a possible implementation, the ciphertext data packet includes a plurality of ciphertext data pairs, each ciphertext data pair includes a second hash value and ciphertext data corresponding to the second hash value, the second hash value is obtained based on the inadvertent pseudo-random function and the hash function to process the data in the database; the decryption module 404 is specifically used to:

[0152] When the second Hash value in the ciphertext data pair is the same as the first Hash value, decrypting the ciphertext data corresponding to the second Hash value based on the symmetric encryption algorithm and the first key corresponding to the first Hash value to obtain plaintext data;

[0153] The plaintext data is used as a query result of the first keyword corresponding to the first Hash value to obtain a query result corresponding to the data query operation.

[0154] In a possible implementation, the format of the first inadvertent pseudo-random function value is a character string; the determination module 403 is specifically configured to:

[0155] Splitting the first inadvertent pseudo-random function value in a character string format corresponding to the first keyword into a first sub-function value and a second sub-function value according to a preset first split character length;

[0156] Based on the preset hash function, determine a sub-hash value corresponding to one of the first sub-function value and the second sub-function value, and determine the sub-hash value as the first hash value corresponding to the first keyword;

[0157] The determining module 403 is further specifically configured to:

[0158] Based on the key derivation function, a subkey corresponding to the other of the first sub-function value and the second sub-function value is determined, and the subkey is determined as a first key corresponding to the first keyword.

[0159] In a possible implementation manner, the determining module 403 is specifically configured to:

[0160] determining a first key corresponding to the first keyword based on the key derivation function and a first oblivious pseudo-random function value corresponding to the first keyword; or,

[0161] Based on the key derivation function and a first hash value corresponding to the first keyword, a first key corresponding to the first keyword is determined.

[0162] In a possible implementation manner, the format of the first hash value is a string; and the determining module 403 is specifically configured to:

[0163] Splitting the first hash value in a character string format corresponding to the first keyword into a first sub-hash value and a second sub-hash value according to a preset second splitting character length;

[0164] One of the first sub-hash value and the second sub-hash value is determined as the first hash value, and the first key is determined based on the key derivation function and the other of the first sub-hash value and the second sub-hash value.

[0165] In a possible implementation manner, the determining module 403 is further configured to:

[0166] In a case where the first Hash value is different from each second Hash value, the query result of the first keyword corresponding to the first Hash value is determined to be a null value.

[0167] See also Figure 5 , is a schematic diagram of a data query device 500 provided in some other embodiments of the present disclosure, the device comprising:

[0168] The keyword encryption module 501 is used to obtain a second key corresponding to the oblivious pseudo-random function, and encrypt the data in the database based on the second key; wherein each data in the database is stored in the form of a key-value pair, each key-value pair includes a second keyword and a key value corresponding to the second keyword, and the encrypting the data in the database based on the second key means encrypting the second keyword in each key-value pair to obtain a second oblivious pseudo-random function value corresponding to each second keyword;

[0169] A key determination module 502, configured to determine, for each second keyword, a second hash value corresponding to the second keyword based on the second inadvertent pseudo-random function value and a preset hash function, and determine a third key corresponding to the second keyword based on a key derivation function;

[0170] A key value encryption module 503 is used to encrypt the key value corresponding to the second keyword based on a symmetric encryption algorithm and a third key corresponding to the second keyword to obtain ciphertext data corresponding to the second keyword; there is a second corresponding relationship between the ciphertext data corresponding to the same second keyword and the second Hash value;

[0171] The ciphertext generation module 504 is used to generate a ciphertext data pair based on the second hash value corresponding to the second keyword and the ciphertext data corresponding to the second keyword, and generate a ciphertext data packet based on each ciphertext data pair, and send the ciphertext data packet to the client, so that the client decrypts the ciphertext data packet based on the hash function, the oblivious pseudo-random function, the key derivation function and the symmetric encryption algorithm pre-agreed with the server.

[0172] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.

[0173] Based on the same technical concept, the embodiment of the present disclosure also provides an electronic device. Figure 6 , which is a schematic diagram of the structure of an electronic device 600 provided in an embodiment of the present disclosure, including a processor 601, a memory 602, and a bus 603. The memory 602 is used to store execution instructions, including a memory 6021 and an external memory 6022; the memory 6021 is also called an internal memory, which is used to temporarily store the operation data in the processor 601 and the data exchanged with the external memory 6022 such as a hard disk. The processor 601 exchanges data with the external memory 6022 through the memory 6021.

[0174] In the embodiment of the present application, the memory 602 is specifically used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 601. That is, when the electronic device 600 is running, the processor 601 communicates with the memory 602 through the bus 603, so that the processor 601 executes the application code stored in the memory 602, and then executes the method described in any of the above embodiments.

[0175] Among them, the memory 602 can be, but is not limited to, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), programmable read-only memory (Programmable Read-Only Memory, PROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable read-only memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.

[0176] Processor 601 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present invention may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0177] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 600. In other embodiments of the present application, the electronic device 600 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0178] The present disclosure also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the data query step in the above method embodiment is executed. The storage medium may be a volatile or non-volatile computer-readable storage medium.

[0179] The present disclosure also provides a computer program product that carries a program code. The program code includes instructions that can be used to execute the data query steps in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.

[0180] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).

[0181] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.

[0182] 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 solution of this embodiment.

[0183] In addition, each functional unit in each embodiment of the present disclosure 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.

[0184] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling an electronic 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 disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk or an optical disk.

[0185] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A data query method, characterized in that: include: In response to the data query operation, obtaining a first keyword to be queried; encrypting the first keyword based on an inadvertent pseudo-random function to obtain a first inadvertent pseudo-random function value corresponding to the first keyword; Determine a first Hash value corresponding to the first keyword based on the first inadvertent pseudo-random function value and a preset Hash function, and determine a first key corresponding to the first keyword based on a key derivation function; there is a corresponding relationship between the first Hash value and the first key corresponding to the same first keyword; Based on the comparison result of the first Hash value and the second Hash value, the ciphertext data packet provided by the server is decrypted using the first key and the symmetric encryption algorithm to obtain a query result corresponding to the data query operation; the ciphertext data packet is obtained by the server encrypting the data in the database based on the same oblivious pseudo-random function, the Hash function, the key derivation function and the symmetric encryption algorithm pre-agreed with the client; The ciphertext data packet includes a plurality of ciphertext data pairs, each ciphertext data pair includes a second Hash value and ciphertext data corresponding to the second Hash value, and the second Hash value is obtained by processing the data in the database based on the inadvertent pseudo-random function and the Hash function; The format of the first inadvertent pseudo-random function value is a character string; and determining the first Hash value corresponding to the first keyword based on the first inadvertent pseudo-random function value and a preset Hash function includes: According to a preset first split character length, splitting the first inadvertent pseudo-random function value in a character string format corresponding to the first keyword into a first sub-function value and a second sub-function value, and Based on the preset hash function, determine a sub-hash value corresponding to one of the first sub-function value and the second sub-function value, and determine the sub-hash value as a first hash value corresponding to the first keyword; The determining, based on a key derivation function, a first key corresponding to the first keyword comprises: Based on the key derivation function, a subkey corresponding to the other of the first sub-function value and the second sub-function value is determined, and the subkey is determined as a first key corresponding to the first keyword.

2. The method according to claim 1, characterized in that The decrypting the ciphertext data packet provided by the server using the first key and the symmetric encryption algorithm based on the comparison result of the first hash value and the second hash value includes: For each ciphertext data pair, when the second hash value in the ciphertext data pair is the same as the first hash value, decrypting the ciphertext data corresponding to the second hash value based on the symmetric encryption algorithm and the first key corresponding to the first hash value to obtain plaintext data; The plaintext data is used as a query result of the first keyword corresponding to the first Hash value to obtain a query result corresponding to the data query operation.

3. The method according to claim 1, characterized in that The determining, based on a key derivation function, a first key corresponding to the first keyword comprises: determining a first key corresponding to the first keyword based on the key derivation function and a first oblivious pseudo-random function value corresponding to the first keyword; or, Based on the key derivation function and a first hash value corresponding to the first keyword, a first key corresponding to the first keyword is determined.

4. The method according to claim 3, characterized in that The format of the first hash value is a string; The determining, based on the key derivation function and a first hash value corresponding to the first keyword, a first key corresponding to the first keyword includes: Splitting the first hash value in a character string format corresponding to the first keyword into a first sub-hash value and a second sub-hash value according to a preset second splitting character length; One of the first sub-hash value and the second sub-hash value is determined as the first hash value, and the first key is determined based on the key derivation function and the other of the first sub-hash value and the second sub-hash value.

5. The method according to claim 2, characterized in that: The method further comprises: In a case where the first Hash value is different from each second Hash value, the query result of the first keyword corresponding to the first Hash value is determined to be a null value.

6. A data query method, characterized in that: include: Obtaining a second key corresponding to the oblivious pseudo-random function, and encrypting the data in the database based on the second key; wherein each data in the database is stored in the form of a key-value pair, each key-value pair includes a second keyword and a key value corresponding to the second keyword, and encrypting the data in the database based on the second key means encrypting the second keyword in each key-value pair to obtain a second oblivious pseudo-random function value corresponding to each second keyword; For each second keyword, determine a second hash value corresponding to the second keyword based on the second inadvertent pseudo-random function value and a preset hash function, and determine a third key corresponding to the second keyword based on a key derivation function; Based on a symmetric encryption algorithm and a third key corresponding to the second keyword, encrypt the key value corresponding to the second keyword to obtain ciphertext data corresponding to the second keyword; there is a second corresponding relationship between the ciphertext data corresponding to the same second keyword and the second Hash value; Generate a ciphertext data pair based on the second hash value corresponding to the second keyword and the ciphertext data corresponding to the second keyword, generate a ciphertext data packet based on each ciphertext data pair, and send the ciphertext data packet to the client, so that the client decrypts the ciphertext data packet based on the hash function, the oblivious pseudo-random function, the key derivation function, and the symmetric encryption algorithm that are pre-agreed and identical with the server; The format of the second inadvertent pseudo-random function value is a character string; and determining the second Hash value corresponding to the second keyword based on the second inadvertent pseudo-random function value and a preset Hash function includes: According to a preset second split character length, split the second inadvertent pseudo-random function value in a character string format corresponding to the second keyword into a third sub-function value and a fourth sub-function value, and Based on the preset hash function, determine a sub-hash value corresponding to one of the third sub-function value and the fourth sub-function value, and determine the sub-hash value as a second hash value corresponding to the second keyword; The determining, based on a key derivation function, a third key corresponding to the second keyword comprises: Based on the key derivation function, a subkey corresponding to the other of the third sub-function value and the fourth sub-function value is determined, and the subkey is determined as a third key corresponding to the second keyword.

7. A data query device, characterized in that: The device comprises: An acquisition module, used for acquiring a first keyword to be queried in response to a data query operation; an encryption module, configured to perform encryption processing on the first keyword based on an inadvertent pseudo-random function to obtain a first inadvertent pseudo-random function value corresponding to the first keyword; a determination module, configured to determine a first Hash value corresponding to the first keyword based on the first inadvertent pseudo-random function value and a preset Hash function, and to determine a first key corresponding to the first keyword based on a key derivation function; there is a corresponding relationship between the first Hash value corresponding to the same first keyword and the first key; a decryption module, configured to decrypt the ciphertext data packet provided by the server using the first key and the symmetric encryption algorithm based on the comparison result of the first Hash value and the second Hash value, so as to obtain a query result corresponding to the data query operation; the ciphertext data packet is obtained by the server encrypting the data in the database based on the same oblivious pseudo-random function, the Hash function, the key derivation function and the symmetric encryption algorithm pre-agreed with the client; The ciphertext data packet includes a plurality of ciphertext data pairs, each ciphertext data pair includes a second Hash value and ciphertext data corresponding to the second Hash value, and the second Hash value is obtained by processing the data in the database based on the inadvertent pseudo-random function and the Hash function; The format of the first inadvertent pseudo-random function value is a character string; and determining the first Hash value corresponding to the first keyword based on the first inadvertent pseudo-random function value and a preset Hash function includes: According to a preset first split character length, splitting the first inadvertent pseudo-random function value in a character string format corresponding to the first keyword into a first sub-function value and a second sub-function value, and Based on the preset hash function, determine a sub-hash value corresponding to one of the first sub-function value and the second sub-function value, and determine the sub-hash value as a first hash value corresponding to the first keyword; The determining, based on a key derivation function, a first key corresponding to the first keyword comprises: Based on the key derivation function, a subkey corresponding to the other of the first sub-function value and the second sub-function value is determined, and the subkey is determined as a first key corresponding to the first keyword.

8. A data query device, characterized in that: The device comprises: A keyword encryption module, used for obtaining a second key corresponding to the oblivious pseudo-random function, and encrypting the data in the database based on the second key; wherein each data in the database is stored in the form of a key-value pair, each key-value pair includes a second keyword and a key value corresponding to the second keyword, and encrypting the data in the database based on the second key means encrypting the second keyword in each key-value pair to obtain a second oblivious pseudo-random function value corresponding to each second keyword; a key determination module, configured to determine, for each second keyword, a second hash value corresponding to the second keyword based on the second inadvertent pseudo-random function value and a preset hash function, and determine a third key corresponding to the second keyword based on a key derivation function; a key value encryption module, configured to encrypt the key value corresponding to the second keyword based on a symmetric encryption algorithm and a third key corresponding to the second keyword to obtain ciphertext data corresponding to the second keyword; a second corresponding relationship exists between the ciphertext data corresponding to the same second keyword and the second Hash value; a ciphertext generation module, configured to generate a ciphertext data pair based on the second hash value corresponding to the second keyword and the ciphertext data corresponding to the second keyword, and to generate a ciphertext data packet based on each ciphertext data pair, and to send the ciphertext data packet to the client, so that the client decrypts the ciphertext data packet based on the hash function, the oblivious pseudo-random function, the key derivation function, and the symmetric encryption algorithm pre-agreed with the server; The format of the second inadvertent pseudo-random function value is a character string; and determining the second Hash value corresponding to the second keyword based on the second inadvertent pseudo-random function value and a preset Hash function includes: According to a preset second split character length, split the second inadvertent pseudo-random function value in a character string format corresponding to the second keyword into a third sub-function value and a fourth sub-function value, and Based on the preset hash function, determine a sub-hash value corresponding to one of the third sub-function value and the fourth sub-function value, and determine the sub-hash value as a second hash value corresponding to the second keyword; The determining, based on a key derivation function, a third key corresponding to the second keyword comprises: Based on the key derivation function, a subkey corresponding to the other of the third sub-function value and the fourth sub-function value is determined, and the subkey is determined as a third key corresponding to the second keyword.

9. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable requests executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable request is executed by the processor, the steps of the data query method as described in any one of claims 1 to 6 are performed.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data query method according to any one of claims 1 to 6 are executed.

Citation Information

Cited By

  • Data query method and apparatus, device and medium

    EP4567624A1

  • Data query method and apparatus, device and medium

    WO2024208208A1