A ciphertext index construction method and a data retrieval method
By constructing a ciphertext index using a hash encryption algorithm, the problem of high computational complexity in homomorphic encryption technology is solved, achieving efficient data privacy protection and retrieval, and supporting the retrieval of both character and numerical data.
Patent Information
- Application Number
- CN202510677287.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-26
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2045-05-26
AI Technical Summary
Existing homomorphic encryption technology has high computational complexity, resulting in high computational resource consumption and low efficiency during ciphertext retrieval.
A hash encryption algorithm is used to construct a ciphertext index. Character and numeric ciphertext indexes are generated through interpolation sorting and hash encryption. During retrieval, only the search keywords need to be hash encrypted and the data is retrieved within the ciphertext index.
It effectively avoids the risk of plaintext leakage, achieves data privacy protection, reduces calculation steps and resource consumption, improves retrieval efficiency, and supports retrieval of character and numerical data.
Smart Images

Figure CN120196794B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of computer, and particularly relates to a ciphertext index construction method and a data retrieval method. BACKGROUND
[0002] Ciphertext retrieval technology can realize direct search operation on encrypted data without exposing plaintext information. Among them, homomorphic encryption is one of the main technologies supporting range retrieval at present, which allows direct computation (such as addition / multiplication) on ciphertext without decrypting data. This feature enables homomorphic encryption to perform useful computation operations while protecting data privacy. However, in the process of using existing homomorphic encryption technology, the inventors found that it at least has the following problems: the high computational complexity of homomorphic encryption technology leads to the consumption of a large amount of computing resources and low retrieval efficiency when ciphertext retrieval is performed based on homomorphic encryption technology. SUMMARY
[0003] The present application aims to at least partially solve the above technical problems, and provides a ciphertext index construction method and a data retrieval method.
[0004] In order to achieve the above purpose, the present application adopts the following technical solutions:
[0005] In a first aspect, the present application provides a ciphertext index construction method, comprising:
[0006] receiving original data, and performing interpolation sorting processing on the original data according to the data type of the original data to obtain an initial index; wherein the original data includes character type data and numerical value type data, and the initial index includes a character type initial index corresponding to the character type data and a numerical value type initial index corresponding to the numerical value type data;
[0007] performing hash encryption processing on the original data in the initial index, and deleting the original data in the initial index to obtain a ciphertext index; wherein the index branch of the ciphertext index includes a character type ciphertext index corresponding to the character type data and a numerical value type ciphertext index corresponding to the numerical value type data.
[0008] In one possible design, when the data type of the original data is character type data, performing interpolation sorting processing on the original data to obtain an initial index comprises:
[0009] extracting the initial letter corresponding to the original data, and performing interpolation sorting processing on the original data in the preset character sequence according to the order of the initial letter to obtain a character type initial index;
[0010] When the data type of the original data is numerical data, the original data is subjected to interpolation sorting processing to obtain an initial index, including:
[0011] The integer part and the decimal part of the original data are extracted;
[0012] The integer part of the original data is inserted into a preset integer ordered sequence in size order, and the decimal part of the original data is inserted into a decimal sub-sequence corresponding to the integer part of the original data in size order to obtain a numerical initial index.
[0013] In one possible design, the original data in the initial index is subjected to hash encryption processing, including:
[0014] An interference factor is obtained, and the original data in the initial index is spliced with the interference factor to obtain spliced data;
[0015] The spliced data is subjected to hash encryption processing to obtain an index ciphertext corresponding to the original data in the initial index.
[0016] In a second aspect, the present application provides a data retrieval method, including:
[0017] A retrieval request bound with a retrieval keyword is received; wherein the retrieval keyword is character data or numerical data;
[0018] The retrieval keyword is subjected to hash encryption processing to obtain a keyword ciphertext, and data retrieval is performed in the ciphertext index according to the keyword ciphertext to obtain a retrieval result.
[0019] In one possible design, when the data type of the retrieval keyword is character data, the keyword ciphertext includes character encryption data; correspondingly, the retrieval keyword is subjected to hash encryption processing to obtain a keyword ciphertext, including: the retrieval keyword is subjected to hash encryption processing to obtain character encryption data;
[0020] When the data type of the retrieval keyword is numerical data, and the retrieval keyword is single-value data, the keyword ciphertext includes integer encryption data and decimal encryption data; correspondingly, the retrieval keyword is subjected to hash encryption processing to obtain a keyword ciphertext, and data retrieval is performed in the ciphertext index according to the keyword ciphertext to obtain a retrieval result, including:
[0021] The integer part and the decimal part of the retrieval keyword are extracted;
[0022] hashing the integer part of the search keyword to obtain integer encrypted data, and performing data retrieval in the ciphertext index according to the integer encrypted data, if any integer ciphertext of the ciphertext index is hit, then proceeding to the next step, if not, determining that the search result is empty;
[0023] hashing the decimal part of the search keyword to obtain decimal encrypted data, and performing data retrieval in the decimal ciphertext subsequence corresponding to any integer ciphertext according to the decimal encrypted data, if any decimal ciphertext in the decimal ciphertext subsequence is hit, then obtaining the ciphertext search result matched with the search keyword, if not, determining that the search result is empty.
[0024] In a possible design, when the data type of the search keyword is numerical data, and the search keyword is range value data, the search keyword is hashed to obtain keyword ciphertext, and data retrieval is performed in the ciphertext index according to the keyword ciphertext, so as to obtain a search result, including:
[0025] hashing the lower limit value of the search keyword to obtain encrypted lower limit value, and performing data retrieval in the ciphertext index according to the encrypted lower limit value, so as to obtain a lower limit search result;
[0026] hashing the upper limit value of the search keyword to obtain encrypted upper limit value, and performing data retrieval in the ciphertext index according to the encrypted upper limit value, so as to obtain an upper limit search result;
[0027] taking the data between the lower limit search result and the upper limit search result in the ciphertext index as the search result.
[0028] In a possible design, the encrypted lower limit value includes lower limit value integer encrypted data and lower limit value decimal encrypted data; correspondingly, hashing the lower limit value of the search keyword to obtain encrypted lower limit value, and performing data retrieval in the ciphertext index according to the encrypted lower limit value, so as to obtain a lower limit search result, includes:
[0029] c1. extracting the integer part and the decimal part of the lower limit value in the search keyword;
[0030] c2. hashing the integer part of the lower limit value to obtain lower limit value integer encrypted data, and performing data retrieval in the ciphertext index according to the lower limit value integer encrypted data, if any integer ciphertext of the ciphertext index is hit, then proceeding to step c3, if not, performing incremental approximation retrieval processing on the integer part of the lower limit value until any integer ciphertext of the ciphertext index is hit or it is determined that the search result is empty;
[0031] c3. Hashing the fractional part of the lower limit value to obtain lower limit value fractional encryption data, and performing data retrieval in the fractional ciphertext subsequence corresponding to any integer ciphertext according to the lower limit value fractional encryption data, if any fractional ciphertext in the fractional ciphertext subsequence is hit, a lower limit retrieval result matching the lower limit value is obtained, if not, incrementally approximating retrieval processing is performed on the fractional part of the lower limit value until any fractional ciphertext in the fractional ciphertext subsequence is hit or the retrieval result is determined to be empty.
[0032] In one possible design, in step c2, incrementally approximating retrieval processing is performed on the integer part of the lower limit value until any integer ciphertext of the ciphertext index is hit or the retrieval result is determined to be empty, including:
[0033] Incrementally calculating the integer part of the lower limit value to obtain an increment calculation result, and hashing the increment calculation result to obtain increment encryption data when the increment calculation result is less than the upper limit value;
[0034] Performing data retrieval in the ciphertext index according to the increment encryption data, if any integer ciphertext of the ciphertext index is hit, step c3 is entered, if not, incrementally calculating the integer part of the lower limit value again until any integer ciphertext of the ciphertext index is hit, or the retrieval result is determined to be empty when the increment calculation result is not less than the upper limit value;
[0035] In step c3, incrementally approximating retrieval processing is performed on the fractional part of the lower limit value until any fractional ciphertext in the fractional ciphertext subsequence is hit or the retrieval result is determined to be empty, including:
[0036] Adding one count unit to the fractional part of the lower limit value to obtain accumulated data;
[0037] Determining whether the accumulated data is less than 1;
[0038] If yes, hashing the accumulated data to obtain accumulated encryption data, and performing data retrieval in the fractional ciphertext subsequence corresponding to any integer ciphertext according to the accumulated encryption data, if any fractional ciphertext in the fractional ciphertext subsequence is hit, a lower limit retrieval result matching the lower limit value is obtained, if not, taking the accumulated data as the fractional part of the new lower limit value and adding one count unit thereto;
[0039] If no, taking the nearest integer greater than the accumulated data as a lower limit retrieval result matching the lower limit value or determining the retrieval result to be empty.
[0040] In a possible design, the encrypted upper limit value includes upper limit value integer encrypted data and upper limit value decimal encrypted data; correspondingly, the upper limit value of the search keyword is subjected to hash encryption to obtain an encrypted upper limit value, and data is searched in the ciphertext index according to the encrypted upper limit value, so as to obtain an upper limit search result, including:
[0041] d1. extracting an integer part and a decimal part of the upper limit value in the search keyword;
[0042] d2. subjecting the integer part of the upper limit value to hash encryption to obtain upper limit value integer encrypted data, and searching data in the ciphertext index according to the upper limit value integer encrypted data; if any integer ciphertext of the ciphertext index is hit, step d3 is entered; if no integer ciphertext is hit, the integer part of the upper limit value is subjected to decrement approximation search processing until any integer ciphertext of the ciphertext index is hit or it is determined that the search result is empty;
[0043] d3. subjecting the decimal part of the upper limit value to hash encryption to obtain upper limit value decimal encrypted data, and searching data in a decimal ciphertext subsequence corresponding to the any integer ciphertext according to the upper limit value decimal encrypted data; if any decimal ciphertext in the decimal ciphertext subsequence is hit, an upper limit search result matching the upper limit value is obtained; if no decimal ciphertext is hit, the decimal part of the upper limit value is subjected to decrement approximation search processing until any decimal ciphertext in the decimal ciphertext subsequence is hit or it is determined that the search result is empty.
[0044] In a possible design, in step d2, the integer part of the upper limit value is subjected to decrement approximation search processing until any integer ciphertext of the ciphertext index is hit or it is determined that the search result is empty, including:
[0045] the integer part of the upper limit value is subjected to decrement calculation to obtain a decrement calculation result, and the decrement calculation result is subjected to hash encryption to obtain decrement encrypted data when the decrement calculation result is less than the lower limit value;
[0046] data is searched in the ciphertext index according to the decrement encrypted data; if any integer ciphertext of the ciphertext index is hit, step d3 is entered; if no integer ciphertext is hit, the integer part of the upper limit value is subjected to decrement calculation again until any integer ciphertext of the ciphertext index is hit, or it is determined that the search result is empty when the decrement calculation result is not less than the lower limit value;
[0047] In step d3, the decimal part of the upper limit value is subjected to decrement approximation search processing until any decimal ciphertext in the decimal ciphertext subsequence is hit or it is determined that the search result is empty, including:
[0048] Subtracting one counting unit from the decimal part of the upper limit value, the cumulative subtraction data is obtained;
[0049] Judging whether the cumulative subtraction data is less than 0;
[0050] If yes, the cumulative subtraction data is subjected to a hash encryption process to obtain cumulative encryption data, and data retrieval is performed in the decimal ciphertext subsequence corresponding to the any integer ciphertext according to the cumulative encryption data, if any decimal ciphertext in the decimal ciphertext subsequence is hit, the upper limit retrieval result matched with the upper limit value is obtained, if not, the cumulative encryption data is taken as the decimal part of the new upper limit value, and one counting unit is subtracted therefrom;
[0051] If no, the nearest integer less than the cumulative encryption data is taken as the upper limit retrieval result matched with the upper limit value or the determination retrieval result is empty.
[0052] The present application has the following beneficial effects:
[0053] The present application discloses a ciphertext index construction method, which constructs a ciphertext index by using a hash encryption algorithm. Since the hash function has a one-way property, the risk of plaintext leakage can be effectively avoided, the privacy protection of data is realized, and the ciphertext retrieval requirement can be met. In addition, the ciphertext index constructed based on the present application can realize the retrieval of numerical value type data and character type data, and has a wider application range.
[0054] The present application also discloses a data retrieval method based on a ciphertext index. When data retrieval is performed based on the ciphertext index, only the retrieval keyword in the retrieval request needs to be subjected to a hash encryption process to obtain a keyword ciphertext, and data retrieval is performed in the ciphertext index according to the keyword ciphertext, so that the retrieval result is obtained. In this process, the present application only needs to use a hash encryption algorithm to encrypt and calculate the keyword, and performs data retrieval in the ciphertext index by using the encrypted keyword ciphertext. On the premise of ensuring security, unnecessary complex operations are reduced, the calculation steps and resource consumption are significantly reduced, and the retrieval efficiency is high.
[0055] Other beneficial effects of the present application will be further described in the specific embodiments. BRIEF DESCRIPTION OF DRAWINGS
[0056] Figure 1 is a flowchart of the ciphertext index construction method in embodiment 1;
[0057] Figure 2 is a structural schematic diagram of the ciphertext index in embodiment 1;
[0058] Figure 3 is a flowchart of the data retrieval method in embodiment 3;
[0059] Figure 4 is a flowchart of the lower limit retrieval process in Example 3;
[0060] Figure 5 is a flowchart of the upper limit retrieval process in Example 3. DETAILED DESCRIPTION
[0061] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the present application will be briefly introduced below in combination with the drawings and the description of the embodiments or the prior art. Obviously, the following description of the drawings is only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of these drawings. It should be noted that the description of these embodiments is used to help understand the present application, but does not constitute a limitation on the present application.
[0062] Example 1:
[0063] The present embodiment discloses a ciphertext index construction method, which can be executed by a computer device or a virtual machine with certain computing resources, such as a personal computer, a smart phone, a personal digital assistant, or a wearable device, or a virtual machine.
[0064] As shown in Figure 1 , a ciphertext index construction method can include, but is not limited to, the following steps:
[0065] A1. Receive the original data, and perform interpolation sorting processing on the original data according to the data type of the original data to obtain an initial index; wherein the original data includes character type data and numerical type data, and the initial index includes a character type initial index corresponding to the character type data and a numerical type initial index corresponding to the numerical type data; it should be noted that in the present embodiment, the original data includes the encrypted field of the original database, which is the original information to be encrypted, such as including name, age, and price, etc., which is not limited here.
[0066] Specifically, when the data type of the original data is character type data, the interpolation sorting processing is performed on the original data to obtain an initial index, including:
[0067] extracting the first letter corresponding to the original data, and performing interpolation sorting processing on the original data in the preset character sequence according to the order of the first letter to obtain a character type initial index; specifically, if the original data is Chinese data, the original data is converted to pinyin in advance, and the first letter of the pinyin is taken as the first letter of the original data.
[0068] In the embodiment, the character sorting function sortChar() is used to realize the interpolation sorting of the original data, that is, the character sorting function sortChar() is used to insert the original data into the character sequence.
[0069] When the data type of the original data is the numerical data, the interpolation sorting of the original data is performed to obtain the initial index, including:
[0070] The integer part and the decimal part of the original data are extracted. It should be noted that in the embodiment, the integer part and the decimal part of the original data are extracted by using the integer operation. Specifically, the integer part of the original data is extracted by using the floor function "floor", and the decimal part of the original data is obtained by subtracting the integer part from the original data. As an example, for the original data x, the result obtained by using the integer operation can be represented as: wherein, represents the integer part of the original data x, represents the decimal part of the original data x.
[0071] The integer part of the original data is inserted into the preset integer ordered sequence in size order, and the decimal part of the original data is inserted into the corresponding decimal sub-sequence of the integer part of the original data in size order to obtain the numerical initial index. Specifically, in the embodiment, the integer part and the decimal part of the original data are respectively sorted in size order.
[0072] It should be understood that in the embodiment, the numerical ciphertext index of the ciphertext index includes the integer ciphertext sequence corresponding to the integer ordered sequence and the decimal ciphertext sub-sequence corresponding to each integer ciphertext in the integer ciphertext sequence, that is, each integer ciphertext in the integer ciphertext sequence is provided with a decimal ciphertext sub-sequence.
[0073] In the embodiment, the numerical sorting function sortNum() is used to realize the interpolation sorting of the integer part and the decimal part of the original data.
[0074] A2. The original data in the initial index is subjected to the hash encryption processing, and the original data in the initial index is deleted to obtain the ciphertext index. The index branch of the ciphertext index includes the character type ciphertext index corresponding to the character type data and the numerical type ciphertext index corresponding to the numerical type data. It should be noted that in the embodiment, the ciphertext index adopts the multi-way tree structure, as shown in Figure 2 The character type ciphertext index and the numerical type ciphertext index constitute the index branch of the ciphertext index.
[0075] In step A2, the original data in the initial index is subjected to hash encryption processing, including:
[0076] A201. An interference factor is obtained, and the original data in the initial index is spliced with the interference factor to obtain spliced data;
[0077] A202. The spliced data is subjected to hash encryption processing to obtain an index ciphertext corresponding to the original data in the initial index. Specifically, in this embodiment, for the original data x in the initial index, the index ciphertext obtained by encryption calculation is h(x)=SM3(x||s), wherein s is a preset interference factor, || represents a string splicing symbol, and SM3() represents a national SM3 algorithm.
[0078] It should be noted that in this embodiment, when the original data in the initial index is subjected to hash encryption processing, the interference factor s is spliced to enhance the anti-collision property and isolate the reverse deduction, thereby further enhancing the data privacy protection capability of this embodiment.
[0079] This embodiment constructs a ciphertext index by using a hash encryption algorithm. Since the hash function has a one-way property, the risk of plaintext leakage can be effectively avoided, the privacy of data is protected, and the demand for ciphertext retrieval is met. In addition, the ciphertext index constructed based on this embodiment can realize retrieval of numerical value type data and character type data, and has a wider application range.
[0080] Embodiment 2:
[0081] This embodiment discloses a ciphertext index construction system for implementing the ciphertext index construction method in embodiment 1; the ciphertext index construction system comprises:
[0082] An initial index generation module is configured to receive original data, and perform interpolation sorting processing on the original data according to the data type of the original data to obtain an initial index; wherein the original data includes character type data and numerical value type data, and the initial index includes a character type initial index corresponding to the character type data and a numerical value type initial index corresponding to the numerical value type data;
[0083] A ciphertext index construction module is in communication connection with the initial index generation module, and is configured to perform hash encryption processing on the original data in the initial index, and delete the original data in the initial index to obtain a ciphertext index; wherein the index branch of the ciphertext index includes a character type ciphertext index corresponding to the character type data and a numerical value type ciphertext index corresponding to the numerical value type data.
[0084] It should be noted that the working process, working details and technical effects of the ciphertext index construction system provided in this embodiment 2 can be referred to embodiment 1, and will not be repeated here.
[0085] Embodiment 3
[0086] The embodiment discloses a data retrieval method, which can be executed by a computer device or a virtual machine with certain computing resources, such as an electronic device such as a personal computer, a smart phone, a personal digital assistant or a wearable device, or a virtual machine.
[0087] As shown in Figure 3 A data retrieval method based on the ciphertext index obtained by the ciphertext index construction method in any one of embodiments 1 or 2, which can include but is not limited to the following steps:
[0088] B1. Receive a search request bound with a search keyword; wherein the search keyword is character type data or numerical type data;
[0089] B2. Perform hash encryption processing on the search keyword to obtain keyword ciphertext, and perform data retrieval in the ciphertext index according to the keyword ciphertext to obtain a search result.
[0090] Specifically, in this embodiment, the data retrieval is performed by using the Boolean function match( ), if the keyword ciphertext meets the search requirement, the search result matched with it is returned, indicating that the data corresponding to the search keyword is matched in the ciphertext index, otherwise it is determined that the search result is empty, and the search failure information is returned, indicating that the data corresponding to the search keyword is not matched in the ciphertext index.
[0091] In step B2, when the data type of the search keyword is character type data, the keyword ciphertext includes character encrypted data; correspondingly, the hash encryption processing on the search keyword to obtain keyword ciphertext includes: performing hash encryption processing on the search keyword to obtain character encrypted data.
[0092] In step B2, when the data type of the search keyword is numerical type data, and the search keyword is single value data, the search condition at this time is single value search, and the keyword ciphertext includes integer encrypted data and decimal encrypted data; correspondingly, the hash encryption processing on the search keyword to obtain keyword ciphertext, and performing data retrieval in the ciphertext index according to the keyword ciphertext to obtain a search result includes:
[0093] Extracting the integer part and the decimal part of the search keyword;
[0094] The integer part of the search keyword is subjected to hash encryption to obtain integer encryption data, and data retrieval is performed in the ciphertext index according to the integer encryption data. If any integer ciphertext in the ciphertext index is hit, the next step is entered. If no ciphertext is hit, it is determined that the search result is empty.
[0095] The decimal part of the search keyword is subjected to hash encryption to obtain decimal encryption data, and data retrieval is performed in the decimal ciphertext subsequence corresponding to the any integer ciphertext according to the decimal encryption data. If any decimal ciphertext in the decimal ciphertext subsequence is hit, the ciphertext search result matching the search keyword is obtained. If no ciphertext is hit, it is determined that the search result is empty. It should be understood that, in the embodiment, when data retrieval is performed in the ciphertext index according to the decimal encryption data, data retrieval is performed in the decimal ciphertext subsequence corresponding to the integer part of the search keyword in the ciphertext index, and the ciphertext search result obtained is composed of the any integer ciphertext and the any decimal ciphertext.
[0096] To meet the requirement of range search, the embodiment is further improved as follows: in step B2, when the data type of the search keyword is numerical data, and the search keyword is range value data, the search condition at this time is range value search. The search keyword is subjected to hash encryption to obtain keyword ciphertext, and data retrieval is performed in the ciphertext index according to the keyword ciphertext to obtain a search result, including:
[0097] The lower limit value of the search keyword is subjected to hash encryption to obtain an encrypted lower limit value, and data retrieval is performed in the ciphertext index according to the encrypted lower limit value to obtain a lower limit search result.
[0098] The upper limit value of the search keyword is subjected to hash encryption to obtain an encrypted upper limit value, and data retrieval is performed in the ciphertext index according to the encrypted upper limit value to obtain an upper limit search result.
[0099] Data between the lower limit search result and the upper limit search result in the ciphertext index is taken as the search result.
[0100] Specifically, the encrypted lower limit value includes lower limit value integer encryption data and lower limit value decimal encryption data. Correspondingly, as shown in Figure 4 The lower limit value of the search keyword is subjected to hash encryption to obtain an encrypted lower limit value, and data retrieval is performed in the ciphertext index according to the encrypted lower limit value to obtain a lower limit search result, including:
[0101] c1. Extracting the integer part and the decimal part of the lower limit value in the search keyword;
[0102] c2. Hash encrypting the integer part of the lower limit value to obtain lower limit value integer encrypted data, and performing data retrieval in the ciphertext index according to the lower limit value integer encrypted data, if any integer ciphertext of the ciphertext index is hit, then entering step c3, if not, performing incremental approximation retrieval processing on the integer part of the lower limit value until any integer ciphertext of the ciphertext index is hit or it is determined that the retrieval result is empty;
[0103] c3. Hash encrypting the fractional part of the lower limit value to obtain lower limit value fractional encrypted data, and performing data retrieval in the fractional ciphertext subsequence corresponding to the any integer ciphertext according to the lower limit value fractional encrypted data, if any fractional ciphertext in the fractional ciphertext subsequence is hit, then obtaining the lower limit retrieval result matching the lower limit value, if not, performing incremental approximation retrieval processing on the fractional part of the lower limit value until any fractional ciphertext in the fractional ciphertext subsequence is hit or it is determined that the retrieval result is empty.
[0104] In step c2 of the embodiment, the incremental approximation retrieval processing on the integer part of the lower limit value until any integer ciphertext of the ciphertext index is hit or it is determined that the retrieval result is empty, includes:
[0105] Incrementally calculating the integer part of the lower limit value to obtain an incremental calculation result, and when the incremental calculation result is less than the upper limit value, hash encrypting the incremental calculation result to obtain incremental encrypted data;
[0106] Performing data retrieval in the ciphertext index according to the incremental encrypted data, if any integer ciphertext of the ciphertext index is hit, then entering step c3, if not, again incrementally calculating the integer part of the lower limit value until any integer ciphertext of the ciphertext index is hit, or it is determined that the retrieval result is empty when the incremental calculation result is not less than the upper limit value;
[0107] In step c3, the incremental approximation retrieval processing on the fractional part of the lower limit value until any fractional ciphertext in the fractional ciphertext subsequence is hit or it is determined that the retrieval result is empty, includes:
[0108] Adding a count unit to the fractional part of the lower limit value to obtain accumulated data;
[0109] Determining whether the accumulated data is less than 1;
[0110] If yes, the accumulated data is subjected to hash encryption to obtain accumulated encrypted data, and data retrieval is performed in the subsequence of decimal ciphertext corresponding to the any integer ciphertext according to the accumulated encrypted data. If any decimal ciphertext in the subsequence of decimal ciphertext is hit, the lower limit retrieval result matching the lower limit value is obtained. If not, the accumulated data is taken as the decimal part of the new lower limit value, and a count unit is added thereto.
[0111] If no, the nearest integer greater than the accumulated data is taken as the lower limit retrieval result matching the lower limit value or the determination retrieval result is empty. Specifically, in the embodiment, if the accumulated data is not less than 1, the nearest integer greater than the accumulated data is taken as the previous integer, and it is further determined whether the previous integer is greater than the upper limit value. If yes, the determination retrieval result is empty. Otherwise, the previous integer is taken as the lower limit retrieval result matching the lower limit value.
[0112] As an example, if the ciphertext index corresponds to the plaintext as follows:
[0113] 2.1, 2.3, 2.5, 3, 3.1, 3.2, 3.5, 4, 4.1, 4.2, 5, 6.2, 6.3;
[0114] When the data type of the retrieval keyword is numerical data, the retrieval keyword is range value data, the lower limit value of the retrieval keyword is 2.6, and the upper limit value is 6.1, the decimal part of the lower limit value 2.6 is subjected to incremental approximation retrieval processing. 0.6 is not matched in 2.1, 2.3, 2.5 of the ciphertext index. At this time, 3 in the ciphertext index is taken as the lower limit retrieval result matching the lower limit value 2.6, and all data greater than or equal to 3 and less than or equal to the upper limit retrieval result in the ciphertext index can be obtained as hit data based thereon.
[0115] In the embodiment, the encrypted upper limit value includes upper limit value integer encrypted data and upper limit value decimal encrypted data. Correspondingly, as shown in the following table, the upper limit value of the retrieval keyword is subjected to hash encryption to obtain the encrypted upper limit value, and data retrieval is performed in the ciphertext index according to the encrypted upper limit value to obtain the upper limit retrieval result, including: Figure 5
[0116] d1. Extracting the integer part and the decimal part of the upper limit value in the retrieval keyword;
[0117] d2. Hash encrypting the integer part of the upper limit value to obtain upper limit value integer encrypted data, and performing data retrieval in the ciphertext index according to the upper limit value integer encrypted data, if any integer ciphertext in the ciphertext index is hit, then entering step d3, if not, performing decreasing approximation retrieval processing on the integer part of the upper limit value until any integer ciphertext in the ciphertext index is hit or it is determined that the retrieval result is empty;
[0118] d3. Hash encrypting the decimal part of the upper limit value to obtain upper limit value decimal encrypted data, and performing data retrieval in the decimal ciphertext subsequence corresponding to the any integer ciphertext according to the upper limit value decimal encrypted data, if any decimal ciphertext in the decimal ciphertext subsequence is hit, then obtaining the upper limit retrieval result matched with the upper limit value, if not, performing decreasing approximation retrieval processing on the decimal part of the upper limit value until any decimal ciphertext in the decimal ciphertext subsequence is hit or it is determined that the retrieval result is empty.
[0119] In step d2 of the embodiment, the decreasing approximation retrieval processing on the integer part of the upper limit value until any integer ciphertext in the ciphertext index is hit or it is determined that the retrieval result is empty includes:
[0120] decreasingly calculating the integer part of the upper limit value to obtain a decreasing calculation result, and when the decreasing calculation result is less than the lower limit value, hash encrypting the decreasing calculation result to obtain decreasing encrypted data;
[0121] performing data retrieval in the ciphertext index according to the decreasing encrypted data, if any integer ciphertext in the ciphertext index is hit, then entering step d3, if not, again decreasingly calculating the integer part of the upper limit value until any integer ciphertext in the ciphertext index is hit, or it is determined that the retrieval result is empty when the decreasing calculation result is not less than the lower limit value;
[0122] In step d3, the decreasing approximation retrieval processing on the decimal part of the upper limit value until any decimal ciphertext in the decimal ciphertext subsequence is hit or it is determined that the retrieval result is empty includes:
[0123] decreasing the decimal part of the upper limit value by one counting unit to obtain decreased data;
[0124] determining whether the decreased data is less than 0;
[0125] If yes, the cumulative reduction data is subjected to hash encryption processing to obtain cumulative reduction encryption data, and data retrieval is performed in the decimal ciphertext subsequence corresponding to the any integer ciphertext according to the cumulative reduction encryption data, if any decimal ciphertext in the decimal ciphertext subsequence is hit, the upper limit retrieval result matching the upper limit value is obtained, if not, the cumulative reduction encryption data is taken as the decimal part of the new upper limit value, and one counting unit is subtracted therefrom;
[0126] If no, the nearest integer less than the cumulative reduction encryption data is taken as the upper limit retrieval result matching the upper limit value or the determination retrieval result is empty. Specifically, in the embodiment, if the cumulative data is not less than 0, the nearest integer less than the cumulative reduction encryption data is taken as the next integer, and it is further determined whether the next integer is less than the lower limit value, if yes, the determination retrieval result is empty, otherwise, the next integer is taken as the upper limit retrieval result matching the upper limit value.
[0127] As an example, if the ciphertext index corresponds to the plaintext as follows:
[0128] 2.1, 2.3, 2.5, 3, 3.1, 3.2, 3.5, 4, 4.1, 4.2, 5, 6.2, 6.3;
[0129] When the data type of the retrieval keyword is numerical value type data, the retrieval keyword is range value data, and the lower limit value of the retrieval keyword is 2.6 and the upper limit value is 6.1, the decimal part of the upper limit value 6.1 is subjected to decrement approximation retrieval processing, and there is no 0.1 matching in 6.2 and 6.3 decimals of the ciphertext index, at this time, 5 in the ciphertext index is taken as the upper limit retrieval result matching the upper limit value 6.1, and all data greater than or equal to 3 and less than or equal to 5 in the ciphertext index can be obtained as hit data based thereon.
[0130] The embodiment has small resource consumption and high retrieval efficiency in data retrieval. Specifically, when data retrieval is performed based on the ciphertext index, the retrieval keyword in the retrieval request only needs to be subjected to hash encryption processing to obtain a keyword ciphertext, and data retrieval is performed in the ciphertext index according to the keyword ciphertext, so as to obtain the retrieval result. In this process, the embodiment only needs to perform encryption calculation on the keyword by using the hash encryption algorithm, and performs data retrieval in the ciphertext index by using the keyword ciphertext obtained by encryption, so as to reduce unnecessary complex operation under the premise of ensuring security, significantly reduce the calculation steps and resource consumption, and has high retrieval efficiency.
[0131] Embodiment 4:
[0132] The embodiment discloses a data retrieval system for implementing the data retrieval method in embodiment 3; the data retrieval system comprises:
[0133] a request receiving module, configured to receive a search request with a search keyword bound thereto; wherein the search keyword is character type data or numerical value type data;
[0134] a data searching module, in communication connection with the request receiving module, configured to perform hash encryption processing on the search keyword to obtain keyword ciphertext, and perform data searching in the ciphertext index according to the keyword ciphertext, so as to obtain a search result.
[0135] It should be noted that the working process, working details and technical effects of the data searching system provided in this embodiment 4 can be referred to the embodiment 3, and will not be described here again.
[0136] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, but not to limit it; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can still be modified, or some technical features can be replaced by equivalents. The modification or replacement does not make the essence of the corresponding technical solution deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for constructing a ciphertext index, characterized in that, include: Receive raw data and perform interpolation sorting on the raw data according to the data type of the raw data to obtain an initial index; wherein, the raw data includes character data and numeric data, and the initial index includes a character initial index corresponding to the character data and a numeric initial index corresponding to the numeric data; The original data in the initial index is hashed and encrypted, and then the original data in the initial index is deleted to obtain a ciphertext index; wherein, the index branches of the ciphertext index include a character ciphertext index corresponding to the character data and a numeric ciphertext index corresponding to the numeric data; When the original data is of character type, the original data undergoes interpolation sorting to obtain an initial index, including: Extract the first letter corresponding to the original data, and then perform interpolation sorting on the original data according to the order of its first letter in a preset character sequence to obtain a character-type initial index; When the original data is of numerical data type, interpolation sorting is performed on the original data to obtain an initial index, including: Extract the integer and fractional parts of the original data; The integer part of the original data is inserted into a preset ordered integer sequence in order of size, and the decimal part of the original data is inserted into the decimal subsequence corresponding to the integer part of the original data in order of size, thus obtaining a numerical initial index.
2. The method for constructing a ciphertext index according to claim 1, characterized in that, The original data in the initial index is hashed and encrypted, including: Obtain the interference factor, and concatenate the original data in the initial index with the interference factor to obtain the concatenated data; The concatenated data is hashed and encrypted to obtain the index ciphertext corresponding to the original data in the initial index.
3. A data retrieval method, characterized in that, include: Receive a search request bound with search keywords; wherein, the search keywords are character data or numerical data; The search keywords are hashed and encrypted to obtain keyword ciphertext. Data is then retrieved from the ciphertext index based on the keyword ciphertext to obtain search results. When the data type of the search keyword is character data, the keyword ciphertext includes encrypted character data; correspondingly, performing hash encryption on the search keyword to obtain keyword ciphertext includes: performing hash encryption on the search keyword to obtain encrypted character data; When the data type of the search keyword is numeric data, and the search keyword is single-value data, the keyword ciphertext includes integer encrypted data and decimal encrypted data; correspondingly, the search keyword is hash-encrypted to obtain keyword ciphertext, and data is retrieved within the ciphertext index based on the keyword ciphertext to obtain search results, including: Extract the integer and decimal parts of the search keywords; The integer part of the search keyword is hashed and encrypted to obtain encrypted integer data. Data is then retrieved within the ciphertext index based on the encrypted integer data. If any integer ciphertext in the ciphertext index is matched, the process proceeds to the next step. If no match is found, the search result is determined to be empty. The decimal part of the search keyword is hashed and encrypted to obtain decimal encrypted data. Data retrieval is performed within the decimal encrypted subsequence corresponding to any integer ciphertext based on the decimal encrypted data. If any decimal ciphertext in the decimal encrypted subsequence is matched, the ciphertext retrieval result matching the search keyword is obtained. If no match is found, the retrieval result is determined to be empty.
4. The data retrieval method according to claim 3, characterized in that, When the data type of the search keyword is numeric data and the search keyword is a range value data, the search keyword is hashed and encrypted to obtain keyword ciphertext. Data is then retrieved within the ciphertext index based on the keyword ciphertext to obtain search results, including: The lower limit value of the search keyword is hashed and encrypted to obtain the encrypted lower limit value. Data is then retrieved within the ciphertext index based on the encrypted lower limit value to obtain the lower limit search results. The upper limit value of the search keyword is hashed and encrypted to obtain the encrypted upper limit value. Data is then retrieved within the ciphertext index based on the encrypted upper limit value to obtain the upper limit search result. The data in the encrypted index that lies between the lower limit search result and the upper limit search result is used as the search result.
5. The data retrieval method according to claim 4, characterized in that, The encrypted lower limit value includes encrypted integer data and encrypted decimal data. Correspondingly, the lower limit value of the search keyword is hashed to obtain the encrypted lower limit value, and data is retrieved within the ciphertext index based on the encrypted lower limit value to obtain the lower limit search results, including: c1. Extract the integer and decimal parts of the lower limit value from the search keywords; c2. Perform hash encryption on the integer part of the lower limit value to obtain encrypted data of the lower limit value integer, and perform data retrieval in the ciphertext index based on the encrypted data of the lower limit value integer. If any integer ciphertext in the ciphertext index is hit, proceed to step c3. If no hit is found, perform incremental approximation retrieval on the integer part of the lower limit value until any integer ciphertext in the ciphertext index is hit or the retrieval result is determined to be empty. c3. Perform hash encryption on the decimal part of the lower limit value to obtain the lower limit value decimal encrypted data, and perform data retrieval in the decimal ciphertext subsequence corresponding to any integer ciphertext based on the lower limit value decimal encrypted data. If any decimal ciphertext in the decimal ciphertext subsequence is matched, a lower limit retrieval result matching the lower limit value is obtained. If no match is found, perform incremental approximation retrieval on the decimal part of the lower limit value until any decimal ciphertext in the decimal ciphertext subsequence is matched or the retrieval result is determined to be empty.
6. The data retrieval method according to claim 5, characterized in that, In step c2, an incremental approximation search is performed on the integer part of the lower limit value until any integer ciphertext of the ciphertext index is hit or the search result is determined to be empty, including: Incremental calculation is performed on the integer part of the lower limit value to obtain the incremental calculation result. When the incremental calculation result is less than the upper limit value, the incremental calculation result is hashed and encrypted to obtain incremental encrypted data. Data retrieval is performed within the ciphertext index based on the incremental encrypted data. If any integer ciphertext in the ciphertext index is matched, proceed to step c3. If not matched, the integer part of the lower limit value is incrementally calculated again until any integer ciphertext in the ciphertext index is matched, or the retrieval result is determined to be empty when the incremental calculation result is not less than the upper limit value. In step c3, an incremental approximation search is performed on the decimal part of the lower limit value until any decimal ciphertext in the decimal ciphertext subsequence is hit or the search result is determined to be empty, including: Add a counting unit to the decimal part of the lower limit value to obtain the accumulated data; Determine whether the accumulated data is less than 1; If so, the accumulated data is hashed and encrypted to obtain accumulated encrypted data. Then, data is retrieved in the fractional ciphertext subsequence corresponding to any integer ciphertext based on the accumulated encrypted data. If any fractional ciphertext in the fractional ciphertext subsequence is matched, a lower limit retrieval result matching the lower limit value is obtained. If no match is found, the accumulated data is used as the fractional part of the new lower limit value, and a counting unit is added to it. If not, then the nearest integer greater than the accumulated data is taken as the lower limit retrieval result that matches the lower limit value, or the retrieval result is determined to be empty.
7. The data retrieval method according to claim 4, characterized in that, The encrypted upper limit value includes encrypted integer data and encrypted decimal data. Correspondingly, the upper limit value of the search keyword is hashed to obtain the encrypted upper limit value, and data is retrieved within the ciphertext index based on the encrypted upper limit value to obtain the upper limit retrieval result, including: d1. Extract the integer and decimal parts of the upper limit value from the search keywords; d2. Perform hash encryption on the integer part of the upper limit value to obtain encrypted data of the upper limit value integer. Then, perform data retrieval in the ciphertext index based on the encrypted data of the upper limit value integer. If any integer ciphertext in the ciphertext index is matched, proceed to step d3. If no match is found, perform a decreasing approximation retrieval on the integer part of the upper limit value until any integer ciphertext in the ciphertext index is matched or the retrieval result is determined to be empty. d3. Perform hash encryption on the decimal part of the upper limit value to obtain encrypted decimal data of the upper limit value, and perform data retrieval in the decimal ciphertext subsequence corresponding to any integer ciphertext based on the encrypted decimal data of the upper limit value. If any decimal ciphertext in the decimal ciphertext subsequence is matched, the upper limit retrieval result matching the upper limit value is obtained. If no match is found, perform a decreasing approximation retrieval on the decimal part of the upper limit value until any decimal ciphertext in the decimal ciphertext subsequence is matched or the retrieval result is determined to be empty.
8. A data retrieval method according to claim 7, characterized in that, In step d2, a decreasing approximation search is performed on the integer part of the upper limit value until any integer ciphertext of the ciphertext index is hit or the search result is determined to be empty, including: The integer part of the upper limit value is calculated by decreasing to obtain the decreasing calculation result. When the decreasing calculation result is less than the lower limit value, the decreasing calculation result is hashed and encrypted to obtain decreasing encrypted data. Data retrieval is performed within the ciphertext index based on the decreasing encrypted data. If any integer ciphertext in the ciphertext index is matched, proceed to step d3. If not matched, the integer part of the upper limit value is calculated decreasing again until any integer ciphertext in the ciphertext index is matched, or the retrieval result is determined to be empty when the decreasing calculation result is not less than the lower limit value. In step d3, a decreasing approximation search is performed on the decimal part of the upper limit value until any decimal ciphertext in the decimal ciphertext subsequence is hit or the search result is determined to be empty, including: Subtract one counting unit from the decimal part of the upper limit value to obtain the cumulatively subtracted data; Determine whether the accumulated subtraction data is less than 0; If so, the accumulated data is hashed and encrypted to obtain accumulated encrypted data. Then, data is retrieved in the fractional ciphertext subsequence corresponding to any integer ciphertext based on the accumulated encrypted data. If any fractional ciphertext in the fractional ciphertext subsequence is matched, the upper limit retrieval result matching the upper limit value is obtained. If no match is found, the accumulated encrypted data is used as the fractional part of the new upper limit value and one count unit is decremented from it. If not, then the nearest integer less than the cumulative encrypted data is taken as the upper limit retrieval result that matches the upper limit value, or the retrieval result is determined to be empty.
Citation Information
Patent Citations
Keyword hiding and tracing query method and device based on homomorphic encryption
CN116756185A