Keyword search processing method, encryption method, device and related equipment
By working collaboratively among the terminal, server, and security coprocessor, and utilizing mapping information and index decryption technology, the problem of single-keyword search is solved, enabling encrypted data search using multiple keywords, thus improving search diversity and efficiency.
Patent Information
- Application Number
- CN202110005429.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-05
- Publication Date
- 2026-01-16
- Estimated Expiration
- 2041-01-05
AI Technical Summary
In existing technologies, users can only use a single keyword to search encrypted data, resulting in a relatively simple search method and a lack of Boolean logic relationships between multiple keywords.
The system determines the target search tokens that match the N keywords to be searched from the mapping information pre-stored on the terminal, generates and sends them to the server, and the server and security coprocessor decrypt and query them. The mapping relationship between the target index and the score index is used to enrich the search methods.
It enables searching encrypted data using keywords composed of multiple keywords, enriching the search methods, taking into account the Boolean logic relationships between keywords, and improving the diversity and efficiency of the search.
Smart Images

Figure CN114722405B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the field of communication technology, and in particular to a keyword search processing method, an encryption method, an apparatus and related equipment. BACKGROUND
[0002] With the massive increase of data, in order to alleviate the storage pressure of data, more and more users choose to store data in the cloud, at the same time, use encryption technology to store encrypted files in the cloud, to ensure the security of data.
[0003] Users can use the search token encrypted for the keyword to search the encrypted data stored in the cloud. At present, it is limited to encrypting a single keyword to form a search token, in this case, users can only use a single keyword to search the encrypted data, and the search method is relatively single. SUMMARY
[0004] Embodiments of the present application provide a keyword search processing method, an encryption method, an apparatus and related equipment to solve the problem of a relatively single search method.
[0005] To solve the above problems, the present application is implemented as follows:
[0006] In a first aspect, the embodiments of the present application provide a keyword search processing method, executed by a terminal, comprising:
[0007] Determining at least one target search token matched by N keywords to be searched in pre-stored mapping information;
[0008] Sending a search request to a server, the search request comprising the target search token;
[0009] Receiving a target file sent by the server based on the target search token;
[0010] The mapping information comprises a mapping relationship between a search token and a keyword, the target search token is used to decrypt an encrypted target index and an encrypted score index, the target index comprises a first sub-index, the first sub-index is used to represent the mapping relationship between a file to which a keyword composed of M keywords belongs and the keyword, N and M are positive integers greater than 1, and the score index is used to represent the mapping relationship between a file and a weight value.
[0011] In a second aspect, the embodiments of the present application provide a keyword search processing method, executed by a server, comprising:
[0012] Receiving a target search token sent by a terminal;
[0013] decrypt, based on the target search token, a pre-stored encrypted target index to obtain an associated file corresponding to the target search token;
[0014] sending a query request to a security co-processor, the query request carrying the associated file and the target search token;
[0015] receiving a target file fed back by the security co-processor based on the associated file and the target search token;
[0016] The target index includes a first sub-index, the first sub-index is used to represent a mapping relationship between a file to which a keyword composed of M keywords belongs and the keyword, and a weight value of the target file is greater than a weight value of a non-target file in the associated file.
[0017] In a third aspect, an embodiment of the present application provides a keyword search processing method, executed by a security co-processor, and the method comprises:
[0018] receiving a target search token and an associated file corresponding to the target search token sent by a server;
[0019] decrypting, based on the target search token, a pre-stored encrypted score index to determine a target file in the associated file;
[0020] sending the target file to the server;
[0021] The score index is used to represent a mapping relationship between a file and a weight value.
[0022] In a fourth aspect, an embodiment of the present application provides a keyword encryption method, executed by a terminal, and the method comprises:
[0023] performing division operation on N keywords based on a preset key of a first encryption algorithm to generate a first search sub-token;
[0024] performing division operation on H keyword groups composed of M keywords based on a preset key of a first encryption algorithm to generate a second search sub-token, H being a positive integer;
[0025] obtaining a search token according to the first search sub-token and the second search sub-token.
[0026] In a fifth aspect, an embodiment of the present application further provides a terminal, comprising:
[0027] a first processor configured to determine at least one target search token matched by N keywords to be searched in pre-stored mapping information;
[0028] The first transceiver is configured to send a search request to a server, wherein the search request comprises the target search token;
[0029] The target file is received from the server based on the target search token;
[0030] The mapping information comprises a mapping relationship between a search token and a keyword, the target search token is used to decrypt an encrypted target index and an encrypted score index, the target index comprises a first sub-index, the first sub-index is used to represent a mapping relationship between a file to which a keyword composed of M keywords belongs and the keyword, N and M are positive integers greater than 1, and the score index is used to represent a mapping relationship between a file and a weight value.
[0031] In a sixth aspect, an embodiment of the present application further provides a server, comprising:
[0032] The second transceiver is configured to receive a target search token sent by a terminal;
[0033] The second processor is configured to decrypt a pre-stored encrypted target index based on the target search token to obtain an associated file corresponding to the target search token;
[0034] The second transceiver is further configured to send a query request to a security co-processor, wherein the query request carries the associated file and the target search token;
[0035] The target file is received from the security co-processor based on the associated file and the target search token;
[0036] The target index comprises a first sub-index, the first sub-index is used to represent a mapping relationship between a file to which a keyword composed of M keywords belongs and the keyword, and a weight value of the target file is greater than a weight value of a non-target file in the associated file.
[0037] In a seventh aspect, an embodiment of the present application further provides a security co-processor, comprising:
[0038] The third transceiver is configured to receive a target search token and an associated file corresponding to the target search token sent by a server;
[0039] The third processor is configured to decrypt a pre-stored encrypted score index based on the target search token to determine a target file in the associated file;
[0040] The third transceiver is further configured to send the target file to the server;
[0041] The score index is used to represent a mapping relationship between a file and a weight value.
[0042] In an eighth aspect, the embodiments of the present application further provide a terminal, comprising:
[0043] a fourth processor configured to perform division operation on the N keywords based on a preset key using a key of the first encryption algorithm to generate a first search sub-token;
[0044] perform division operation on the H keywords composed of the M keywords using a key of the first encryption algorithm to generate a second search sub-token, H being a positive integer;
[0045] obtain a search token according to the first search sub-token and the second search sub-token.
[0046] In a ninth aspect, the embodiments of the present application further provide a communication device, comprising a transceiver, a memory, a processor and a program stored in the memory and executable on the processor; and the processor is configured to read the program in the memory to implement the steps in the method according to the first aspect, or the steps in the method according to the second aspect, or the steps in the method according to the third aspect, or the steps in the method according to the fourth aspect.
[0047] In a tenth aspect, the embodiments of the present application further provide a readable storage medium for storing a program, and the program is executable on a processor to implement the steps in the method according to the first aspect, or the steps in the method according to the second aspect, or the steps in the method according to the third aspect, or the steps in the method according to the fourth aspect.
[0048] In the embodiments of the present application, the N keywords to be searched can be determined in the mapping information stored in the terminal in advance, and the target search token is used to decrypt the encrypted target index and the encrypted score index, and the target index comprises a first sub-index, and the first sub-index is used to represent the mapping relationship between the file to which the keyword composed of the M keywords belongs and the keyword. The user can search the encrypted data using the keyword composed of the M keywords, and in this way, the Boolean logical relationship between the multiple keywords is considered, and thus the searching method of the encrypted data is enriched. BRIEF DESCRIPTION OF DRAWINGS
[0049] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the description of the embodiments of the present application will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0050] Figure 1is one of flow charts of the keyword search processing method provided by the embodiment of the present application;
[0051] Figure 2 is one of flow charts of the keyword search processing method provided by the embodiment of the present application;
[0052] Figure 3 is one of flow charts of the keyword search processing method provided by the embodiment of the present application;
[0053] Figure 4 is one of flow charts of the keyword search processing method provided by the embodiment of the present application;
[0054] Figure 5 is one of structure schematic diagrams of the terminal provided by the embodiment of the present application;
[0055] Figure 6 is one of structure schematic diagrams of the terminal provided by the embodiment of the present application;
[0056] Figure 7 is one of structure schematic diagrams of the terminal provided by the embodiment of the present application;
[0057] Figure 8 is one of structure schematic diagrams of the terminal provided by the embodiment of the present application;
[0058] Figure 9 is one of structure schematic diagrams of the terminal provided by the embodiment of the present application. DETAILED DESCRIPTION
[0059] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of the present application.
[0060] The terms "first", "second", and the like in the embodiments of the present application are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product, or device that includes a series of steps or units does not necessarily limit to those clearly listed steps or units, but can include other steps or units not clearly listed or inherent to the process, method, product, or device. In addition, "and / or" is used in the present application to represent at least one of the connected objects, for example, A and / or B and / or C represents 7 cases including A alone, B alone, C alone, A and B both exist, B and C both exist, A and C both exist, and A, B and C all exist.
[0061] To make the technical problems, technical solutions and advantages to be solved by the present application clearer, specific embodiments will be described in detail below with reference to the drawings.
[0062] Referring to Figure 1 , Figure 1 is one of the flowcharts of the keyword search processing method provided by the embodiments of the present application. Figure 1 The keyword search processing method shown in the figure can be executed by a terminal.
[0063] As shown in the keyword search processing method Figure 1 The keyword search processing method can include the following steps:
[0064] Step 101, determining at least one target search token matched with N keywords to be searched in the pre-stored mapping information.
[0065] In this step, the terminal pre-stores mapping information, which includes the mapping relationship between search tokens and keywords. The terminal can determine at least one search token corresponding to N keywords to be searched based on the N keywords to be searched input by the user in the mapping information, which can be understood as a target search token, wherein N is a positive integer greater than 1.
[0066] The above target search token is used to decrypt the encrypted target index and the encrypted score index. It should be noted that the target index includes a first sub-index, which is used to represent the mapping relationship between the keyword and the keyword belonging file. It should be understood that the keyword is composed of M keywords, and M is a positive integer greater than 1; it should also be understood that if a keyword exists in a file, the file is defined as a keyword belonging file.
[0067] It should also be noted that the score index is used to represent the relationship between the file and the weight value, wherein the weight value is related to the number of keywords appearing in the file. For the specific scheme of determining the weight value of the file, please refer to the subsequent embodiments.
[0068] Step 102, sending a search request to a server, the search request including the target search token.
[0069] In this step, after determining the target search token, the terminal sends a search request to the server, wherein the search request carries the target search token.
[0070] Step 103, receiving a target file sent by the server based on the target search token.
[0071] In this step, the terminal receives a target file sent by the server based on the target search token, where the target file can be understood as a search result. In some embodiments, the target file is an encrypted file, and the terminal can decrypt the target file to determine the decrypted target file as the search result.
[0072] For how the server determines the target file based on the target search token, please refer to the related embodiments of the server.
[0073] In some embodiments, the target search token is a search token corresponding to a keyword. In this case, the target file fed back by the server is a file corresponding to the keyword, that is, a search request can be generated based on keywords with Boolean logical relationships, and the encrypted data is searched, thereby enriching the search method of the encrypted data.
[0074] In the embodiments of the present application, the at least one target search token matched by the N keywords to be searched can be determined in the mapping information pre-stored in the terminal, and the target search token is used to decrypt the encrypted target index and the encrypted score index. The target index includes a first sub-index, and the first sub-index is used to represent the mapping relationship between the file to which the keyword composed of M keywords belongs and the keyword. The user can search the encrypted data using the keyword composed of M keywords, and in this way, the Boolean logical relationship between multiple keywords is considered, thereby enriching the search method of the encrypted data.
[0075] Optionally, the mapping information further includes a mapping relationship between a search token and a keyword, and the target index further includes M second sub-indices corresponding to the M keywords, and each second sub-index is used to represent the mapping relationship between the file to which the corresponding keyword belongs and the corresponding keyword.
[0076] The mapping information further includes a mapping relationship between a search token and a keyword. In this case, the target index further includes M second sub-indices corresponding to the M keywords, that is, one second sub-index corresponds to one keyword. Any second sub-index is used to represent the mapping relationship between the file to which the corresponding keyword belongs and the corresponding keyword. It should be understood that if a keyword exists in a file, the file is defined as the file to which the keyword belongs.
[0077] Referring to Figure 2 , Figure 2 is a flowchart of the keyword search processing method provided by the embodiments of the present application. The keyword search processing method of the embodiments of the present application can be executed by the server.
[0078] As shown in Figure 2 , the keyword search processing method can include the following steps:
[0079] Step 201, receiving a target search token sent by a terminal.
[0080] In this step, the server receives the target search token sent by the terminal, and the server can be a cloud server.
[0081] Step 202, decrypting a pre-stored encrypted target index based on the target search token to obtain an associated file corresponding to the target search token.
[0082] In this step, the server pre-stores an encrypted target index and an encrypted file, and the server can use the target search token to decrypt the encrypted target index. The target index includes a first sub-index, which is used to represent the mapping relationship between a file to which a keyword composed of M keywords belongs and the keyword, i.e., the first sub-index reflects the mapping relationship between the file to which the keyword belongs and the keyword. The target index also includes a second sub-index, which reflects the mapping relationship between the file to which the keyword belongs and the keyword.
[0083] The target search token is used to decrypt the encrypted target index, and the specific decryption process is described in subsequent embodiments. Based on the second sub-index in the target index, the file to which the keyword belongs can be obtained; based on the first sub-index in the target index, the file to which the keyword belongs can be obtained. Here, the file to which the keyword belongs and the file to which the keyword belongs can be referred to as an associated file corresponding to the target search token.
[0084] Step 203, sending a query request to a secure coprocessor, the query request carrying the associated file and the target search token.
[0085] In this step, the server sends a query request to a secure coprocessor (SCP), and the query request carries the associated file and the target search token.
[0086] Step 204, receiving a target file fed back by the secure coprocessor based on the associated file and the target search token.
[0087] In this step, the server receives a target file fed back by the secure coprocessor based on the associated file and the target search token, and the target file is part of the associated file. In some embodiments, part of the associated file can be determined as the target file; in other embodiments, all of the associated file can be determined as the target file. It should be understood that the weight value of the target file is greater than the weight value of a non-target file in the associated file.
[0088] The process of how the secure coprocessor determines the target file based on the associated file and the target search token. Please refer to the related embodiments of the secure coprocessor.
[0089] It should be noted that the embodiment is as a server corresponding to the above method embodiment, and therefore, the related description in the above method embodiment can be referred to, and the same beneficial effects can be achieved. To avoid repeated description, no longer be described here.
[0090] The various optional embodiments introduced in the embodiments of the application can be combined with each other to be implemented in the case of not conflicting with each other, or can be implemented alone, and the embodiments of the application are not limited thereto.
[0091] Optionally, the encrypted target index includes L encrypted keywords and associated files corresponding to the L encrypted keywords, the keyword includes a keyword and a keyword, the encrypted keyword is generated by multiplying the keyword based on a key of a first encryption algorithm, L is a positive integer; the target search token is generated by dividing a target keyword based on the key of the first encryption algorithm;
[0092] The decryption of the pre-stored encrypted target index based on the target search token includes:
[0093] Multiplying the target search token and the encrypted target index to obtain the associated file corresponding to the target keyword.
[0094] In the embodiment, how the server decrypts the encrypted target index based on the target search token is specifically described.
[0095] As described above, since the first sub-index in the target index includes the mapping relationship between the keyword and the file to which the keyword belongs, the encrypted first sub-index includes the encrypted keyword and the associated file corresponding to the encrypted keyword, and here, the associated file corresponding to the encrypted keyword can be understood as the file to which the keyword belongs.
[0096] The generation principle of the encrypted keyword can be simply understood as: multiplying the keyword based on the key of the first encryption algorithm, and it should be understood that the generation process of the encrypted keyword also includes other steps, and the embodiment does not limit that the encrypted keyword is only generated by multiplying the keyword based on the key of the first encryption algorithm, and the specific generation mode of the encrypted keyword is described in the subsequent embodiments.
[0097] As described above, since the second sub-index includes the mapping relationship between the keyword and the file to which the keyword belongs, the encrypted second sub-index includes the encrypted keyword and the associated file corresponding to the encrypted keyword, and here, the associated file corresponding to the encrypted keyword can be understood as the file to which the keyword belongs.
[0098] The principle of generating the encrypted keyword can be simply understood as: using the key of the first encryption algorithm to perform multiplication operation on the keyword. It should be understood that the generation process of the encrypted keyword also includes other steps. The present embodiment does not limit that the encrypted keyword is generated only by multiplying the key of the first encryption algorithm on the keyword. For the specific generation method of the encrypted keyword, please refer to the subsequent embodiments.
[0099] Since the target index includes the first sub-index and the second sub-index, the encrypted target index includes the encrypted keyword and the associated file corresponding to the encrypted keyword. The keyword includes the keyword and the keyword.
[0100] The principle of generating the search token can be simply understood as: using the key of the first encryption algorithm to perform division operation on the keyword, and using the key of the first encryption algorithm to perform division operation on the keyword. It should be understood that the generation process of the search token also includes other steps. For the specific generation method of the search token, please refer to the subsequent embodiments.
[0101] The principle of generating the encrypted file can be simply understood as: using the traditional symmetric encryption method, such as some encryption methods in the Advanced Encryption Standard (AES), to encrypt the file.
[0102] Based on the above, the server can multiply the target search token with the encrypted target index to obtain the file corresponding to the encrypted keyword and / or the file corresponding to the encrypted keyword. The file decrypted by the server can be understood as the associated file corresponding to the target keyword.
[0103] For the convenience of understanding the present embodiment, the following example is given: the user inputted keywords to be searched are "you", "I" and "he", and six target search tokens are generated, which are the search tokens corresponding to the keywords "you", "I" and "he", and the search tokens corresponding to the keywords "you I", "you he" and "I he". Among them, "you I" and "you he" can be understood as the intersection keyword of "I", and "I he" can be understood as the intersection keyword of "I".
[0104] The format of the encrypted target index can be expressed as:
[0105]
[0106] In the above formula, w1 represents "you", w2 represents "I", w3 represents "he", w4 represents "you I", w5 represents "you he", and w6 represents "I he". f represents the file number, for example, f1 represents the first file.
[0107] For example, the index w1→f1,f3,f5→10101 indicates that the keyword "you" exists in the first, third, and fifth files. The index w4→f3→00100 indicates that the keyword "you and me" exists in the third file.
[0108] Multiplying the target search token by the encrypted target index yields a binary number representing the associated files. For example, in the example above, the binary number 11111 would be obtained, indicating that the first, second, third, fourth, and fifth files are the associated files corresponding to the target search token.
[0109] See Figure 3 , Figure 3 This is the third flowchart of the keyword search processing method provided in this embodiment of the invention. The keyword search processing method of this embodiment of the invention can be executed by a security coprocessor.
[0110] like Figure 3 As shown, the keyword search processing method may include the following steps:
[0111] Step 301: Receive the target search token and the associated file corresponding to the target search token sent by the server.
[0112] In this step, the security coprocessor receives a query request sent by the server, which carries the target search token and the associated file corresponding to the target search token.
[0113] Step 302: Decrypt the pre-stored encrypted score index based on the target search token to determine the target file in the associated file.
[0114] In this step, the security coprocessor pre-stores an encrypted score index, which represents the mapping relationship between files and weight values. The security coprocessor can use a target search token to decrypt the encrypted score index, obtain the score index, and determine the target file in the associated files based on the score index, where the target file belongs to the associated files.
[0115] For details on how to decrypt the encrypted score index using the target search token, please refer to the following examples.
[0116] Step 303: Send the target file to the server.
[0117] In this step, the security coprocessor sends the obtained target file to the server.
[0118] It should be noted that the embodiment is as an implementation of the security co-processor corresponding to the above method embodiment, and therefore, the related description in the above method embodiment can be referred to, and the same beneficial effects can be achieved. In order to avoid repeated description, it will not be described here.
[0119] The various optional embodiments introduced in the embodiments of the application can be combined with each other for implementation without conflict, or can be implemented alone, and the embodiments of the application are not limited in this regard.
[0120] Optionally, the encrypted score index pre-stored is decrypted based on the target search token to determine the target file in the associated file.
[0121] The encrypted score index pre-stored is decrypted based on the target search token to obtain the weight value of the associated file; and the K target files in the associated file are determined in descending order of the weight value, and K is a positive integer.
[0122] In the embodiment, the security co-processor decodes the encrypted score index to obtain the score index. As described above, the score index reflects the mapping relationship between the file and the weight value. The associated file is queried based on the score index to obtain the weight value corresponding to the associated file.
[0123] An optional implementation is that the first K files in the associated file are determined as the target files in descending order of the weight value.
[0124] The value of K can be a value generated by the terminal, and the terminal transmits the value to the security co-processor before searching the keyword.
[0125] In this way, the K files are filtered out according to the weight value of each file and fed back to the server, and then fed back to the terminal via the server, so that the top-k ranking of the search result is realized, and the search efficiency is improved.
[0126] Optionally, the score index is used to represent the mapping relationship between the associated file and the weight value corresponding to the associated file, the encrypted score index is generated by performing multiplication operation on the score index based on the key of the first encryption algorithm; and the target search token is generated by performing division operation on the target keyword based on the key of the first encryption algorithm.
[0127] The encrypted score index pre-stored is decrypted based on the target search token to obtain the weight value of the associated file includes:
[0128] The score index is obtained by multiplying the target search token and the encrypted score index; and the weight value corresponding to the associated file is determined according to the score index.
[0129] In this embodiment, it is specifically explained how the security co-processor decrypts the encrypted score index using the search token.
[0130] The principle of generating the encrypted score index can be simply understood as that the key of the first encryption algorithm is used to multiply the score index. It should be understood that the generation process of the encrypted score index also includes the process of encrypting the score index using other encryption algorithms. The present embodiment does not limit that the encrypted score index is only generated by multiplying the score index by the key of the first encryption algorithm. For the specific generation manner of the encrypted score index, please refer to subsequent embodiments.
[0131] Based on the above content, the security co-processor can multiply the target search token and the encrypted score index to obtain the score index. Further, the weight value of the associated file is determined according to the score index.
[0132] Referring to Figure 4 , Figure 4 is a flowchart of the keyword encryption method provided by the embodiment of the present application. The keyword encryption method of the present embodiment can be executed by a terminal.
[0133] As shown in Figure 4 , the keyword encryption method can include the following steps:
[0134] In step 401, based on the preset N keywords, the key of the first encryption algorithm is used to divide the N keywords to generate a first search sub-token.
[0135] In this embodiment, the process of generating the search token by the terminal is specifically described.
[0136] In this step, the first search sub-token is the token corresponding to the keyword. The above first search sub-token is also called a single-keyword token.
[0137] For each keyword, the private key of the first encryption algorithm can be used to divide the keyword to generate a first encryption value, the public key of the first encryption algorithm is used to calculate the first encryption value to obtain a second encryption value, and the first search sub-token is obtained according to the first encryption value, the second encryption value and a random vector. Wherein, the above first encryption algorithm can be a 2DNF algorithm.
[0138] The construction of the first search sub-token can be represented by the following formula:
[0139]
[0140] wherein, w q represents a keyword, represents a first search sub-token, represents a random vector, represents a first encryption value, representing the second encrypted value.
[0141] At step 402, based on the H keywords composed of the M keywords, the first search sub-token is generated by using the key of the first encryption algorithm to do division operation on the H keywords.
[0142] In this step, the second search sub-token is the token corresponding to the keyword, and the second search sub-token is also called the intersection keyword token.
[0143] The way of generating the second search sub-token in this step is the same as the way of generating the first search sub-token in the above step, and the difference is that this step uses the first encryption algorithm to encrypt the keyword. This step will not be elaborated here.
[0144] At step 403, the search token is obtained according to the first search sub-token and the second search sub-token.
[0145] In this step, an optional way is to integrate the first search sub-token and the second search sub-token to obtain the search token.
[0146] It should be noted that in an application scenario, if the user inputs N search keywords, N is a positive integer greater than 1, then the search token corresponding to the first search keyword to the N-1 search keyword includes two parts, that is, the first search sub-token and the second search sub-token. The first search sub-token is related to the keyword, and the second search sub-token is related to the keyword. The search token corresponding to the Nth keyword only includes the first search sub-token.
[0147] For example, the search keywords are "you", "I" and "he", and the search token corresponding to the first search keyword "you" includes one first search sub-token and two second search sub-tokens. The first search sub-token is the search token corresponding to the keyword "you"; one second search sub-token is the search token corresponding to the intersection keyword "you and I"; and the other second search sub-token is the search token corresponding to the intersection keyword "you and he".
[0148] Optionally, the keyword encryption method further comprises:
[0149] Generate a first dictionary based on H keywords composed of M keywords and a preset file corresponding to each keyword; use a key of a first encryption algorithm to perform multiplication operation on the keywords, use a second encryption algorithm to encrypt the first array, and generate an encrypted first sub-index; generate a second dictionary based on N keywords and a file corresponding to each keyword; use a key of the first encryption algorithm to perform multiplication operation on the keywords, use the second encryption algorithm to encrypt the second array, and generate an encrypted second sub-index; and obtain an encrypted target index according to the encrypted first sub-index and the encrypted second sub-index.
[0150] In this embodiment, the process of generating an encrypted target index by a terminal is specifically described.
[0151] The terminal generates H keywords based on M keywords. For example, if a user inputs two keywords to be searched, “you” and “I”, one keyword “you I” is generated.
[0152] The first dictionary is generated based on a preset file corresponding to each keyword. It should be understood that the first dictionary is used to represent the mapping relationship between the keywords and a first array, and the first array is used to represent the files corresponding to the H keywords.
[0153] In an optional embodiment, the first array is a string of binary numbers, wherein binary number 1 indicates that the keyword corresponding to the first array exists in the file.
[0154] For example, the keyword in the first dictionary is “you I”, and the first array is 10100. It indicates that the keyword “you I” exists in the first file and the third file.
[0155] Use a key of a first encryption algorithm to perform multiplication operation on each keyword in the first dictionary to encrypt the keyword, and use a second encryption algorithm to encrypt the first array in the first dictionary to generate an encrypted first sub-index. The second encryption algorithm can be a probability public key encryption algorithm, for example, GM algorithm.
[0156] The encrypted second sub-index is generated in the same way as the encrypted first sub-index described above. The difference is that the first encryption algorithm is used to encrypt the keyword and the second encryption algorithm is used to encrypt the second value in this embodiment. This embodiment will not be described in more detail.
[0157] After obtaining the encrypted first sub-index and the encrypted second sub-index, the terminal integrates the encrypted first sub-index and the encrypted second sub-index to generate an encrypted target index. The terminal can send the encrypted target index to the server through an offline process, and it should be noted that the offline process is before the search keyword process. In this embodiment, when the keywords to be searched change, one possible case is that one keyword to be searched is deleted. In this case, the first sub-index deletes the index corresponding to the keyword to be searched, and the second sub-index deletes the index corresponding to the keyword to be searched.
[0158] Another possible case is that one keyword to be searched is added. In this case, the first sub-index adds the index corresponding to the keyword to be searched, and the second sub-index places the added keyword to be searched at the head of the second sub-index, so that the added keyword to be searched intersects with all the keywords in the second sub-index to generate the corresponding index.
[0159] In this way, when the keywords to be searched change, this embodiment supports dynamic updating of the target index, thereby saving the time for updating the target index.
[0160] In addition, the terminal can also use some encryption methods in AES to encrypt the file to generate an encrypted file, and send the encrypted file to the server through an offline process. It should be understood that the target file received by the terminal from the server is also an encrypted file, and the terminal can decrypt the encrypted file to display the decrypted file.
[0161] Optionally, the keyword encryption method further includes:
[0162] calculating the term frequency and the inverse document frequency index of the N keywords in the preset S files; determining the weight values corresponding to the S files according to the term frequency and the inverse document frequency index; and generating a score index based on the S files and the weight values corresponding to the S files, and performing multiplication operation on the score index using a key of the first encryption algorithm to obtain an encrypted score index.
[0163] In this embodiment, how the terminal generates the encrypted score index is specifically described.
[0164] The terminal calculates the term frequency (TF) and the inverse document frequency index (IDF) of the keywords in each preset file, and the term frequency and the inverse document frequency index can be referred to as TF-IDF values. The TF-IDF values are used to evaluate the importance of a word to a file set or a file in a corpus.
[0165] One alternative implementation is to use the TF-IDF inverse document frequency algorithm or other algorithms to calculate the TF-IDF value for each keyword in each file, thereby obtaining the weight value corresponding to each file. The weight value of a file can be understood as the TF-IDF value of the file.
[0166] A score index is generated based on the files and their corresponding weight values. As mentioned above, the score index represents the mapping relationship between each file and its corresponding weight value. In this embodiment, the key pair of the first encryption algorithm is used for multiplication to generate a third encrypted value, and the encrypted score index is obtained based on the third encrypted value and a random vector. It should be understood that the method of obtaining the encrypted score index based on the third encrypted value and the random vector is the same as the method of generating the encrypted target index described above, and will not be repeated here.
[0167] After obtaining the encryption score index, the terminal sends it to the security coprocessor via an offline process. See also... Figure 5 , Figure 5 This is one of the structural diagrams of the terminal provided in the embodiments of the present invention. For example... Figure 5 As shown, terminal 500 includes:
[0168] The first processor 501 is used to determine at least one target search token that matches N keywords to be searched in pre-stored mapping information.
[0169] The first transceiver 502 is used to send search requests to the server;
[0170] Receive the target file sent by the server based on the target search token.
[0171] Terminal 500 can implement the embodiments of the present invention. Figure 1 The various processes in the method embodiments, and the ways to achieve the same beneficial effects, will not be repeated here to avoid repetition.
[0172] See Figure 6 , Figure 6 This is a schematic diagram of the server structure provided in an embodiment of the present invention. Figure 6 As shown, server 600 includes:
[0173] The second transceiver 601 is used to receive the target search token sent by the terminal;
[0174] The second processor 602 is used to decrypt the pre-stored encrypted target index based on the target search token to obtain the associated file corresponding to the target search token;
[0175] The second transceiver 601 is also used to send a query request to the security coprocessor;
[0176] receive a target file fed back by the security co-processor based on the associated file and the target search token.
[0177] The server 600 can implement various processes of the method embodiments of the present application Figure 2 embodiments of the present application, and achieve the same beneficial effects. To avoid repetition, details are not described herein.
[0178] Referring to Figure 7 , Figure 7 is a structural schematic diagram of a security co-processor provided by an embodiment of the present application. As shown in Figure 7 , the security co-processor 700 includes:
[0179] a third transceiver 701 configured to receive a target search token and an associated file corresponding to the target search token sent by a server;
[0180] a third processor 702 configured to decrypt a pre-stored encrypted score index based on the target search token, and determine a target file in the associated file;
[0181] The third transceiver 701 is further configured to send the target file to the server.
[0182] Optionally, the third processor 702 is further configured to:
[0183] decrypt the pre-stored encrypted score index based on the target search token to obtain a weight value of the associated file;
[0184] determine K target files in the associated file in descending order of the weight value.
[0185] Optionally, the third processor 702 is further configured to:
[0186] multiply the target search token by the encrypted score index to obtain the score index;
[0187] determine a weight value corresponding to the associated file according to the score index.
[0188] The security co-processor 700 can implement various processes of the method embodiments of the present application Figure 3 embodiments of the present application, and achieve the same beneficial effects. To avoid repetition, details are not described herein.
[0189] Referring to Figure 8 , Figure 8 is a structural schematic diagram of a terminal provided by an embodiment of the present application. As shown in Figure 8 , the terminal 500 includes:
[0190] The fourth processor 503 is configured to perform division operation on the N keywords by using the key of the first encryption algorithm to generate a first search sub-token based on the N keywords;
[0191] The second search sub-token is generated by performing division operation on the H keywords composed of the M keywords by using the key of the first encryption algorithm;
[0192] The search token is obtained according to the first search sub-token and the second search sub-token.
[0193] Optionally, the fourth processor 503 is further configured to:
[0194] The first dictionary is generated based on the H keywords composed of the M keywords and the preset file corresponding to each keyword;
[0195] The first encryption sub-index is generated by performing multiplication operation on the keywords by using the key of the first encryption algorithm and encrypting the first array by using the second encryption algorithm;
[0196] The second dictionary is generated based on the N keywords and the file corresponding to each keyword;
[0197] The second encryption sub-index is generated by performing multiplication operation on the keywords by using the key of the first encryption algorithm and encrypting the second array by using the second encryption algorithm;
[0198] The encrypted target index is obtained according to the encrypted first sub-index and the encrypted second sub-index.
[0199] Optionally, the fourth processor 503 is further configured to:
[0200] The term frequency and the inverse document frequency index of the N keywords in the preset S files are calculated;
[0201] The weight value corresponding to the S files is determined according to the term frequency and the inverse document frequency index;
[0202] The score index is generated based on the S files and the weight value corresponding to the S files,
[0203] The multiplication operation is performed on the score index by using the key of the first encryption algorithm to obtain the encrypted score index.
[0204] The terminal 500 can implement various processes of the method embodiment of the present application Figure 4 The same beneficial effects are achieved, and thus details are not repeated here.
[0205] The present application also provides a communication device. Please refer to Figure 9The communication device can include a processor 801, a memory 802, and a program 8021 stored in the memory 802 and executable on the processor 801.
[0206] In the case of the communication device being a terminal, the program 8021, when executed by the processor 801, can implement Figure 1 Any step in the corresponding method embodiments and the same beneficial effects can be achieved, and here will not be repeated.
[0207] In the case of the communication device being a server, the program 8021, when executed by the processor 801, can implement Figure 2 Any step in the corresponding method embodiments and the same beneficial effects can be achieved, and here will not be repeated.
[0208] In the case of the communication device being a security co-processor, the program 8021, when executed by the processor 801, can implement Figure 3 Any step in the corresponding method embodiments and the same beneficial effects can be achieved, and here will not be repeated.
[0209] In the case of the communication device being a terminal, the program 8021, when executed by the processor 801, can implement Figure 4 Any step in the corresponding method embodiments and the same beneficial effects can be achieved, and here will not be repeated.
[0210] A person of ordinary skill in the art can understand that all or part of the steps of the methods in the above embodiments can be completed by program instructions related to hardware. The programs can be stored in a readable medium. The embodiments of the present application also provide a readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, can implement the methods described above. Figure 1 Or Figure 2 Or Figure 3 Or Figure 4 Any step in the corresponding method embodiments and the same beneficial effects can be achieved, and here will not be repeated.
[0211] The storage medium can be a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0212] The above is the preferred embodiment of the present application. It should be noted that, for those of ordinary skill in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, which should also be considered within the scope of the present application.
Claims
1. A keyword search processing method executed by a terminal, characterized by comprising: The method comprises: determining at least one target search token matching the N keywords to be searched in pre-stored mapping information; sending a search request to a server, the search request comprising the target search token; receiving a target file sent by the server based on the target search token; wherein the mapping information comprises a mapping relationship between a search token and a keyword, the target search token is used to decrypt an encrypted target index and an encrypted score index, the target index comprises a first sub-index, the first sub-index is used to represent a mapping relationship between a file to which a keyword composed of M keywords belongs and the keyword, N and M are positive integers greater than 1, and the score index is used to represent a mapping relationship between a file and a weight value; wherein the mapping information further comprises a mapping relationship between a search token and a keyword, and the target index further comprises M second sub-indices corresponding to the M keywords, each second sub-index is used to represent a mapping relationship between a file to which a corresponding keyword belongs and the corresponding keyword.
2. A keyword search processing method executed by a server, characterized by, The method comprises: receiving a target search token sent by a terminal; decrypting a pre-stored encrypted target index based on the target search token to obtain an associated file corresponding to the target search token; sending a query request to a security co-processor, the query request carrying the associated file and the target search token; receiving a target file fed back by the security co-processor based on the associated file and the target search token; wherein the target index comprises a first sub-index, the first sub-index is used to represent a mapping relationship between a file to which a keyword composed of M keywords belongs and the keyword, and a weight value of the target file is greater than that of a non-target file in the associated file.
3. The method of claim 2, wherein, The encrypted target index comprises L encrypted keyword phrases and associated files corresponding to the L encrypted keyword phrases, the keyword phrase comprises a keyword and a keyword, the encrypted keyword phrase is generated by multiplying a keyword phrase based on a key of a first encryption algorithm, and L is a positive integer; The target search token is generated by dividing a target keyword phrase based on a key of the first encryption algorithm; The decryption of the pre-stored encrypted target index based on the target search token comprises: multiplying the target search token and the encrypted target index to obtain an associated file corresponding to a target keyword phrase.
4. A method of keyword search processing, performed by a security co-processor, characterized by, The method comprises: receiving a target search token and an associated file corresponding to the target search token sent by a server; decrypting a pre-stored encrypted score index based on the target search token to determine a target file in the associated file; sending the target file to the server; wherein the score index is used to represent a mapping relationship between a file and a weight value; wherein the decryption of the pre-stored encrypted score index based on the target search token to determine the target file in the associated file comprises: decrypting a pre-stored encrypted score index based on the target search token to obtain a weight value of the associated file; Determine K target files in the associated file in order of the weight values from large to small, K being a positive integer.
5. The method of claim 4, wherein, The score index is used to represent the mapping relationship between the associated file and the weight value corresponding to the associated file. The encrypted score index is generated by performing multiplication operation on the score index based on a key of a first encryption algorithm. The target search token is generated by performing division operation on the target keyword based on the key of the first encryption algorithm. The method further comprises: Performing multiplication operation on the score index based on the key of the first encryption algorithm to obtain the encrypted score index. Determine the weight value corresponding to the associated file according to the score index.
6. A keyword encryption method, performed by a terminal, the method comprising: The method further comprises: Performing division operation on the N keywords based on a key of a first encryption algorithm to generate a first search sub-token, wherein the first encryption algorithm is a 2DNF algorithm. Performing division operation on the H keywords composed of M keywords based on a key of a first encryption algorithm to generate a second search sub-token, H being a positive integer. Obtain a search token according to the first search sub-token and the second search sub-token.
7. The method of claim 6, wherein, The method further comprises: Generate a first dictionary based on the H keywords composed of M keywords and the preset file corresponding to each keyword, wherein the first dictionary is used to represent the mapping relationship between the keyword and a first array, and the first array is used to represent the file corresponding to the H keywords. Perform multiplication operation on the keyword based on a key of a first encryption algorithm, and encrypt the first array based on a second encryption algorithm to generate an encrypted first sub-index. Generate a second dictionary based on the N keywords and the file corresponding to each keyword, wherein the second dictionary is used to represent the mapping relationship between the keyword and a second array, and the second array is used to represent the file corresponding to the N keywords. Perform multiplication operation on the keyword based on a key of a first encryption algorithm, and encrypt the second array based on a second encryption algorithm to generate an encrypted second sub-index. Obtain an encrypted target index according to the encrypted first sub-index and the encrypted second sub-index.
8. The method of claim 6, wherein, The method further comprises: Calculate the term frequency and the inverse text frequency index of the N keywords in the preset S files, S being a positive integer. Determine the weight value corresponding to the S files according to the term frequency and the inverse text frequency index. Generate a score index based on the S files and the weight value corresponding to the S files. Perform multiplication operation on the score index based on a key of a first encryption algorithm to obtain an encrypted score index.
9. A terminal, characterized by comprising: The method further comprises: The first processor is configured to determine at least one target search token matched with the N keywords to be searched in the pre-stored mapping information. The first transceiver is configured to send a search request to a server, wherein the search request comprises the target search token. Receive the target file sent by the server based on the target search token. The mapping information includes a mapping relationship between a search token and a keyword, and the target search token is used to decrypt an encrypted target index and an encrypted score index. The mapping information further includes a mapping relationship between a search token and a keyword, and the target index further includes M second sub-indices corresponding to the M keywords, each second sub-index being used to represent a mapping relationship between a file to which a corresponding keyword belongs and the corresponding keyword.
10. A server, characterized by The method comprises the following steps: The second transceiver receives a target search token sent by a terminal. The second processor decrypts a pre-stored encrypted target index based on the target search token to obtain an associated file corresponding to the target search token. The second transceiver sends a query request to a security co-processor, and the query request carries the associated file and the target search token. The target file is received based on the associated file and the target search token fed back by the security co-processor. The target index includes a first sub-index used to represent a mapping relationship between a file to which a keyword composed of M keywords belongs and the keyword, and the weight value of the target file is greater than the weight value of a non-target file in the associated file.
11. A secure co-processor, comprising: The method comprises the following steps: The third transceiver receives a target search token and an associated file corresponding to the target search token sent by a server. The third processor decrypts a pre-stored encrypted score index based on the target search token to determine a target file in the associated file. The third transceiver sends the target file to the server. The score index is used to represent a mapping relationship between a file and a weight value. The third processor further comprises the following steps: The third processor decrypts a pre-stored encrypted score index based on the target search token to obtain a weight value of the associated file. The third processor determines K target files in the associated file in descending order of the weight value, K being a positive integer.
12. The secure co-processor of claim 11, wherein, The score index is used to represent a mapping relationship between the associated file and a weight value corresponding to the associated file, and the encrypted score index is generated by multiplying the score index by a key of a first encryption algorithm. The third processor further comprises the following steps: The third processor multiplies the target search token by the encrypted score index to obtain the score index. The third processor determines a weight value corresponding to the associated file according to the score index.
13. A terminal, characterized by comprising: The fourth processor generates a first search sub-token by dividing N keywords by a key of a first encryption algorithm based on the N keywords, and the first encryption algorithm is a 2DNF algorithm. The H keywords are composed of M keywords, and a second search sub-token is generated by performing division operation on the H keywords using a key of a first encryption algorithm, where H is a positive integer; A search token is obtained according to the first search sub-token and the second search sub-token.
14. The terminal according to claim 13, characterized by The fourth processor is further configured to: A first dictionary is generated based on H keywords composed of M keywords and a preset file corresponding to each keyword, the first dictionary being used to represent a mapping relationship between the keywords and a first array, the first array being used to represent files corresponding to the H keywords; A first encryption sub-index is generated by performing multiplication operation on the keywords using a key of a first encryption algorithm and encrypting the first array using a second encryption algorithm; A second dictionary is generated based on N keywords and a file corresponding to each keyword, the second dictionary being used to represent a mapping relationship between the keywords and a second array, the second array being used to represent files corresponding to the N keywords; A second encryption sub-index is generated by performing multiplication operation on the keywords using a key of a first encryption algorithm and encrypting the second array using a second encryption algorithm; An encrypted target index is obtained according to the encrypted first sub-index and the encrypted second sub-index.
15. The terminal according to claim 13, characterized by The fourth processor is further configured to: Term frequencies and inverse text frequency indexes of N keywords in S preset files are calculated, where S is a positive integer; Weight values corresponding to the S files are determined according to the term frequencies and the inverse text frequency indexes; A score index is generated based on the S files and the weight values corresponding to the S files, The score index is multiplied using a key of a first encryption algorithm to obtain an encrypted score index.
16. A communication device comprising: A transceiver, a memory, a processor, and a program stored in the memory and executable on the processor; the processor is configured to read the program in the memory to implement the steps in the keyword search processing method according to claim 1; or the steps in the keyword search processing method according to any one of claims 2 to 3; or the steps in the keyword search processing method according to any one of claims 4 to 5; or the steps in the keyword encryption method according to any one of claims 6 to 8.
17. A readable storage medium for storing a program, characterized in that, The program is executed by the processor to implement the steps in the keyword search processing method according to claim 1; Or the steps in the keyword search processing method according to any one of claims 2 to 3; Or the steps in the keyword search processing method according to any one of claims 4 to 5; Or the steps in the keyword encryption method according to any one of claims 6 to 8.