A ciphertext database JOIN operation method based on homomorphic encryption
By adopting the JOIN operation method of extended padding and cyclic padding in the homomorphic encryption database, the problems of large number of ciphertext comparisons and low computational efficiency are solved, efficient and secure data association is achieved, and resource consumption is reduced.
Patent Information
- Application Number
- CN202411874735.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2044-12-19
AI Technical Summary
In homomorphic encryption databases, traditional JOIN operation methods have problems such as excessive ciphertext comparisons, low computational efficiency, and high resource consumption, making it difficult to efficiently associate data in an encrypted environment.
A JOIN operation method based on homomorphic encryption is adopted. Through the extended filling and cyclic filling of the plaintext vector, combined with the use of left-rotation keys, the number of ciphertext comparisons is reduced, the operation efficiency is improved, and the storage overhead is reduced.
It achieves efficient data association in homomorphic encrypted databases, reduces computing time and space storage costs, while ensuring data security and privacy.
Smart Images

Figure CN119830319B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of ciphertext data processing, and more particularly to a ciphertext database JOIN operation method based on homomorphic encryption. Background Art
[0002] The JOIN algorithm plays a key role in database systems, establishing relationships between tables and merging data based on specified conditions. This operation is widely used in routine data queries and analysis in 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 loop joins are suitable for small data sets, performing a row-by-row traversal to achieve matching; sort-merge joins sort data first and are suitable for large data tables; hash joins construct hash tables for fast lookups and are particularly effective for equal-value joins. The database's query optimizer selects the optimal JOIN strategy based on characteristics such as table size, data distribution, and the presence of indexes, improving 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 JOINs in homomorphically encrypted databases presents new technical challenges, as 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-merge, and hash joins) are difficult to apply directly in encrypted environments. This has led to the emergence of new JOIN implementations. Systems such as HerreDB overcome these limitations by combining innovative techniques such as homomorphic operations, batch processing, symbolic functions, and modular operations.
[0004] But at the same time, the implementation of JOIN in a homomorphically encrypted database 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 perform JOIN operations directly in an encrypted state, avoiding the privacy risks of decrypting the data before processing; second, 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, sign functions and modular operations ensure the accuracy of ciphertext data during matching and screening, and are particularly suitable for scenarios such as large integers and floating-point numbers that require precise control of boundaries. Therefore, in a homomorphically encrypted 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 querying.
[0005] By utilizing innovative encrypted data processing technology, the JOIN method effectively supports complex data queries and associations within encrypted databases, laying a solid foundation for the practical application of encrypted data. This implementation is of great significance for privacy protection in cloud and distributed databases, providing businesses and users with a database solution that combines security, efficiency, and functionality.
[0006] However, traditional JOIN operation methods have the following shortcomings in homomorphic encryption databases: 1. Excessive ciphertext comparisons: Traditional JOIN implementations typically use Cartesian products to construct all possible combinations and perform ciphertext comparisons on each pair of data items, resulting 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 computing time; 3. High resource consumption: The high computational complexity leads to 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 solutions:
[0009] A ciphertext database JOIN operation method based on homomorphic encryption includes the following steps:
[0010] S1. For the two plaintext vectors to be compared, determine whether extension padding is required based on the plaintext slot size and plaintext information length;
[0011] S2. Circularly pad and encrypt the original plaintext vector or the expanded plaintext vector;
[0012] S3. Compare 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 of the two plaintext vectors to be compared is expanded to 2 k Position, that is, Where 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 fixed slots, specifically including:
[0017] Assume that 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-built left-rotation key k L_1 , obtain the ciphertext vector after one step of left rotation, and after repeating it a certain number of times, realize the full comparison of the two ciphertext vectors.
[0022] Furthermore, in S5, the process of determining the number of comparisons required between 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 cyclic 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 expansion and padding, N+MOD(S max ,N) and The size of Then perform extended filling, otherwise perform circular filling 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, all other vector comparison and rotation operations are always performed under fully homomorphic ciphertext. In other words, 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, this method uses cyclic padding to maximize the information density of the encrypted ciphertext vector, reducing the number of comparisons. Rotational comparisons also enable multiple results from a single comparison. Only one encryption operation is required for each of the two plaintext vectors, significantly improving computational efficiency. Furthermore, extended padding for shorter vectors is proposed, enabling even higher JOIN computation efficiency for certain plaintext lengths.
[0030] 3. Low storage overhead: The present invention only requires 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 following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0032] Figure 1 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 rotation comparison diagram provided by the present invention. DETAILED DESCRIPTION
[0035] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. 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 making creative efforts 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 the two plaintext vectors to be compared, determine whether extension padding is required based on the plaintext slot size and plaintext information length;
[0038] S2. Circularly pad and encrypt the original plaintext vector or the expanded plaintext vector;
[0039] S3. Compare 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 cyclic filling can also achieve a smaller number of comparisons, in order to further reduce the number of comparisons required for cyclic filling in some cases, the present invention takes advantage of the fact that the second plaintext vector is shorter and provides an additional extended filling method, that is, to expand the length of the shorter plaintext vector 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 padding. If the length of the shorter plaintext vector is divisible by the fixed slot, no padding is required 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. Assume N = 5, then 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 cyclic 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 that 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 cyclically, that is, the length of the vector is padded 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, directly comparing ciphertext vectors is very inefficient, requiring many comparisons to achieve a complete comparison. On the one hand, through cyclic padding, the elements in the second vector appear in multiple complete cycles, making a single comparison equivalent to comparing multiple data points in the first vector, significantly reducing the total number of ciphertext comparisons. On the other hand, because the length of the slots is the same, the encrypted ciphertext length of longer and shorter plaintexts is the same, which increases the information density of the ciphertext vector, allowing more information to be obtained in a single comparison.
[0053] S3. Ciphertext vector comparison operations based on fully homomorphic encryption can be implemented using 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, if you want to achieve full comparison, you only need to rotate one of the vectors continuously. L_1, you only need to multiply the second ciphertext vector by k after each comparison L_1 , we obtain the ciphertext vector corresponding to the plaintext data vector after a single left rotation. Repeating this operation a certain number of times allows a full comparison of the two data vectors. This ensures that the full comparison process does not require reconstructing the vector or repeating the encryption and decryption process of the plaintext vector, significantly reducing time and space overhead. Furthermore, combined with the loop padding in the previous step, each comparison can simultaneously compare multiple vector elements, further improving efficiency. Furthermore, this rotation operation replaces the construction of a new vector, significantly reducing storage space costs.
[0056] like Figure 3 As shown in the figure, all data should be ciphertext data. For ease of understanding, the corresponding plaintext vectors are shown. Figure 3 (a) shows the result of the first comparison after cyclic padding, and (b) shows the comparison result after one rotation using the 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 between the two plaintext vectors includes:
[0058] Since the length of the second plaintext data vector is generally short (i.e., satisfying 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 cyclic comparisons required is: N+MOD(S max ,N);
[0060] Otherwise, the number of comparisons required is: N.
[0061] 2. In fact, in most cases, there are 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 filling the plain text, it is necessary to compare and calculate: N+MOD(S max ,N) and This is used to determine whether expansion filling is needed. If Then perform extended filling, otherwise perform circular filling directly.
[0063] Overall, this paper focuses on implementing a JOIN method for fixed-slot data vectors in a homomorphically encrypted database. It does not specifically require or describe underlying algorithms such as ciphertext vector comparison or rotation. Actual implementation may be affected by the specific homomorphically encrypted database architecture and implementation. Therefore, the focus of this method is on minimizing the time cost of performing a JOIN method on fixed-slot encrypted data vectors.
[0064] The following is an example of how the present invention reduces the number of loop comparisons by using extended padding.
[0065] Assume that 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 directly perform loop filling, 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] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Reference can be made to the common and similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method description.
[0069] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily 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 is not limited to the embodiments shown herein but is intended to conform 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 the two plaintext vectors to be compared, determine whether extension padding is required based on the plaintext slot size and plaintext information length; In the two plaintext vectors to be compared, the length of the shorter plaintext vector is expanded to 2 k bit, that is, N ' =2 k >N,k=1,2,…, Where N represents the original length of the shorter plaintext vector, N ' Represents the length of a shorter plaintext vector after expansion and padding. The slot size is a positive power of 2. Before performing plaintext expansion and filling, compare and calculate N+MOD(S max ,N) and The size of Then perform extended filling, otherwise perform circular filling directly; S2. Circularly pad and encrypt the original plaintext vector or the expanded plaintext vector; S3. Compare 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 certain number of steps, it means that there is no matching data in the two vectors; The process of determining the number of comparisons required between 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 cyclic comparisons required is: N+MOD(S max ,N); Otherwise, the number of comparisons required is: N; Among them, S max represents the number of slots, and M represents the length of the longer plaintext vector.
2. The ciphertext database JOIN operation method based on homomorphic encryption according to claim 1 is characterized in that: In S2, the two plaintext vectors are cyclically filled based on fixed slots, specifically including: Assume that 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.
3. The ciphertext database JOIN operation method based on homomorphic encryption according to claim 2 is characterized in that: 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.
4. 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-built left-rotation key k L_1 , obtain the ciphertext vector after one step of left rotation, and after repeating it a certain number of times, realize the full comparison of the two ciphertext vectors.
5. The ciphertext database JOIN operation method based on homomorphic encryption according to claim 1 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:
Citation Information
Patent Citations
Ciphertext feature matching method and system based on fully homomorphic encryption and composite polynomial
CN118381598A
Encrypting method and decrypting method
JP2009175544A
Cited By
Offline file automatic encryption synchronization method and system
CN121723491A