Data retrieval method, server, terminal, storage medium and computer program product
Through the binary search tree homomorphic search method, the problems of complex server preprocessing and large terminal computing overhead in the existing technology are solved, low-complexity and high-flexibility data retrieval is realized, and the traffic volume and computing requirements are reduced. In environments where data changes frequently.
Patent Information
- Application Number
- CN202410978429.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-19
- Publication Date
- 2024-11-19
AI Technical Summary
The existing private information retrieval schemes are difficult to achieve low complexity and high flexibility in data retrieval of data retrieval in server preprocessing, complex data update operations, large terminal computing overhead, and large communication volume of terminal queries to servers.
Using the binary search tree homomorphic search method, the target keywords are encrypted homomorphically, and the binary search tree stores keywords and data, and divides the binary structure to perform threshold ciphertext comparison, reducing the traffic volume and calculation complexity .
It realizes data retrieval with low complexity and high flexibility, reduces query transmission traffic between terminals and servers, is suitable for scenarios where data changes frequently, and reduces terminal computing and storage requirements.
Smart Images

Figure CN118981787A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of communication security technology, and in particular, to a data retrieval method, a server, a terminal, a storage medium, and a computer program product. Background Art
[0002] Publicly accessible databases are indispensable resources for retrieving the latest information, but they also pose a threat to user privacy. Database operators may track users' query behaviors out of curiosity or other purposes, and then infer users' intentions. Private information retrieval technology, also known as anonymous query, ensures that when users submit query requests to the server, the query is completed without leaking the query information.
[0003] Currently, common private information retrieval solutions are mainly implemented based on secure multi-party computing technologies such as oblivious transfer and homomorphic encryption. However, existing private information retrieval solutions often have problems such as complex server preprocessing calculations, complex data update operations, high terminal computing overhead, and high query transmission communication volume from the terminal to the server. Summary of the invention
[0004] The embodiments of the present application provide a data retrieval method, a server, a terminal, a storage medium and a computer program product, which realize data retrieval with low complexity and high flexibility and reduce the query transmission communication volume between the terminal and the server.
[0005] The technical solution of the embodiment of the present application is implemented as follows:
[0006] The present application provides a data retrieval method, which is applied to a server. The method includes:
[0007] A ciphertext pair sent by a receiving terminal; the ciphertext pair is a homomorphic encryption result of a target keyword;
[0008] Homomorphically searching for homomorphic ciphertexts corresponding to the ciphertext pair using a binary search tree; each node in the binary search tree stores a keyword and data corresponding to the keyword, and the homomorphic ciphertext is a homomorphic encryption result of the data corresponding to the target keyword;
[0009] The homomorphic ciphertext is sent to the terminal.
[0010] In the above method, before using the binary search tree to homomorphically retrieve the homomorphic ciphertext corresponding to the ciphertext pair, the method further includes:
[0011] Different keywords and their corresponding data are sorted according to the size of the keywords and stored in different nodes to construct the binary search tree.
[0012] In the above method, the step of using a binary search tree to homomorphically retrieve the homomorphic ciphertext corresponding to the ciphertext pair includes:
[0013] Divide each two adjacent layers of nodes in the binary search tree from top to bottom into a layer of binary structure, and obtain an L-layer binary structure; L is a positive integer, and the parent node in the next layer of binary structure is the child node of the parent node in the previous layer of binary structure;
[0014] Determine a threshold ciphertext of each layer of the L-layer binary structure, and a homomorphic comparison result between the threshold ciphertext of each layer of the binary structure and the ciphertext pair;
[0015] Based on the homomorphic comparison result between each layer of binary structure in the L-layer binary structure and the ciphertext pair, the homomorphic ciphertext is homomorphically extracted from the L-layer binary structure.
[0016] In the above method, determining the threshold ciphertext of each layer of the L-layer binary structure and the homomorphic comparison result between the threshold ciphertext of each layer of the binary structure and the ciphertext pair includes:
[0017] Homomorphically encrypting the keywords of each node different from the leaf node in the L-layer binary structure to obtain an initial ciphertext of the keyword;
[0018] Determine the initial ciphertext of the keyword of the parent node in the first-layer binary structure as the threshold ciphertext of the first-layer binary structure and compare it with the ciphertext pair homomorphically to obtain a homomorphic comparison result corresponding to the first-layer binary structure;
[0019] If L is greater than 1, obtain the current ciphertext of the keyword of each node in the first n-1 layers of the binary structure; n is a positive integer greater than 1 and less than or equal to L, and the current ciphertext of each keyword is the initial ciphertext or the updated ciphertext generated by updating the initial ciphertext;
[0020] Based on the current ciphertext of the keywords of each node in the first n-1 layers of binary structures and the homomorphic comparison results corresponding to each layer of binary structures in the first n-1 layers of binary structures, the threshold ciphertext of the nth layer of binary structures is determined;
[0021] The threshold ciphertext of the n-th layer binary structure is homomorphically compared with the ciphertext pair to obtain a homomorphic comparison result corresponding to the n-th layer binary structure.
[0022] In the above method, the step of obtaining the current ciphertext of the keyword of each node in the first n-1 layers of the binary structure includes:
[0023] If n-1 is equal to 1, the initial ciphertext of the keyword of each node in the first-layer binary structure is determined as the current ciphertext;
[0024] If n-1 is greater than 1, for the keywords of each node in the first n-1 layers of binary structure, if an updated ciphertext is generated when determining the threshold ciphertext of the n-1th layer of binary structure, the generated updated ciphertext is determined as the current ciphertext; if an updated ciphertext is not generated when determining the threshold ciphertext of the n-1th layer of binary structure, the initial ciphertext is determined as the current ciphertext.
[0025] In the above method, the current ciphertext of the keyword of each node in the first n-1 layers of binary structure and the homomorphic comparison results corresponding to each layer of binary structure in the first n-1 layers of binary structure are used to determine the threshold ciphertext of the nth layer of binary structure, including:
[0026] Based on the current ciphertext of the keyword of the parent node and its child nodes in the n-1-th layer binary structure, and the homomorphic comparison result corresponding to the n-1-th layer binary structure, update the current ciphertext of the keyword of the parent node in the n-1-th layer binary structure;
[0027] If n-1 is greater than 1, from the bottom to the top of the n-2-th binary structure, based on the updated ciphertext of the keyword in the parent node in the next binary structure, the current ciphertext of the keyword in the parent node in the previous binary structure, and the homomorphic comparison result corresponding to the previous binary structure, update the current ciphertext of the keyword in the parent node in the previous binary structure until the updated ciphertext of the keyword in the parent node in the first binary structure is obtained;
[0028] The updated ciphertext of the keyword in the parent node in the first-layer binary structure is determined as the threshold ciphertext of the n-th-layer binary structure.
[0029] In the above method, the step of homomorphically extracting the homomorphic ciphertext from the L-layer binary structure based on the homomorphic comparison result between each layer of the binary structure in the L-layer binary structure and the ciphertext pair includes:
[0030] Homomorphically encrypt the data of each node in the L-layer binary structure to obtain the initial ciphertext of the data;
[0031] Based on the initial ciphertext of the data of the parent node and its child nodes in the L-th layer binary structure and the homomorphic comparison result corresponding to the L-th layer binary structure, the initial ciphertext of the data of the parent node in the L-th layer binary structure is updated;
[0032] If L is greater than 1, from the Lth layer of binary structure, from bottom to top, based on the updated ciphertext of the data in the parent node in the next layer of binary structure, the current ciphertext of the data in the parent node in the previous layer of binary structure, and the homomorphic comparison result corresponding to the previous layer of binary structure, update the initial ciphertext of the data in the parent node in the previous layer of binary structure until the updated ciphertext of the data in the parent node in the first layer of binary structure is obtained;
[0033] The updated ciphertext of the data of the parent node in the first-layer binary structure is determined as the homomorphic ciphertext.
[0034] The present application provides a data retrieval method, which is applied to a terminal. The method includes:
[0035] Homomorphically encrypt the target keyword to obtain a ciphertext pair;
[0036] Sending the ciphertext pair to a server so that the server uses a binary search tree to homomorphically retrieve a homomorphic ciphertext corresponding to the ciphertext pair; each node in the binary search tree stores a keyword and data corresponding to the keyword, and the homomorphic ciphertext is a homomorphic encryption result of the data corresponding to the target keyword;
[0037] Receive the homomorphic ciphertext sent by the server.
[0038] In the above method, after receiving the homomorphic ciphertext sent by the server, the method includes:
[0039] The homomorphic ciphertext is decrypted to obtain data corresponding to the target keyword.
[0040] An embodiment of the present application provides a server, including: a first processor, a first memory, and a first communication bus;
[0041] The first communication bus is used to implement a communication connection between the first processor and the first memory;
[0042] The first processor is used to execute one or more computer programs stored in the first memory to implement a data retrieval method applied to a server.
[0043] An embodiment of the present application provides a terminal, including: a second processor, a second memory, and a second communication bus;
[0044] The second communication bus is used to implement a communication connection between the second processor and the second memory;
[0045] The second processor is used to execute one or more computer programs stored in the second memory to implement the data retrieval method applied to the terminal.
[0046] An embodiment of the present application 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 a data retrieval method applied to a server or the steps of a data retrieval method applied to a terminal are implemented.
[0047] An embodiment of the present application provides a computer program product, including a computer program, which, when executed, implements the steps of a data retrieval method applied to a server, or the steps of a data retrieval method applied to a terminal.
[0048] The embodiment of the present application provides a data retrieval method, a server, a terminal, a storage medium and a computer program product. The data retrieval method applied to the server includes: receiving a ciphertext pair sent by a terminal; the ciphertext pair is a homomorphic encryption result of a target keyword; using a binary search tree to homomorphically retrieve the homomorphic ciphertext corresponding to the ciphertext pair; each node in the binary search tree stores a keyword and the data corresponding to the keyword, and the homomorphic ciphertext is the homomorphic encryption result of the data corresponding to the target keyword; sending the homomorphic ciphertext to the terminal. The technical solution provided by the embodiment of the present application realizes data retrieval with low complexity and high flexibility, and reduces the query transmission communication volume between the terminal and the server. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 A schematic diagram of a data retrieval method provided in an embodiment of the present application Figure 1 ;
[0050] Figure 2 A schematic diagram of the structure of an exemplary binary search tree provided in an embodiment of the present application;
[0051] Figure 3 A schematic diagram of a data retrieval method provided in an embodiment of the present application Figure 2 ;
[0052] Figure 4 An exemplary data retrieval interaction diagram provided for an embodiment of the present application;
[0053] Figure 5 A schematic diagram of the structure of a server provided in an embodiment of the present application Figure 1 ;
[0054] Figure 6 A schematic diagram of the structure of a server provided in an embodiment of the present application Figure 2 ;
[0055] Figure 7 A schematic diagram of a terminal structure provided in an embodiment of the present application Figure 1 ;
[0056] Figure 8 A schematic diagram of a terminal structure provided in an embodiment of the present application Figure 2 . DETAILED DESCRIPTION
[0057] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0058] The following will specifically describe the technical solution of the present application and how the technical solution of the present application solves the above technical problems through embodiments and in conjunction with the accompanying drawings. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.
[0059] In addition, the technical solutions described in the embodiments of the present application can be combined arbitrarily without conflict.
[0060] An embodiment of the present application provides a data retrieval method applied to a server. Figure 1 A schematic diagram of a data retrieval method provided in an embodiment of the present application Figure 1 .like Figure 1 As shown, in the embodiment of the present application, the data retrieval method applied to the server mainly includes the following steps:
[0061] S101. Receive a ciphertext pair sent by a terminal; the ciphertext pair is a homomorphic encryption result of a target keyword.
[0062] In an embodiment of the present application, the server receives a ciphertext pair sent by a terminal, where the ciphertext pair is generated by homomorphic encryption of a target keyword by the terminal.
[0063] It should be noted that in the embodiments of the present application, the target keyword is the search object, and its corresponding data needs to be retrieved. The specific target keyword can be selected according to actual needs and application scenarios, and the embodiments of the present application are not limited.
[0064] In the embodiments of the present application, k is used * ∈Z N Indicates a numerical target keyword (to ensure efficient solution calculation, it is recommended that N does not exceed 2 16 ). Terminal pair k * After encoding, homomorphic encryption based on the Ring Error Learning Problem (RLWE) algorithm is performed to obtain the ciphertext pair (ck1, ck2). The server can receive the ciphertext pair sent by the terminal. Ciphertext pair As shown in the following formula (1) and formula (2):
[0065]
[0066] Where N represents the dimension of the ring in the RLWE algorithm, and X represents the polynomial on the ring.
[0067] It should be noted that, in the embodiments of the present application, the algorithm for homomorphic encryption of the target keyword may not only be the above RLWE algorithm, but also other homomorphic encryption algorithms, such as the Brakerski-Gentry-Vaikuntanathan (abbreviated as BGV) algorithm, the Brakerski-Fan-Vercauteren (abbreviated as BFV) algorithm, the Cheon-Kim-Kim-Song (abbreviated as CKKS) algorithm, etc. The embodiments of the present application do not make any limitations.
[0068] S102. Use a binary search tree to homomorphically retrieve the corresponding homomorphic ciphertext for the ciphertext pair; each node in the binary search tree stores a keyword and the data corresponding to the keyword, and the homomorphic ciphertext is the homomorphic encryption result of the data corresponding to the target keyword.
[0069] In the embodiments of the present application, after receiving the ciphertext pair, the server uses a binary search tree to homomorphically retrieve the corresponding homomorphic ciphertext for the ciphertext pair.
[0070] In the embodiments of the present application, the server needs to first construct a binary search tree for homomorphically retrieving the corresponding homomorphic ciphertext for the ciphertext pair. Based on this, the server can also perform the following steps: sort different keywords and their corresponding data according to the size of the keywords and store them in different nodes to construct a binary search tree.
[0071] It should be noted that, in the embodiments of the present application, the keyword can be a numerical keyword, that is, the keyword is represented in numerical form. Based on this, the server can sort all the keywords from largest to smallest or from smallest to largest, and then determine the positions of the nodes where each keyword and its corresponding data are to be stored according to the size relationship between the keywords for storage based on the binary search tree.
[0072] It should be noted that, in the embodiments of the present application, refer to Figure 2 , different keywords k1, k2, k3, etc. in the binary search tree, and the data v1, v2, v3, etc. corresponding to the keywords k1, k2, k3 are stored in sorted order according to the keyword size. The data is stored in the form of key-value pairs in the node, satisfying k2 < k1 < k3, k4 < k2 < k5, k6 < k3 < k7, and so on.
[0073] In an embodiment of the present application, a server uses a binary search tree to homomorphically retrieve homomorphic ciphertexts corresponding to a ciphertext pair, including: dividing each two adjacent layers of nodes in the binary search tree from top to bottom into a layer of binary structure to obtain an L-layer binary structure; L is a positive integer, and the parent node in the next layer of binary structure is the child node of the parent node in the previous layer of binary structure; determining the threshold ciphertext of each layer of binary structure in the L-layer binary structure, and the homomorphic comparison result between the threshold ciphertext of each layer of binary structure and the ciphertext pair; based on the homomorphic comparison result between each layer of binary structure in the L-layer binary structure and the ciphertext pair, homomorphically extracting the homomorphic ciphertext from the L-layer binary structure.
[0074] It should be noted that in the embodiment of the present application, data is stored in a binary search tree structure, and the server can divide it into layers of binary structures, see Figure 2 The binary search tree shown in the figure, the server can divide the binary search tree from top to bottom into a layer of binary structure for every two adjacent layers of nodes. Assuming a total of L layers of binary structure, based on this, the node storage in the binary search tree can be expressed as k i For keywords, v i k i The corresponding data (single k i Can correspond to multiple ordered data v i,1 ,v i,2 ,…), satisfying k 2i <k i <k 2i+1 , and supports plaintext or homomorphic ciphertext storage.
[0075] It should be noted that, in the embodiment of the present application, for the divided L-layer binary structure, since there is a common layer of nodes between two adjacent layers of binary structures, the parent node in the next layer of binary structure is the child node of the parent node in the previous layer of binary structure. For example, see Figure 2 , the node storing k2,v2 in the second-layer binary structure is a parent node in the second-layer binary structure, and this node is a child node of the parent node storing k1,v1 in the first-layer binary structure.
[0076] In an embodiment of the present application, after dividing the L-layer binary structure, the server can determine the threshold ciphertext of each layer of the L-layer binary structure, as well as the homomorphic comparison result between the threshold ciphertext of each layer of the binary structure and the ciphertext pair.
[0077] It should be noted that, in the embodiment of the present application, the threshold values of the L-layer binary structure are t1, t2, ..., t L , the threshold ciphertexts are ct1, ct2, ..., ct L , where the method for determining each threshold ciphertext is detailed in the following text.
[0078] It should be noted that in the embodiment of the present application, the server converts the threshold ciphertext of each layer of the binary structure into the ciphertext pair according to formula (3) and formula (4). Perform a homomorphic comparison and obtain the corresponding homomorphic comparison result:
[0079]
[0080] where l∈[1,…,L], and The output is the RLWE ciphertext, assuming that its corresponding plaintext is the polynomial m i,l (X), then the ciphertext extraction algorithm Ext is used to extract the constant term m i,l (0) is converted into the LWE ciphertext using the key switching algorithm KS. i,l (0) RLWE ciphertext.
[0081] It should be noted that in the embodiments of the present application, in formula (3) and formula (4) and They represent homomorphic multiplication and homomorphic addition operations in a dense state, respectively, and should satisfy the following properties of multiplication homomorphism and addition homomorphism:
[0082]
[0083] Wherein, Dec represents the decryption algorithm, and m1 and m2 represent two operation objects.
[0084] It should be noted that, in the embodiments of the present application, in combination with the above formulas, the homomorphic multiplication calculation of formula (3) can be written as:
[0085]
[0086] When k * ≤t l When ≤N-1, The constant term is 1, otherwise it is 0. Similarly, the homomorphic multiplication calculation of formula (4) can be written as:
[0087]
[0088] When 0≤t l ≤k * hour, The constant term is 1, otherwise it is 0. Therefore, for the hidden comparison result
[0089] x l :=Dec(cx l ) (9)
[0090] y l :=Dec(cy l ) (10)
[0091] satisfy:
[0092]
[0093] It should be noted that in the embodiment of the present application, after determining the homomorphic comparison result between the l-th layer binary structure and the ciphertext pair, the server determines whether the homomorphic comparison of all layers of binary structures has been completed, that is, whether l is equal to L. If not completed, set l=l+1 and continue to perform the homomorphic comparison between the threshold ciphertext of the next layer of binary structure and the ciphertext pair.
[0094] The following details the threshold ciphertexts ct1, ct2, ..., ct involved in the homomorphic comparison. L The method of determination.
[0095] In an embodiment of the present application, the server determines the threshold ciphertext of each layer of the binary structure in the L-layer binary structure, and the homomorphic comparison result between the threshold ciphertext of each layer of the binary structure and the ciphertext pair, including: homomorphically encrypting the keywords of each node different from the leaf node in the L-layer binary structure to obtain the initial ciphertext of the keyword; determining the initial ciphertext of the keyword of the parent node in the first-layer binary structure as the threshold ciphertext of the first-layer binary structure and homomorphically comparing it with the ciphertext pair to obtain the homomorphic comparison result corresponding to the first-layer binary structure; if L is greater than 1, obtain the first n -1 layers of binary structures; n is a positive integer greater than 1 and less than or equal to L, and the current ciphertext of each keyword is the initial ciphertext or the updated ciphertext generated by updating the initial ciphertext; based on the current ciphertext of the keyword of each node in the first n-1 layers of binary structures and the homomorphic comparison results corresponding to each layer of binary structures in the first n-1 layers of binary structures, the threshold ciphertext of the n-th layer of binary structures is determined; the threshold ciphertext of the n-th layer of binary structures is homomorphically compared with the ciphertext pair to obtain the homomorphic comparison result corresponding to the n-th layer of binary structures.
[0096] It should be noted that in the embodiment of the present application, the server performs homomorphic encryption on the keywords of each node different from the leaf node in the L-layer binary structure. Specifically, when there is no need to keep the keywords confidential, the trivial homomorphic encryption algorithm RLWE can be used. * Perform homomorphic encryption to obtain the initial ciphertext, as shown in the following formula (12):
[0097]
[0098] in, Keywords Their respective initial ciphertexts.
[0099] It should be noted that in the embodiment of the present application, in the first-layer binary structure, there is only one parent node, see Figure 2, that is, the node storing (k1, v1), the threshold ciphertext ct1 of the first-layer binary structure, that is, the initial ciphertext ck1 of k1 generated according to the above formula (12), that is, ct1=ck1.
[0100] In the embodiment of the present application, if L is greater than 1, that is, the binary structure has multiple layers, in this case, for any binary structure from the 2nd to the Lth binary structure, that is, the threshold ciphertext ct of the nth binary structure n , it is necessary to determine the threshold ciphertext of the n-th layer of binary structure based on the current ciphertext of the keywords of each node in the first n-1 layers of binary structure and the homomorphic comparison results corresponding to each layer of binary structure in the first n-1 layers of binary structure, specifically including: updating the current ciphertext of the keyword of the parent node in the n-1 layer of binary structure based on the current ciphertext of the keywords of the parent node and its child nodes in the n-1 layer of binary structure and the homomorphic comparison results corresponding to the n-1 layer of binary structure; if n-1 is greater than 1, from the bottom to the top of the n-2 layer of binary structure, based on the updated ciphertext of the keyword in the parent node in the next layer of binary structure, the current ciphertext of the keyword of the parent node in the previous layer of binary structure, and the homomorphic comparison results corresponding to the previous layer of binary structure, update the current ciphertext of the keyword of the parent node in the previous layer of binary structure until the updated ciphertext of the keyword in the parent node in the first layer of binary structure is obtained; and determining the updated ciphertext of the keyword in the parent node in the first layer of binary structure as the threshold ciphertext of the n-th layer of binary structure.
[0101] It should be noted that, in the embodiment of the present application, the threshold ciphertext ct of the binary structure of the nth layer is calculated. n This step extracts the keyword ciphertext in the path as the threshold ciphertext without exposing the binary tree search path. The specific operation is as follows:
[0102] Let p = n-1, q = 2 n-2 .
[0103] Using cx p andcy p Update ck q ,…,ck 2q-1 , where ck q ,…,ck 2q-1 Indicates k q ,…,k 2q-1 Current ciphertext: For n≤u≤2n-1, calculate:
[0104] ck u ←THS(ck 2u ,ck u ,ck 2u+1 ,cx p ,cy p )(13)
[0105] Here, the threshold value calculation algorithm THS is based on cx p andcy p The corresponding plaintext value homomorphically selects ck 2u ,ck u ,ck 2u+1 One of the corresponding plaintext values is set as follows:
[0106]
[0107] Specifically,
[0108]
[0109] Determine whether the current ciphertext of all keywords has been updated, that is, determine whether q is equal to 1. If not, set p = p-1, q = q / 2, and continue to update the keyword ciphertext; if completed, the updated ciphertext of k1 stored in the parent node of the first-level binary structure can be determined as ct n .
[0110] It should be noted that, in the embodiments of the present application, referring to the above-mentioned determination of the threshold ciphertext of the n-th layer binary structure, for the L-layer binary structure, the threshold ciphertext of each layer of the binary structure is determined from top to bottom. For the first-layer binary structure, the initial ciphertext of the parent node keyword is directly determined as the threshold ciphertext. When determining the threshold ciphertext of each layer of the binary structure from the second to the L-th layer binary structure, it involves updating the keyword ciphertext. When determining the threshold ciphertext of the n-th layer binary structure, it is necessary to use the current ciphertext of the keyword of each node in the first n layers of the binary structure, that is, it is necessary to consider the ciphertext update of the keyword in the process of determining the threshold ciphertext of the n-1-th layer binary structure.
[0111] It can be understood that in the embodiments of the present application, based on the above reasons, regarding the current ciphertext of the keywords of each node in the first n-1 layers of binary structure involved in the process of determining the threshold ciphertext of the n-th layer of binary structure, if n-1 is equal to 1, that is, at this time, to determine the threshold ciphertext of the second layer of binary structure, it is necessary to obtain the current ciphertext of the keywords of each node in the first layer. As mentioned above, when determining the threshold ciphertext of the first layer of binary structure, the initial ciphertext of the keyword of the parent node is directly used as the threshold ciphertext, and no ciphertext update is involved. Therefore, the initial ciphertext of the keyword of each node in the first layer is determined as the current ciphertext; if n-1 is greater than 1, for the keywords of each node in the first n-1 layers of binary structure, if an updated ciphertext is generated when determining the threshold ciphertext of the n-2th layer of binary structure, the generated updated ciphertext is determined as the current ciphertext, and if no updated ciphertext is generated when determining the threshold ciphertext of the n-2th layer of binary structure, the initial ciphertext is determined as the current ciphertext.
[0112] In an embodiment of the present application, after the server obtains the threshold ciphertext of each layer of the binary structure based on the above method and determines the homomorphic comparison result between the ciphertext pair, it can homomorphically extract the homomorphic ciphertext from the L-layer binary structure based on this.
[0113] In an embodiment of the present application, the server homomorphically extracts homomorphic ciphertext from the L-layer binary structure based on the homomorphic comparison results between each layer of binary structure and the ciphertext pair in the L-layer binary structure, including: homomorphically encrypting the data of each node in the L-layer binary structure to obtain the initial ciphertext of the data; updating the initial ciphertext of the data of the parent node in the L-th layer binary structure based on the initial ciphertext of the data of the parent node and its child nodes in the L-th layer binary structure, and the homomorphic comparison results corresponding to the L-th layer binary structure; if L is greater than 1, from the L-th layer binary structure from bottom to top, based on the updated ciphertext of the data in the parent node in the next layer binary structure, the current ciphertext of the data of the parent node in the previous layer binary structure, and the homomorphic comparison results corresponding to the previous layer binary structure, update the initial ciphertext of the data of the parent node in the previous layer binary structure, until the updated ciphertext of the data of the parent node in the first layer binary structure is obtained; the updated ciphertext of the data of the parent node in the first layer binary structure is determined as the homomorphic ciphertext.
[0114] It should be noted that in the embodiment of the present application, the server performs homomorphic encryption on the data of each node in the L-layer binary structure, that is, the data corresponding to the keyword. Specifically, when there is no need to keep the data confidential, the trivial homomorphic encryption algorithm RLWE can be used. * Perform homomorphic encryption to obtain the initial ciphertext, as shown in the following formula (16):
[0115]
[0116] in, Data Their respective initial ciphertexts.
[0117] It should be noted that, in the embodiment of the present application, the step of homomorphically extracting the homomorphic ciphertext cv according to the homomorphic comparison result is similar to the above-mentioned method of updating the keyword ciphertext, and the specific operation is as follows:
[0118] Let p = L, q = 2 L-1 ;
[0119] Using cx p andcy p Update cv q ,…,cv 2q-1 : For q≤u≤2q-1, calculate:
[0120] cv u ←THS(cv 2u ,cv u ,cv2u+1 ,cx p ,cy p )(17)
[0121] Determine whether the initial ciphertext of all data has been updated, that is, determine whether q is equal to 1. If not, set p = p-1, q = q / 2, and continue to update the data ciphertext; if completed, the updated ciphertext of v1 stored in the parent node in the first-layer binary structure is the homomorphic ciphertext cv.
[0122] S103. Send the homomorphic ciphertext to the terminal.
[0123] In an embodiment of the present application, after obtaining the homomorphic ciphertext, the server can send the homomorphic ciphertext to the terminal for the terminal to decrypt and obtain the data corresponding to the target keyword.
[0124] An embodiment of the present application provides a data retrieval method, which is applied to a terminal. Figure 3 A schematic diagram of a data retrieval method provided in an embodiment of the present application Figure 2 .like Figure 3 As shown, in an embodiment of the present application, the data retrieval method applied to the terminal mainly includes the following steps:
[0125] S201, homomorphically encrypt the target keyword to obtain a ciphertext pair;
[0126] S202, sending the ciphertext pair to the server, so that the server uses a binary search tree to homomorphically retrieve the homomorphic ciphertext corresponding to the ciphertext pair; each node in the binary search tree stores a keyword and data corresponding to the keyword, and the homomorphic ciphertext is a homomorphic encryption result of the data corresponding to the target keyword;
[0127] S203. Receive the homomorphic ciphertext sent by the server.
[0128] It should be noted that, in the embodiment of the present application, the process of homomorphic encryption of the target keyword by the terminal is described in the above formula (1) and formula (2) and will not be repeated here.
[0129] In an embodiment of the present application, after the terminal receives the homomorphic ciphertext sent by the server, the following steps may be performed: decrypting the homomorphic ciphertext to obtain data corresponding to the target keyword, as shown in the following formula (18):
[0130] v * ←Dec(cv)(18)
[0131] Among them, cv represents homomorphic ciphertext, v * The target keyword k * The corresponding data.
[0132] Combined with the above server-side and terminal-side method steps, see Figure 4 , the data retrieval method provided in this application mainly involves the following contents:
[0133] 1. The terminal homomorphically encrypts the target keyword, obtains the ciphertext pair and sends it to the server;
[0134] 2. The server uses the binary search tree to homomorphically retrieve the homomorphic ciphertext corresponding to the ciphertext pair and sends it to the terminal;
[0135] Among them, the binary search tree includes an L-layer binary structure, and the homomorphic retrieval algorithm is summarized as follows:
[0136] 2.1. Let the initial number of layers l = 1, and let the threshold ciphertext of the first layer binary structure ct1 = ck1;
[0137] 2.2 Homomorphic comparison ct l and ciphertext, and obtain the homomorphic comparison result corresponding to the binary structure of the lth layer;
[0138] 2.3. Determine whether the homomorphic comparison result of the L-layer binary structure layer is obtained; if not, continue to execute steps 2.4 and 2.5; if yes, go to step 2.6;
[0139] 2.4. Based on the homomorphic comparison results corresponding to the binary structures at each layer, the current ciphertext of the keyword is updated to determine ct l+1 ;
[0140] 2.5. Go to step 2.2 and set l = l + 1;
[0141] 2.6. Based on the homomorphic comparison results corresponding to all binary structures, homomorphic ciphertext is homomorphically extracted from the L-layer binary structure;
[0142] 3. The terminal decrypts the homomorphic ciphertext and obtains the data corresponding to the target keyword.
[0143] The technical solution provided in the embodiment of the present application, with respect to the server side, only requires the server to store data in a binary search tree structure, and performs real-time calculations when the terminal initiates a retrieval request. There is no need to pre-generate a fitting polynomial, and supports dynamic insertion of new data without performing complex update operations. It is more suitable for scenarios where data changes frequently. With respect to the terminal side, it only requires the terminal to generate two RLWE structured ciphertext pairs, i.e., two encryption operations, with a small amount of computation, less content to be transmitted when requesting, and only a single RLWE structured ciphertext needs to be decrypted when obtaining the result, which can reduce the requirements for terminal computing and storage, and is suitable for various terminals.
[0144] An embodiment of the present application provides a server. Figure 5 A schematic diagram of the structure of a server provided in an embodiment of the present application Figure 1 .like Figure 5 As shown, the server includes:
[0145] The first receiving module 301 is used to receive a ciphertext pair sent by a terminal; the ciphertext pair is a homomorphic encryption result of a target keyword;
[0146] A data retrieval module 302 is used to homomorphically retrieve the homomorphic ciphertext corresponding to the ciphertext pair using a binary search tree; each node in the binary search tree stores a keyword and data corresponding to the keyword, and the homomorphic ciphertext is a homomorphic encryption result of the data corresponding to the target keyword;
[0147] The first sending module 303 is used to send the homomorphic ciphertext to the terminal.
[0148] In one embodiment of the present application, the data retrieval module 302 is further used to store different keywords and their corresponding data in different nodes in order of the size of the keywords to construct the binary search tree.
[0149] In one embodiment of the present application, the data retrieval module 302 is also used to divide every two adjacent layers of nodes in the binary search tree from top to bottom into a layer of binary structure to obtain an L-layer binary structure; L is a positive integer, and the parent node in the next layer of binary structure is the child node of the parent node in the previous layer of binary structure; determine the threshold ciphertext of each layer of binary structure in the L-layer binary structure, and the homomorphic comparison result between the threshold ciphertext of each layer of binary structure and the ciphertext pair; based on the homomorphic comparison result between each layer of binary structure in the L-layer binary structure and the ciphertext pair, homomorphically extract the homomorphic ciphertext from the L-layer binary structure.
[0150] In one embodiment of the present application, the data retrieval module 302 is also used to homomorphically encrypt the keywords of each node different from the leaf node in the L-layer binary structure to obtain the initial ciphertext of the keyword; determine the initial ciphertext of the keyword of the parent node in the first-layer binary structure as the threshold ciphertext of the first-layer binary structure and homomorphically compare it with the ciphertext pair to obtain the homomorphic comparison result corresponding to the first-layer binary structure; if L is greater than 1, obtain the current ciphertext of the keyword of each node in the first n-1 layers of binary structure; n is a positive integer greater than 1 and less than or equal to L, and the current ciphertext of each keyword is the initial ciphertext or the updated ciphertext generated by updating the initial ciphertext; based on the current ciphertext of the keyword of each node in the first n-1 layers of binary structure and the homomorphic comparison results corresponding to each layer of binary structure in the first n-1 layers of binary structure, determine the threshold ciphertext of the n-th layer of binary structure; homomorphically compare the threshold ciphertext of the n-th layer of binary structure with the ciphertext pair to obtain the homomorphic comparison result corresponding to the n-th layer of binary structure.
[0151] In one embodiment of the present application, the data retrieval module 302 is also used to determine the initial ciphertext of the keywords of each node in the first layer of binary structure as the current ciphertext if n-1 is equal to 1; if n-1 is greater than 1, for the keywords of each node in the first n-1 layers of binary structure, if an updated ciphertext is generated when determining the threshold ciphertext of the n-1th layer of binary structure, then the generated updated ciphertext is determined as the current ciphertext; if no updated ciphertext is generated when determining the threshold ciphertext of the n-1th layer of binary structure, then the initial ciphertext is determined as the current ciphertext.
[0152] In one embodiment of the present application, the data retrieval module 302 is also used to update the current ciphertext of the keyword of the parent node in the n-1th layer of binary structure based on the current ciphertext of the keyword of the parent node and its child nodes in the n-1th layer of binary structure, and the homomorphic comparison result corresponding to the n-1th layer of binary structure; if n-1 is greater than 1, from the n-2th layer of binary structure from bottom to top, based on the updated ciphertext of the keyword in the parent node in the next layer of binary structure, the current ciphertext of the keyword of the parent node in the previous layer of binary structure, and the homomorphic comparison result corresponding to the previous layer of binary structure, update the current ciphertext of the keyword of the parent node in the previous layer of binary structure until the updated ciphertext of the keyword in the parent node in the 1st layer of binary structure is obtained; the updated ciphertext of the keyword in the parent node in the 1st layer of binary structure is determined as the threshold ciphertext of the nth layer of binary structure.
[0153] In one embodiment of the present application, the data retrieval module 302 is also used to homomorphically encrypt the data of each node in the L-layer binary structure to obtain the initial ciphertext of the data; based on the initial ciphertext of the data of the parent node and its child nodes in the L-layer binary structure, and the homomorphic comparison result corresponding to the L-layer binary structure, update the initial ciphertext of the data of the parent node in the L-layer binary structure; if L is greater than 1, from the L-layer binary structure from bottom to top, based on the updated ciphertext of the data in the parent node in the next-layer binary structure, the current ciphertext of the data of the parent node in the previous-layer binary structure, and the homomorphic comparison result corresponding to the previous-layer binary structure, update the initial ciphertext of the data of the parent node in the previous-layer binary structure until the updated ciphertext of the data of the parent node in the 1st-layer binary structure is obtained; the updated ciphertext of the data of the parent node in the 1st-layer binary structure is determined as the homomorphic ciphertext.
[0154] Figure 6 A schematic diagram of the structure of a server provided in an embodiment of the present application Figure 2 .like Figure 6 As shown, the server includes: a first processor 401, a first memory 402 and a first communication bus 403;
[0155] The first communication bus 403 is used to implement a communication connection between the first processor 401 and the first memory 402;
[0156] The first processor 401 is used to execute one or more computer programs stored in the first memory 402 to implement a data retrieval method applied to a server.
[0157] An embodiment of the present application provides a terminal. Figure 7 A schematic diagram of a terminal structure provided in an embodiment of the present application Figure 1 .like Figure 7 As shown, the terminal includes:
[0158] The data processing module 501 is used to homomorphically encrypt the target keyword to obtain a ciphertext pair;
[0159] The second sending module 502 is used to send the ciphertext pair to the server, so that the server uses a binary search tree to homomorphically retrieve the homomorphic ciphertext corresponding to the ciphertext pair; each node in the binary search tree stores a keyword and data corresponding to the keyword, and the homomorphic ciphertext is a homomorphic encryption result of the data corresponding to the target keyword;
[0160] The second receiving module 503 is used to receive the homomorphic ciphertext sent by the server.
[0161] In one embodiment of the present application, the data processing module 501 is also used to decrypt the homomorphic ciphertext to obtain data corresponding to the target keyword.
[0162] Figure 8 A schematic diagram of a terminal structure provided in an embodiment of the present application Figure 2 .like Figure 8 As shown, the terminal includes: a second processor 601, a second memory 602 and a second communication bus 603;
[0163] The second communication bus 603 is used to implement a communication connection between the second processor 601 and the second memory 602;
[0164] The second processor 601 is configured to execute one or more computer programs stored in the second memory 602 to implement a data retrieval method applied to a terminal.
[0165] An embodiment of the present application provides a computer program product, including a computer program, which, when executed, implements the steps of a data retrieval method applied to a server, or the steps of a data retrieval method applied to a terminal.
[0166] The embodiment of the present application is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps in the data retrieval method applied to the server are implemented, or the steps in the data retrieval method applied to the terminal are implemented. The computer-readable storage medium can be a volatile memory (volatile memory), such as a random access memory (Random-Access Memory, RAM); or a non-volatile memory (non-volatile memory), such as a read-only memory (Read-Only Memory, ROM), a flash memory (flash memory), a hard disk (Hard Disk Drive, HDD) or a solid-state drive (Solid-State Drive, SSD); or it can be a respective device including one or any combination of the above memories, such as a mobile phone, a computer, a tablet device, a personal digital assistant, etc.
[0167] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of hardware embodiments, software embodiments, or embodiments in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) that contain computer-usable program code.
[0168] The present application is described with reference to implementation flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the process in the flowchart. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0169] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which is implemented in the implementation flow diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0170] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process described in the flowchart. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0171] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by any technician familiar with the technical field within the technical scope disclosed in the utility application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A data retrieval method, characterized in that: Applied to a server, the method comprises: A ciphertext pair sent by a receiving terminal; the ciphertext pair is a homomorphic encryption result of a target keyword; Homomorphically searching for homomorphic ciphertexts corresponding to the ciphertext pair using a binary search tree; each node in the binary search tree stores a keyword and data corresponding to the keyword, and the homomorphic ciphertext is a homomorphic encryption result of the data corresponding to the target keyword; The homomorphic ciphertext is sent to the terminal.
2. The method according to claim 1, characterized in that Before using the binary search tree to homomorphically retrieve the homomorphic ciphertext corresponding to the ciphertext pair, the method further includes: Different keywords and their corresponding data are sorted according to the size of the keywords and stored in different nodes to construct the binary search tree.
3. The method according to claim 1, characterized in that The using a binary search tree to homomorphically retrieve a homomorphic ciphertext corresponding to the ciphertext pair includes: Divide each two adjacent layers of nodes in the binary search tree from top to bottom into a layer of binary structure, and obtain an L-layer binary structure; L is a positive integer, and the parent node in the next layer of binary structure is the child node of the parent node in the previous layer of binary structure; Determine a threshold ciphertext of each layer of the L-layer binary structure, and a homomorphic comparison result between the threshold ciphertext of each layer of the binary structure and the ciphertext pair; Based on the homomorphic comparison result between each layer of binary structure in the L-layer binary structure and the ciphertext pair, the homomorphic ciphertext is homomorphically extracted from the L-layer binary structure.
4. The method according to claim 3, characterized in that Determining the threshold ciphertext of each layer of the L-layer binary structure and the homomorphic comparison result between the threshold ciphertext of each layer of the binary structure and the ciphertext pair, including: Homomorphically encrypting the keywords of each node different from the leaf node in the L-layer binary structure to obtain an initial ciphertext of the keyword; Determine the initial ciphertext of the keyword of the parent node in the first-layer binary structure as the threshold ciphertext of the first-layer binary structure and compare it with the ciphertext pair homomorphically to obtain a homomorphic comparison result corresponding to the first-layer binary structure; If L is greater than 1, obtain the current ciphertext of the keyword of each node in the first n-1 layers of the binary structure; n is a positive integer greater than 1 and less than or equal to L, and the current ciphertext of each keyword is the initial ciphertext or the updated ciphertext generated by updating the initial ciphertext; Based on the current ciphertext of the keywords of each node in the first n-1 layers of binary structures and the homomorphic comparison results corresponding to each layer of binary structures in the first n-1 layers of binary structures, the threshold ciphertext of the nth layer of binary structures is determined; The threshold ciphertext of the n-th layer binary structure is homomorphically compared with the ciphertext pair to obtain a homomorphic comparison result corresponding to the n-th layer binary structure.
5. The method according to claim 4, characterized in that The obtaining of the current ciphertext of the keyword of each node in the first n-1 layers of the binary structure includes: If n-1 is equal to 1, the initial ciphertext of the keyword of each node in the first-layer binary structure is determined as the current ciphertext; If n-1 is greater than 1, for the keywords of each node in the first n-1 layers of binary structure, if an updated ciphertext is generated when determining the threshold ciphertext of the n-1th layer of binary structure, the generated updated ciphertext is determined as the current ciphertext; if an updated ciphertext is not generated when determining the threshold ciphertext of the n-1th layer of binary structure, the initial ciphertext is determined as the current ciphertext.
6. The method according to claim 4, characterized in that The method of determining the threshold ciphertext of the n-th layer of binary structure based on the current ciphertext of the keywords of each node in the first n-1 layers of binary structure and the homomorphic comparison results corresponding to each layer of binary structure in the first n-1 layers of binary structure comprises: Based on the current ciphertext of the keyword of the parent node and its child nodes in the n-1-th layer binary structure, and the homomorphic comparison result corresponding to the n-1-th layer binary structure, update the current ciphertext of the keyword of the parent node in the n-1-th layer binary structure; If n-1 is greater than 1, from the bottom to the top of the n-2-th binary structure, based on the updated ciphertext of the keyword in the parent node in the next binary structure, the current ciphertext of the keyword in the parent node in the previous binary structure, and the homomorphic comparison result corresponding to the previous binary structure, update the current ciphertext of the keyword in the parent node in the previous binary structure until the updated ciphertext of the keyword in the parent node in the first binary structure is obtained; The updated ciphertext of the keyword in the parent node in the first-layer binary structure is determined as the threshold ciphertext of the n-th-layer binary structure.
7. The method according to claim 3, characterized in that The step of homomorphically extracting the homomorphic ciphertext from the L-layer binary structure based on the homomorphic comparison result between each layer of the binary structure in the L-layer binary structure and the ciphertext pair includes: Homomorphically encrypt the data of each node in the L-layer binary structure to obtain the initial ciphertext of the data; Based on the initial ciphertext of the data of the parent node and its child nodes in the L-th layer binary structure and the homomorphic comparison result corresponding to the L-th layer binary structure, the initial ciphertext of the data of the parent node in the L-th layer binary structure is updated; If L is greater than 1, from the Lth layer of binary structure, from bottom to top, based on the updated ciphertext of the data in the parent node in the next layer of binary structure, the current ciphertext of the data in the parent node in the previous layer of binary structure, and the homomorphic comparison result corresponding to the previous layer of binary structure, update the initial ciphertext of the data in the parent node in the previous layer of binary structure until the updated ciphertext of the data in the parent node in the first layer of binary structure is obtained; The updated ciphertext of the data of the parent node in the first-layer binary structure is determined as the homomorphic ciphertext.
8. A data retrieval method, characterized in that: Applied to a terminal, the method comprises: Homomorphically encrypt the target keyword to obtain a ciphertext pair; Sending the ciphertext pair to a server so that the server uses a binary search tree to homomorphically retrieve a homomorphic ciphertext corresponding to the ciphertext pair; each node in the binary search tree stores a keyword and data corresponding to the keyword, and the homomorphic ciphertext is a homomorphic encryption result of the data corresponding to the target keyword; Receive the homomorphic ciphertext sent by the server.
9. The method according to claim 8, characterized in that After receiving the homomorphic ciphertext sent by the server, the method includes: The homomorphic ciphertext is decrypted to obtain data corresponding to the target keyword.
10. A server, characterized in that: include: a first processor, a first memory, and a first communication bus; The first communication bus is used to implement a communication connection between the first processor and the first memory; The first processor is used to execute one or more computer programs stored in the first memory to implement the data retrieval method according to any one of claims 1 to 7.
11. A terminal, characterized in that: include: a second processor, a second memory, and a second communication bus; The second communication bus is used to implement a communication connection between the second processor and the second memory; The second processor is used to execute one or more computer programs stored in the second memory to implement the data retrieval method according to any one of claims 8 to 9.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the data retrieval method according to any one of claims 1 to 9 is implemented.
13. A computer program product, comprising a computer program, characterized in that When the computer program is executed, the data retrieval method according to any one of claims 1 to 9 is implemented.
