Ciphertext database JOIN operation method based on homomorphic encryption
By adopting parallel operation and batch algorithms in homomorphic encrypted databases, combined with the JOIN operation method of loop filling and left-hand comparison technology, the problems of low efficiency and high resource consumption in the homomorphic encrypted database are solved, and efficient and secure ciphertext database JOIN operation is achieved.
Patent Information
- Application Number
- CN202411874735.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2044-12-19
AI Technical Summary
In homomorphic encrypted databases, traditional JOIN operation methods have problems such as excessive ciphertext comparisons, low computing efficiency and large resource consumption, making it difficult to apply to the processing of large data sets.
The JOIN operation method of ciphertext database based on homomorphic encryption is adopted, and the cyclic filling and left-hand comparison technology is used to reduce the number of ciphertext comparisons and improve the calculation efficiency through parallel computing and batch processing algorithms.
It significantly improves the efficiency of JOIN operation, reduces time overhead and space storage costs, and ensures the security and efficiency of ciphertext database data.
Smart Images

Figure CN119830319A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of ciphertext data processing, and more specifically to a ciphertext database JOIN operation method based on homomorphic encryption. Background Art
[0002] The JOIN algorithm plays a key role in database systems. It is used to establish relationships between different tables and merge data according to specified conditions. This operation is widely used in daily data query and analysis of relational databases. In traditional databases, the JOIN algorithm automatically selects the optimal implementation strategy based on data characteristics and query requirements. Common JOIN methods include nested loop joins, sort merge joins, and hash joins. Nested loops are suitable for small data sets and achieve matching by traversing row by row; sort merge sorts the data first and is suitable for tables with large data volumes; hash join builds a hash table for fast search and is particularly efficient for equal value join scenarios. The database query optimizer selects the best JOIN strategy based on table size, data distribution, whether there are indexes, and other characteristics to improve query efficiency. In big data and distributed environments, JOIN operations are combined with parallel processing and data partitioning to fully utilize the computing power of multi-core processors and distributed nodes.
[0003] However, implementing JOIN methods in homomorphic encrypted databases faces new technical challenges because fields cannot be directly compared or matched when the data is encrypted. Homomorphic encryption allows basic operations to be performed on data in ciphertext, but because ciphertext cannot be directly read or compared, traditional JOIN implementations (such as nested loops, sort merges, and hash joins) are difficult to apply directly in an encrypted environment. This has given rise to new JOIN implementations, such as HerreDB, which overcomes the limitations in encrypted environments by combining innovative technologies such as homomorphic operations, batch processing, symbolic functions, and modular operations.
[0004] But at the same time, the implementation of JOIN in homomorphic encryption databases is particularly important because it ensures privacy and security when processing data in the cloud or in an untrusted environment. First, homomorphic encryption enables the database to directly perform JOIN operations in an encrypted state, avoiding the privacy risks of decrypting the data before processing; secondly, batch processing technology improves the parallelism and efficiency of JOIN operations by processing multiple ciphertext data simultaneously, reducing the computational overhead of traditional JOIN operations in an encrypted environment. In addition, symbolic functions and modular operations ensure the accuracy of ciphertext data during matching and screening, which is particularly suitable for scenarios such as large integers and floating-point numbers that require precise control of boundaries. Therefore, in a homomorphic encryption database, the JOIN operation is not only a basic operation for building data associations, but also a core technology for ensuring data privacy and efficient query.
[0005] By using innovative encrypted data processing technology, the JOIN method effectively supports complex data query and association requirements in encrypted databases, laying a solid foundation for the practical application of encrypted data. Such an implementation is of great significance to privacy protection in cloud databases and distributed databases, and provides enterprises and users with a database solution that combines security, efficiency and functionality.
[0006] However, the traditional JOIN operation method has the following disadvantages in homomorphic encryption databases: 1. Too many ciphertext comparisons: Traditional JOIN implementations usually use Cartesian products to construct all possible combinations and perform ciphertext comparisons on each pair of data items, which results in an exponential increase in the number of comparisons and extremely high computational overhead; 2. Low computational efficiency: In the encrypted state, data cannot be directly read and indexed, and each comparison requires homomorphic operations, which greatly increases the computing time; 3. High resource consumption: High computational complexity brings additional storage and processing resource consumption, making traditional JOIN difficult to apply when processing large data sets in encrypted databases. Summary of the invention
[0007] In view of this, the present invention provides a ciphertext database JOIN operation method based on homomorphic encryption, which significantly improves the JOIN operation efficiency, reduces time overhead, and reduces space storage costs with the support of parallel computing and batch processing algorithms.
[0008] In order to achieve the above object, the present invention adopts the following technical solution:
[0009] A ciphertext database JOIN operation method based on homomorphic encryption includes the following steps:
[0010] S1. For two plaintext vectors to be compared, determine whether extension padding is required based on the plaintext slot size and plaintext information length;
[0011] S2, cyclically filling and encrypting the original plaintext vector or the expanded plaintext vector;
[0012] S3, performing a comparison operation on the two encrypted ciphertext vectors;
[0013] S4: If the correct result is obtained, output it, otherwise perform a left rotation on the shorter vector and repeat S3;
[0014] S5. If no result is obtained after repeating a specific number of steps, it means that there is no matching data in the two vectors.
[0015] Furthermore, in S1, the length of the shorter plaintext vector is expanded to 2. k Position, that is, Wherein, N represents the original length of the shorter plaintext vector, and N' represents the length of the shorter plaintext vector after expansion and padding.
[0016] Furthermore, in S2, the two plaintext vectors are cyclically filled based on the fixed slots, specifically including:
[0017] Assume the number of slots is S max , the lengths of the two plaintext vectors to be compared are M and N respectively, and there exists
[0018] The remaining slots of the two plaintext vectors are filled cyclically until the length reaches S max , if the length of the plaintext vector itself has reached S max , no filling is performed;
[0019] The two plaintext vectors after cyclic padding are encrypted into ciphertext vectors respectively.
[0020] Furthermore, in S2, when the remaining slots of the two plaintext vectors are cyclically filled, the end of the vector is padded according to the original order of the vector elements.
[0021] Furthermore, in S4, after each comparison, the corresponding ciphertext vector after the shorter plaintext vector is cyclically padded is multiplied by the pre-constructed left-hand key k L_1 , obtain the ciphertext vector after one step of left rotation, and after repeating it a certain number of times, a full comparison of the two ciphertext vectors is achieved.
[0022] Furthermore, in S5, the process of determining the number of comparisons required for two plaintext vectors includes:
[0023] The longer plaintext vector is used as the first plaintext vector, and the shorter plaintext vector is used as the second plaintext vector. That is, the first plaintext vector does not completely fill a sequence, and the filling length is less than the length of the second plaintext vector. At the same time, when there is no multiple relationship between the two plaintext vectors, the number of loop comparisons required is: N+MOD(S max ,N);
[0024] Otherwise, the number of comparisons required is: N.
[0025] Furthermore, when the shorter plaintext vector is expanded and padded, its length is N'=2 k , k=1,2,…, then MOD(S max ,N')=0, the number of comparisons is always:
[0026] Furthermore, in S1, before performing plaintext extension padding, N+MOD(S max ,N) and The size of If yes, then extended filling is performed, otherwise circular filling is performed directly.
[0027] It can be seen from the above technical solutions that, compared with the prior art, the present invention has the following beneficial effects:
[0028] 1. Operational security: In addition to the need for pre-plaintext padding, other vector comparisons and rotation operations are always performed under fully homomorphic ciphertext. That is to say, all JOIN processes are completed under fully homomorphic encryption, ensuring the security of the ciphertext database data.
[0029] 2. High computational efficiency: Based on fixed slots, the present invention uses cyclic filling to make the encrypted ciphertext vector obtain the highest possible information density to reduce the number of comparisons. It also achieves the effect of obtaining multiple results in a single comparison through rotation comparison. At the same time, only one encryption operation is required for each of the two plaintext vectors, which significantly improves the computational efficiency. At the same time, it further proposes to extend and fill shorter vectors, so that higher JOIN computational efficiency can be achieved under certain specific plaintext lengths.
[0030] 3. Low storage overhead: The space required by the present invention is only two ciphertext vectors, a rotation key and a comparison result vector. There is no need to construct vectors multiple times, which greatly reduces storage overhead and processing resource consumption. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0032] Figure 1 A flowchart of the ciphertext database JOIN operation method based on homomorphic encryption provided by the present invention;
[0033] Figure 2 A demonstration diagram of plaintext vector filling provided by the present invention;
[0034] Figure 3 This is a schematic diagram of rotation comparison provided by the present invention. DETAILED DESCRIPTION
[0035] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0036] like Figure 1 As shown, the embodiment of the present invention discloses a ciphertext database JOIN operation method based on homomorphic encryption, comprising the following steps:
[0037] S1. For two plaintext vectors to be compared, determine whether extension padding is required based on the plaintext slot size and plaintext information length;
[0038] S2, cyclically filling and encrypting the original plaintext vector or the expanded plaintext vector;
[0039] S3, performing a comparison operation on the two encrypted ciphertext vectors;
[0040] S4: If the correct result is obtained, output it, otherwise perform a left rotation on the shorter vector and repeat S3;
[0041] S5. If no result is obtained after repeating a specific number of steps, it means that there is no matching data in the two vectors.
[0042] The above steps are further explained below.
[0043] S1. Although only using circular filling can also achieve a smaller number of comparisons, in order to further reduce the number of comparisons required for circular filling in some cases, the present invention uses the characteristic that the second plaintext vector is shorter and additionally provides an extended filling method, that is, the length of the shorter plaintext vector is extended and filled to 2. k Position, that is, Where N represents the original length of the second plaintext vector, and N' represents the length of the second plaintext vector after expansion and padding. If the length of the shorter plaintext vector is divisible by the fixed slot, there is no need to perform expansion and padding, and circular padding can be performed directly.
[0044] Generally speaking, the slot size is a positive power of 2, so when k is a positive integer, 2 k It is a factor of the slot size, which means it is just filled after a certain number of cycles.
[0045] Regarding the calculation of N', log2N needs to be rounded up. Assuming N = 5, log2N is 2.x, which is rounded up to 3, so N' = 2 3 =8.
[0046] Afterwards, the new plaintext vector is used to complete the loop filling of the subsequent steps. This filling method can achieve fewer rotation comparisons in some cases, thereby achieving better results.
[0047] S2: Circularly fill the two plaintext vectors based on fixed slots, specifically including:
[0048] Assume the number of slots is S max , the lengths of the two plaintext vectors to be compared are M and N respectively, and there exists
[0049] The remaining slots of the two plaintext vectors are filled in a loop, that is, the vectors are lengthened in the order of the original vector elements at the end until the length reaches S max , if the length of the plaintext vector itself has reached S max , no filling is performed;
[0050] The two plaintext vectors after cyclic padding are encrypted into ciphertext vectors respectively.
[0051] like Figure 2 As shown, taking 32 slots as an example, Figure 2 (a) represents the shorter original plaintext vector, (b) represents the plaintext vector after direct cyclic padding, (c) represents the plaintext vector after extended padding, and (d) represents the plaintext vector after extended padding and then cyclic padding.
[0052] Since the cost of comparing a single ciphertext vector is high, and in general: Therefore, the method of directly comparing ciphertext vectors is very inefficient, and many comparisons are required to achieve a full comparison. On the one hand, through loop filling, multiple complete loops appear in the elements of the second vector, which is equivalent to comparing with multiple data in the first vector at the same time in one comparison, greatly reducing the total number of ciphertext comparisons. On the other hand, due to the restriction of equal length slots, the encrypted ciphertext length of longer plaintext and shorter plaintext is the same, which also improves the information density of the ciphertext vector, and more information can be obtained in a single comparison operation.
[0053] S3. Ciphertext vector comparison operation based on fully homomorphic encryption can be implemented by element-by-element comparison or hash comparison.
[0054] S4: If the correct result is obtained, output it, otherwise perform a left rotation on the shorter vector and repeat S3;
[0055] Since the two data vectors are now equal in length due to the circular filling performed previously, if full comparison is to be achieved, only one of the vectors needs to be rotated continuously. L_1, you only need to multiply the second ciphertext vector by k after each comparison L_1 , you can get the ciphertext vector corresponding to the plaintext data vector after one step of left rotation. After repeating this a certain number of times, you can achieve a full comparison of the two data vectors. This ensures that there is no need to rebuild the vector or repeat the encryption and decryption process of the plaintext vector during the full comparison, which greatly reduces time and space overhead. At the same time, combined with the loop filling in the previous step, each comparison can compare multiple vector elements at the same time, further improving efficiency. At the same time, this rotation operation replaces the construction of a new vector, greatly reducing the cost of space storage.
[0056] like Figure 3 As shown in the figure, all data should be ciphertext data. For ease of understanding, the corresponding plaintext vector is shown. Figure 3 (a) shows the result of the first comparison after cyclic padding, and (b) shows the comparison result after one rotation using a one-step left rotation key.
[0057] S5. After a certain number of repetitions, a full comparison of the two ciphertext vectors can be achieved (i.e., every element in one vector is compared with the elements in the other vector). The process of determining the number of comparisons required for the two plaintext vectors includes:
[0058] Since the length of the second plaintext data vector is generally shorter (i.e., it satisfies M>>N), we will only discuss the cases with different M sizes:
[0059] 1. Take the longer plaintext vector as the first plaintext vector and the shorter plaintext vector as the second plaintext vector. That is, the first plaintext vector does not completely fill a sequence, and the filling length is less than the length of the second plaintext vector. At the same time, when there is no multiple relationship between the two plaintext vectors, the number of loop comparisons required is: N+MOD(S max ,N);
[0060] Otherwise, the number of comparisons required is: N.
[0061] 2. In fact, in most cases, Therefore, the number of comparisons required is: N+MOD(S max ,N), it is worth mentioning that when using extended padding, let N = N', since N' = 2 k , k=1,2,…, then MOD(S max ,N')=0, so the number of comparisons is always:
[0062] Before plain text padding, it is necessary to compare and calculate: N+MOD(S max ,N) and This is used to determine whether expansion filling is needed. If yes, then extended filling is performed, otherwise circular filling is performed directly.
[0063] In general, the present invention focuses on implementing the JOIN method for fixed-slot data vectors in homomorphic encryption databases. It does not specifically require or describe basic algorithms such as specific ciphertext vector comparison or rotation. The actual use may be affected by the specific homomorphic encryption database architecture and implementation method. Therefore, the focus of this method is how to obtain the least possible time cost when performing the JOIN method on fixed-slot encrypted data vectors.
[0064] The following is an example of reducing the number of loop comparisons by using extended padding in the present invention.
[0065] Assumption: the number of plaintext slots is 1024, the length of the first plaintext vector is 1020, and the length of the second plaintext vector is 15.
[0066] Because of satisfaction If you want to perform loop filling directly, you need to compare N+MOD(S max ,N)=15+4=19 times.
[0067] If the extension padding is performed first, the length after padding is: Therefore, only 16 comparisons are required.
[0068] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0069] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A ciphertext database JOIN operation method based on homomorphic encryption, characterized in that: The following steps are involved: S1. For two plaintext vectors to be compared, determine whether extension padding is required based on the plaintext slot size and plaintext information length; S2, cyclically filling and encrypting the original plaintext vector or the expanded plaintext vector; S3, performing a comparison operation on the two encrypted ciphertext vectors; S4: If the correct result is obtained, output it, otherwise perform a left rotation on the shorter vector and repeat S3; S5. If no result is obtained after repeating a specific number of steps, it means that there is no matching data in the two vectors.
2. According to the ciphertext database JOIN operation method based on homomorphic encryption according to claim 1, it is characterized in that: In S1, of the two plaintext vectors to be compared, the length of the shorter plaintext vector is expanded to 2. k bits, that is, let N'=2 k >N,k=1,2,…, Wherein, N represents the original length of the shorter plaintext vector, and N' represents the length of the shorter plaintext vector after expansion and padding.
3. According to the ciphertext database JOIN operation method based on homomorphic encryption according to claim 1, it is characterized in that: In S2, two plaintext vectors are cyclically filled based on fixed slots, including: Assume the number of slots is S max , the lengths of the two plaintext vectors to be compared are M and N respectively, and there exists The remaining slots of the two plaintext vectors are filled cyclically until the length reaches S max , if the length of the plaintext vector itself has reached S max , no filling is performed; The two plaintext vectors after cyclic padding are encrypted into ciphertext vectors respectively.
4. According to claim 3, the ciphertext database JOIN operation method based on homomorphic encryption is characterized in that: In S2, when the remaining slots of the two plaintext vectors are cyclically filled, the vectors are padded at the end according to the original order of the vector elements.
5. The ciphertext database JOIN operation method based on homomorphic encryption according to claim 1 is characterized in that: In S4, after each comparison, the corresponding ciphertext vector after the shorter plaintext vector is cyclically padded is multiplied by the pre-constructed left-hand key k L_1 , obtain the ciphertext vector after one step of left rotation, and after repeating it a certain number of times, a full comparison of the two ciphertext vectors is achieved.
6. The ciphertext database JOIN operation method based on homomorphic encryption according to claim 3 is characterized in that: In S5, the process of determining the number of comparisons required for two plaintext vectors includes: The longer plaintext vector is used as the first plaintext vector, and the shorter plaintext vector is used as the second plaintext vector. That is, the first plaintext vector does not completely fill a sequence, and the filling length is less than the length of the second plaintext vector. At the same time, when there is no multiple relationship between the two plaintext vectors, the number of loop comparisons required is: N+MOD(S max ,N); Otherwise, the number of comparisons required is: N.
7. The ciphertext database JOIN operation method based on homomorphic encryption according to claim 6 is characterized in that: When the shorter plaintext vector is expanded and padded, its length is N'=2 k , k=1,2,…, then MOD(S max ,N')=0, the number of comparisons is always:
8. The ciphertext database JOIN operation method based on homomorphic encryption according to claim 7 is characterized in that: In S1, before performing plaintext extension padding, compare and calculate N+MOD(S max ,N) and The size of If yes, then extended filling is performed, otherwise circular filling is performed directly.
Citation Information
Patent Citations
A searchable public key encryption method supporting inner product operations
CN109325361A
Ciphertext homomorphic comparison method and device based on fully homomorphic encryption
CN116776359A
Plaintext and ciphertext matrix multiplication calculation method based on homomorphic encryption
CN117200972A
Ciphertext feature matching method and system based on fully homomorphic encryption and composite polynomial
CN118381598A
Encrypting method and decrypting method
JP2009175544A