Fully homomorphic comparison method based on tfhe gate bootstrap
By constructing L-CMux gates and using GPU parallel computing, the problems of excessive number of logic gates and serial computation in the TFHE scheme are solved, and an efficient fully homomorphic comparison method is realized.
Patent Information
- Application Number
- CN202310910955.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-24
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2043-07-24
Smart Images

Figure BDA0004355216240000026 
Figure BDA0004355216240000028 
Figure BDA0004355216240000041
Abstract
Description
Technical Field
[0001] This invention relates to the field of toroidal fully homomorphic encryption, specifically a fully homomorphic comparison method based on TFHE gate bootstrapping. Background Technology
[0002] Fully homomorphic encryption (FHE) schemes allow arbitrary computations (primarily addition and multiplication) to encrypted data without decryption. The resulting ciphertext, after decryption, yields the same result as the same computation performed on the unencrypted plaintext. FHE introduces a technique called bootstrapping to refresh ciphertext noise, allowing for further homomorphic computations with less noise. Gate bootstrapping, a type of bootstrapping technique, involves performing a bootstrapping operation after each logic gate operation. Logic gates can be used to implement homomorphic multiplication, addition, and comparison operations. Homomorphic comparison operations are increasingly used in various scenarios and are fundamental to multi-party computation and machine learning.
[0003] In 2019, Liu et al. constructed a single-bit and multi-bit comparator based on the cuFHE library in the paper "Homomorphic Comparison Operator Based on cuFHE[J], Computer Engineering, 2019, 45(09):143-146+152." In this scheme, the homomorphic comparison process requires 5 logic gates, and the single-bit comparison process also takes 10ms. In particular, the multi-bit homomorphic comparison is not fully parallelized, which results in nearly 50% of the time being consumed in serial computation. Summary of the Invention
[0004] To overcome the problems of excessive number of logic gates and serial computation in existing fully homomorphic comparison operations, this invention proposes a fully homomorphic comparison method based on TFHE gate bootstrapping. This method only requires the use of two logic gates and is fully parallelized.
[0005] In the TFHE scheme, the core of the gate bootstrapping algorithm is to perform an outer product operation on the public key composed of the decomposed TRLWE ciphertext and TGSW ciphertext. This step is essentially the computation of the CMux gate. This logic gate uses TRLWE and TRGSW ciphertexts as input and TRLWE ciphertext as output for homomorphic computation. Due to the inconsistency of ciphertexts, existing schemes use a combination of NOT, AND, and XNOR logic gates to implement homomorphic comparison operations. The homomorphic comparison process requires the use of multiple gate combinations, but the combination computation of logic gates limits parallelism and leads to gate waste, resulting in low efficiency for homomorphic comparison. The method of this invention is first designed based on the CMux gate. In order to construct a suitable comparison gate, the TGSW ciphertext in the CMux gate is replaced with TLWE ciphertext, and the TRLWE ciphertext is also replaced with TLWE ciphertext, thereby constructing a homomorphic comparison L-CMux (TLWE-CMux) gate with TLWE ciphertext as both input and output. Then, it is combined with an XOR gate to implement a single-bit homomorphic comparison process. Furthermore, this invention extends the single-bit homomorphic comparison process to arbitrary-bit homomorphic comparison operations by combining and extending it, and uses GPUs to perform parallel comparison operations to achieve full parallelization of the comparison process.
[0006] The technical solution of this invention is as follows:
[0007] A fully homomorphic comparison method based on TFHE gate bootstrapping includes the following steps:
[0008] Step 1: Initialization:
[0009] Set the gate bootstrap inputs as TLWE ciphertext c1, TRLWE ciphertext c2, and TRGSW ciphertext C; where the key for TLWE ciphertext c1 is s. 1 ;
[0010] Set the bootstrap key and transformation key
[0011] For two fixed messages set up The integer closest to 2Nb;
[0012] Another TLWE ciphertext at the same time n represents the length of the TLWE key, N represents the dimension of the polynomial, and an intermediate ciphertext is constructed.
[0013]
[0014] When i = 0, 1, ..., k-1, C i =0, k represents the number of polynomials;
[0015] The accumulator ACC is initialized in the following form:
[0016]
[0017] Step 2: Calculate the CMux gate:
[0018] make ACC i Perform Gadget decomposition with basis h to obtain the decomposition result Dec. h (ACC i )=(A 11 ,...,A 1,l ,...,A (k+1)l );
[0019] The decomposed Dec h (ACC i ) and BK i Perform multiplication, where BK i Represents the i-th bootstrap key;
[0020] Finally, add the result of the multiplication operation to ACC0 to obtain the accumulator.
[0021] ACC←ACC0+ACC i ·BK i
[0022] Sample extraction is performed on the calculated ACC to obtain a TLWE ciphertext c′=TLWE with key s′. s′ (μ);
[0023] Use conversion key The obtained TLWE ciphertext c′ is subjected to key conversion to obtain the final key s. 1 The TLWE ciphertext c″;
[0024] Step 3: Replace all inputs and outputs of the CMux gate with TLWE ciphertext.
[0025] Construct a homomorphic gate structure of L-CMux(a,b,c) = a? b:c multi-bit comparison and accelerate it in parallel using a GPU, where b and c represent the input TLWE ciphertext, and a represents the selection control. When a is 1 for encryption, L-CMux(a,b,c) outputs b, and when a is 0 for encryption, L-CMux(a,b,c) outputs c. The plaintext space is chosen as μ∈[-1 / 8,1 / 8].
[0026] Step 3.1: Based on the torus Give the basic gate structure used in homomorphic comparisons.
[0027] First, map the plaintext AND, NOT, and XOR operations to the ciphertext operations as follows:
[0028] L-AND(A,B)=Bootstrapping((0,-1 / 8)+A+B),
[0029] L-NOT(A) = -A,
[0030] L-XOR(A,B)=Bootstrapping((0,1 / 4)+2·(A+B))
[0031] It satisfies the following homomorphic property:
[0032] Dec(L-AND(A,B)) = AND(a,b),
[0033] L-NOT(A) = NOT(a),
[0034] Dec(L-XOR(A,B)) = XOR(a,b)
[0035] The final L-CMux gate is as follows:
[0036] L-CMux(A,B,C)=KeySwitching(Bootstrapping_WoKS(L-AND(A,B))
[0037] +Bootstrapping_WoKS(L-AND(L-NOT(A),C)))
[0038] Bootstrapping_WoKS indicates a bootstrapping step without key conversion;
[0039] Step 3.2: Construct a single-bit homomorphic comparator based on the L-CMux gate
[0040] make To compare the results, we select ciphertexts A and B, and plaintexts a and b to compare, and construct a single-bit homomorphic comparator as follows:
[0041] cmp0=Bootstrapping(L-AND(L-NOT(A),B),
[0042] cmp1=Bootstrapping(L-AND(A,L-NOT(B))),
[0043] cmp2=Bootstrapping(L-NOT(L-XOR(A,B)))
[0044] Satisfying homomorphic operations:
[0045] Dec(cmp0)=L-AND(L-NOT(a),b),
[0046] Dec(cmp1)=L-AND(a,L-NOT(b)),
[0047] Dec(cmp2) = L-NOT(L-XOR(a,b))
[0048] After decrypting the output, if a > b, return cmp1 = TLWE s (1); When a < b, return cmp0 = TLWE s (1); When a = b, return cmp2 = TLWE s (1), where 1 corresponds to 1 / 8 on the torus;
[0049] Step 3.3: Construct an arbitrary bit homomorphic comparator based on L-CMux gates
[0050] Let the length of the bit string to be compared be... Using cmp from step 3.2 as the comparison result, pre = TLWE s (μ) serves as a temporary comparison result, and the base digits during the comparison process have the following form:
[0051]
[0052] have Let two plaintext bit strings to be compared have the following form:
[0053]
[0054] The corresponding ciphertexts A and B also have the following forms:
[0055]
[0056]
[0057] in Compare from the most significant bit to the least significant bit of the bit string:
[0058] First, determine a i With b i Whether they have the same bits, i.e., execute:
[0059] pre = L - XOR(A i B i )
[0060] Then, the result of the judgment is used as the condition for selecting the L-CMux gate, and carry1 and pre are used as inputs, which are the selection results, to execute L-CMux:
[0061] carry2 = L - CMux(pre, Bi ,carry1)
[0062] carry2 is the temporary result of the comparison of the i-th bit. This result is copied to carry1, as defined below:
[0063] L-COPY(out,in)=L-COPY(carry1,carry2)
[0064] Repeat the comparison process until the entire bit string has been compared, and save the result to cmp:
[0065] L-COPY(out,in)=L-COPY(cmp,carry1)
[0066] The entire process satisfies the following homomorphic computation:
[0067] Dec(pre) = L - XOR(a i ,b i ),
[0068] Dec(carry2)=L-CMux(Dec(pre),b i Dec(carry1))
[0069] After decrypting the output, if a > b, return cmp = TLWE s (0), where 0 corresponds to -1 / 8 on the torus; when a≤b, return cmp=TLWE s (1), where 1 corresponds to 1 / 8 on the torus;
[0070] Step 3.4: Construct an arbitrary bit homomorphic comparator based on GPU
[0071] First, select the plaintext string and ciphertext structure from step 3.3;
[0072] Next, for each ciphertext A in the ciphertext string... i With B i And the sign bit, using multi-threading technology, calls the single-bit homomorphic comparator in step 3.2 in parallel, and stores the result in... With cmp i middle;
[0073] Again With cmp i Decryption will yield 2 A binary 0-1 vector of dimension, corresponding to One plain text;
[0074] Finally, first check Dec(sign). If the sign bits of the two numbers are the same, then check Dec(sign). Finally, check cmp. i The final result is obtained.
[0075] Furthermore, in step 1,
[0076] TLWE ciphertext s 1 For the encryption key, satisfy Taken from a uniform 0,1 distribution, n represents the TLWE key s 1 Length; For real numbers, the torus is used. Choose 1 / 8 to represent 1 and -1 / 8 to represent 0 from the torus; Corresponding to 0 and 1; e represents Gaussian noise;
[0077] TRLWE Cipher Among them, plain text Key For a polynomial with k binary coefficients, N represents the dimension of the polynomial, and k represents the number of polynomials;
[0078] TRGSW Cipher satisfy The key is a TRLWE key, where each item is a TRLWE ciphertext, Z is a TRLWE encryption of 0, and h is a Gadget factorization matrix.
[0079]
[0080] B g Let l denote the decomposition basis of the Gadget matrix, and l denote the decomposition length of the TRLWE ciphertext.
[0081] Furthermore, in step 1,
[0082] The bootstrapping key consists of n TRGSW ciphertexts, which are used in conjunction with the TLWE key s. 1 The encryption key is... Define the bootstrap key as follows:
[0083]
[0084] Each item in the conversion key is a TLWE ciphertext, and the corresponding key is... n′=n·k, the conversion key is defined as:
[0085]
[0086] t is a setting value related to security parameters, and s′=KeyExtract(s″) is obtained by extracting polynomial coefficients from the TRLWE key.
[0087] Furthermore, in step 2, ACC i The specific process of decomposing a Gadget is as follows:
[0088] C i ′ represents set up The closest to C i,j 'of Integer multiples, B g Describe the basis of the Gadget matrix; then... Decompose into:
[0089]
[0090] get:
[0091] Furthermore, in step 2, the sample extraction process for the calculated ACC is as follows: the highest-order bits of the polynomial coefficients are extracted sequentially to obtain the TLWE ciphertext c′=TLWE with key s′. s′ (μ).
[0092] Furthermore, in step 3.2, the comparison processes cmp0 and cmp1 using the L-CMux gate are merged, and the greater than and less than comparisons are completed simultaneously using only one key conversion process. The comparison process is constructed as follows:
[0093] cmp=L-CMux(A,B,B)=KeySwitching(Bootstrapping_WoKS(L-AND(A,B))
[0094] +Bootstrapping_WoKS(L-AND(L-NOT(A),B)))
[0095] Satisfying homomorphic operations:
[0096] Dec(L-CMux(A,B,B))=L-CMux(a,b,b)
[0097] when hour, This means a > b;
[0098] when hour, This means a < b.
[0099] Furthermore, step 3.3 employs an arbitrary bit homomorphic comparator that does not use radix bits:
[0100] First, select plaintext binary strings a and b to be compared, and the corresponding TLWE encrypted ciphertext strings A and B, and compare them from the high bit to the low bit of the bit string;
[0101] Secondly, let the sign bit The sign bits of A and B represent the ciphertext for each bit other than the sign bit. Homomorphic comparison is performed using the single-bit homomorphic comparator described in step 3.2;
[0102] Length is The string comparison result is Decrypt the sign bit: Dec(sign)
[0103] If Dec(sign) = (1,0) or Dec(sign) = (0,1), the comparison process ends, and at this time a b;
[0104] If Dec(sign) = (1,1) or Dec(sign) = (0,0), first determine... when Time represents a j =b j Continue comparing the next one; when time for cmp i Make a judgment when cmp i =0 or cmp i When a=1, the program terminates directly and outputs either a>b or a<b; otherwise, the comparison of the entire bit string ends and a=b is output.
[0105] Furthermore, in step 3.4, when the plaintext is expanded to k elements, it has the following plaintext form:
[0106]
[0107] The corresponding ciphertext It can also take the following form:
[0108]
[0109] Similarly, executing the single-bit homomorphic comparator in parallel will yield k results. With cmp i After decryption, two results are obtained. A binary 0-1 vector of dimension, corresponding to An explicit statement.
[0110] Beneficial effects
[0111] The beneficial effects of this invention are as follows: For the homomorphic comparison calculation in the TFHE scheme, the L-CMux gate is used to implement single-bit homomorphic comparison, and then the single-bit homomorphic comparison is extended to arbitrary-bit homomorphic comparison. Furthermore, the parallel computing of the GPU is used to parallelize the single-bit homomorphic comparison process, thus designing a fast homomorphic comparison method and improving the homomorphic comparison efficiency of the TFHE scheme.
[0112] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Detailed Implementation
[0113] The embodiments of the present invention are described in detail below. These embodiments are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.
[0114] The fully homomorphic comparison method based on TFHE gate bootstrapping in this embodiment mainly includes the following steps:
[0115] Step 1: Initialization:
[0116] Set parameter n = 630, where n represents the TLWE key s 1 The length is usually chosen as an integer.
[0117] Set N=1024, k=1, l=3, B g Let 128 be the number of polynomials, N represents the dimension of the polynomial (usually a power of 2), k represents the number of polynomials, and B... g Let l denote the decomposition basis of the Gadget matrix, and l denote the decomposition length of the TRLWE ciphertext.
[0118] The gate bootstraps a TLWE ciphertext input. Where s 1 For the encryption key, satisfy It is taken from a uniform 0,1 distribution; For a real torus, Choose 1 / 8 to represent 1 and -1 / 8 to represent 0 from the torus. The corresponding values are 0 and 1; e represents Gaussian noise.
[0119] In addition, the bootstrapping process also requires the use of TRLWE ciphertext. Among them, plain text Key For a polynomial with one binary coefficient,
[0120] Finally, TRGSW ciphertext is required. satisfy The key is a TRLWE key, where each item is a TRLWE ciphertext, Z is a TRLWE encryption of 0, and h is a Gadget factorization matrix.
[0121]
[0122] Then, the bootstrapping process also requires some necessary keys, described as follows:
[0123] The bootstrapping process first requires a bootstrapping key, which is 630 TRGSW ciphertexts and is used in conjunction with the TLWE key. 1 The encryption key is... Define the bootstrap key as follows:
[0124]
[0125] Secondly, the bootstrap-processed ciphertext needs to be transformed, so a transformation key is also required. Each item of this transformation key is a TLWE ciphertext, and the corresponding key is... n′=n·k, the transformation key is defined in the following form:
[0126]
[0127] The selection of t is related to the security parameters. The security number λ = 110 is selected, where s′ = KeyExtract(s″) is obtained by extracting polynomial coefficients from the TRLWE key.
[0128] For two fixed messages Let TLWE ciphertext be the integer closest to 2048 bits. at the same time Construct an intermediate ciphertext Let polynomial The accumulator ACC is initialized in the following form:
[0129]
[0130] Where 0 is a vector of length 1024, and (0,v) corresponds to a TRLWE ciphertext.
[0131] Step 2: Calculation process of CMux gate
[0132] make ACC i Perform Gadget decomposition with basis h to obtain the decomposition result Dec. h (ACC i )=(A 11 ,...,A 13 ,...,A (1+1)3 ), about to Ci ′ represents set up The closest to C i,j 'of Integer multiples, then Decompose into:
[0133]
[0134] get:
[0135] The decomposed Dec h (ACC i ) and BK i Performing a multiplication operation, that is, multiplying the TRLWE ciphertext by the TRGSW ciphertext to obtain the TRLWE ciphertext, is essentially a polynomial multiplication operation, which can be calculated using the Fast Number Theory Transformation (NTT). Finally, simply add ACC0 to the result, as follows:
[0136] ACC←ACC0+ACC i ·BK i
[0137] The above process is the calculation process of the CMux gate, which is equivalent to calculating:
[0138] ACC = CMux(BK) i ACC i ,ACC0)
[0139] The CMux gate takes TRLWE ciphertext and TRGSW ciphertext as input and outputs TRLWE ciphertext.
[0140] Then, sample extraction is performed on the calculated ACC, that is, extraction from TRLWE ciphertext to TLWE ciphertext, sequentially extracting the highest bit of the polynomial coefficients to obtain a TLWE ciphertext c′ = TLWE with key s′. s′ (μ).
[0141] Finally, use the conversion key. The obtained TLWE ciphertext c′ is subjected to key conversion to obtain the final key s. 1 The TLWE ciphertext, i.e., c″ = KeySwitching(c′), is obtained in this step. The ciphertext c″ obtained in this step is the final result of the gate bootstrapping algorithm. The plaintext corresponding to this ciphertext is obtained from the input TLWE ciphertext. Decide.
[0142] Step 3: Replace all inputs and outputs of the CMux gate with TLWE ciphertext.
[0143] Construct a homomorphic gate structure of L-CMux(a,b,c) = a? b:c multi-bit comparison and accelerate it in parallel using a GPU, where b and c represent the input TLWE ciphertext, and a represents the selection control. When a is 1 for encryption, L-CMux(a,b,c) outputs b, and when a is 0 for encryption, L-CMux(a,b,c) outputs c.
[0144] The plaintext space is selected as μ∈[-1 / 8,1 / 8] as described in step 1. To ensure correct decryption, the noise e is set to <1 / 16. The TLWE ciphertexts A, B, and C are defined, and the corresponding plaintexts are... Perform the following steps:
[0145] Step 3.1: Based on the torus Give the basic gate structure used in homomorphic comparisons.
[0146] First, map the AND, NOT, and XOR operations of the plaintext to the ciphertext operations as follows:
[0147] L-AND(A,B)=Bootstrapping((0,-1 / 8)+A+B),
[0148] L-NOT(A) = -A,
[0149] L-XOR(A,B)=Bootstrapping((0,1 / 4)+2·(A+B))
[0150] It satisfies the following homomorphic property:
[0151] Dec(L-AND(A,B)) = AND(0,1),
[0152] L-NOT(A)=NOT(0),
[0153] Dec(L-XOR(A,B)) = XOR(0,1)
[0154] The final L-CMux gate is as follows:
[0155] L-CMux(A,B,C)=KeySwitching(Bootstrapping_WoKS(L-AND(A,B))
[0156] +Bootstrapping_WoKS(L-AND(L-NOT(A),C)))
[0157] Bootstrapping_WoKS represents a bootstrapping step without key conversion, which also satisfies Dec(L-CMux(A,B,C))=L-CMux(0,1,1).
[0158] Step 3.2: Construction of a single-bit homomorphic comparator
[0159] Let cmp = (cmp0, cmp1, cmp2) ∈ TLWE s (μ) represents the comparison result. Ciphertexts A and B are selected for comparison, along with plaintexts a and b. Combining the operations in step 3.1, the single-bit homomorphic comparator operates as follows:
[0160] cmp0=Bootstrapping(L-AND(L-NOT(A),B),
[0161] cmp1=Bootstrapping(L-AND(A,L-NOT(B))),
[0162] cmp2=Bootstrapping(L-NOT(L-XOR(A,B)))
[0163] Satisfying homomorphic operations:
[0164] Dec(cmp0)=L-AND(L-NOT(0),1),
[0165] Dec(cmp1)=L-AND(0,L-NOT(1)),
[0166] Dec(cmp2) = L-NOT(L-XOR(0,1))
[0167] After decrypting the output, return cmp1=TLWE when a>b. s (1); When a < b, return cmp0 = TLWE s (1); When a = b, return cmp2 = TLWE s (1), where 1 corresponds to 1 / 8 on the torus. A single-bit homomorphic comparator can be completed with only three bootstrapping steps.
[0168] The single-bit homomorphic comparison process can be further optimized. This process involves three bootstrapping operations, which means three key conversions. The L-CMux gate can be used to merge the comparison processes cmp0 and cmp1, allowing for simultaneous greater than and less than comparisons with only one key conversion. The comparison process can be constructed as follows:
[0169] cmp=L-CMux(A,B,B)=KeySwitching(Bootstrapping_WoKS(L-AND(A,B))
[0170] +Bootstrapping_WoKS(L-AND(L-NOT(A),B)))
[0171] Satisfying homomorphic operations:
[0172] Dec(L-CMux(A,B,B))=L-CMux(0,1,1)
[0173] Analysis shows that when hour, This means a > b; when hour, This means a < b. A single-bit homomorphic comparison operation can be performed using one L-CMux gate and one L-XOR gate. The entire process requires three bootstrapping steps and two key conversion steps.
[0174] Step 3.3: Arbitrary Bit Homomorphic Comparator Based on L-CMux Gate
[0175] Let the length of the bit string to be compared be... Compare two 16-bit numbers, using the cmp result from step 3.2. As the state before L-CMux execution, the base bits and temporary result storage bits during the comparison process have the following forms:
[0176]
[0177] have Let two plaintext bit strings to be compared have the following form:
[0178] a=(1,...,0,...,1),b=(1,...,1,...,0)
[0179] The corresponding ciphertexts A and B also have the following forms:
[0180]
[0181]
[0182] Where i∈[0,15], the comparison is performed from the high-order bits to the low-order bits of the bit string.
[0183] First, determine a i With b i Whether they have the same number of bits, i.e., execute:
[0184] pre = L - XOR(A i B i )
[0185] Then, the result of the judgment is used as the condition for selecting the L-CMux gate, and carry1 and pre are used as inputs, which are the selection results, to execute L-CMux:
[0186] carry2 = L - CMux(pre, B i ,carry1)
[0187] That is, carry2 is the temporary result of the comparison of the i-th bit. This result is saved to carry1, as defined below:
[0188] L-COPY(out,in)=L-COPY(carry1,carry2)
[0189] Repeat step 3.3 until the entire bit string has been compared, and save the result to cmp:
[0190] L-COPY(out,in)=L-COPY(cmp,carry1)
[0191] The entire process satisfies the following homomorphic computation:
[0192] Dec(pre) = L - XOR(a i ,b i ),
[0193] Dec(carry2)=L-CMux(Dec(pre),b i Dec(carry1))
[0194] After decrypting the output, return when a > b. Where 0 corresponds to -1 / 8 on the torus; return when a≤b. Where 1 corresponds to 1 / 8 on the torus.
[0195] The design of the arbitrary bit comparator described above requires the use of a radix bit, i.e., homomorphic comparison operation with radix. The biggest drawback of this comparator design is that the entire calculation process is serialized, resulting in low efficiency when used for actual homomorphic comparison operations. Furthermore, for arbitrary bit homomorphic comparison, both plaintexts to be compared are unsigned integers, meaning that signed negative number comparisons cannot be implemented, which is a significant drawback in practical applications. Therefore, the radix bit, the biggest factor affecting parallelization, can be removed, and an arbitrary bit homomorphic comparator without using a radix bit can be designed. This involves applying the single-bit homomorphic comparator from step 3.2 to each bit of the arbitrary bit, while adding a signed homomorphic comparison method. The implementation process is as follows:
[0196] 1) Select plaintext binary strings a and b to be compared, and corresponding TLWE encrypted ciphertext strings A and B, and compare them from the high bit to the low bit.
[0197] 2) Set the sign bit The sign bits of A and B represent the ciphertext A for each bit excluding the sign bit. i B i i∈[1,15], homomorphic comparison is performed using the single-bit homomorphic comparator in step 3.2.
[0198] 3) The comparison result of a string of length 15 is: Decrypt the sign bit using Dec(sign). If Dec(sign) = (1,0) or Dec(sign) = (0,1), the comparison process ends, and at this point, a b. If Dec(sign) = (1,1) or Dec(sign) = (0,0), first determine... when Time represents a j =b j Continue comparing the next one; when time for cmp i Make a judgment when cmp i =0 or cmp i When a=1, the program terminates directly and outputs either a>b or a<b; otherwise, the comparison of the entire bit string ends and a=b is output.
[0199] Thus far, using the single-bit homomorphic comparator in step 3.2, we have completed the signed homomorphic comparison of any bit. The computational complexity of this arbitrary-bit homomorphic comparator is O(n), where n represents the length of the plaintext bit string.
[0200] Step 3.4: Implement the arbitrary bit homomorphic comparison process on the GPU
[0201] In step 3.3, we implemented a homomorphic comparator for arbitrary bits, which is efficient in plaintext mode. However, for each bit A in ciphertext mode... i With B i Each homomorphic comparison requires computation. With cmp i Then it is necessary to... With cmp i Performing homomorphic decryption operations and determining the size relationship of the current bits is not only time-consuming but also severely affects parallelism. Therefore, the following design will be a parallel arbitrary bit homomorphic comparator that can extend the number of plaintexts to 10.
[0202] 1) Select the plaintext string and ciphertext structure from step 3.3.
[0203] 2) For each ciphertext A in the ciphertext string i With B iThe sign bit, 'sign', is calculated using multithreading, employing 16 thread blocks to perform the computation, concurrently calling the single-bit homomorphic comparator in step 3.2, and storing the result in... With cmp i middle.
[0204] 3) To With cmp i Decryption will yield two 15-dimensional binary 0-1 vectors, corresponding to 30 plaintexts.
[0205] 4) Finally, first check Dec(sign). If the sign bits of the two numbers are the same, then check Dec(sign). Finally, check cmp. i The final result is obtained.
[0206] When the extended plaintext is 10 characters, it has the following plaintext form:
[0207]
[0208] The corresponding ciphertext It can also take the following form:
[0209]
[0210] Similarly, executing the single-bit homomorphic comparator in parallel will yield 10... With cmp i Then, after decryption, two 10×15 dimensional binary 0-1 vectors are obtained, corresponding to 2×10×15 plaintexts. This is an arbitrary bit homomorphic comparator that performs parallel computation from the most significant bit to the least significant bit.
[0211] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention without departing from the principles and spirit of the present invention.
Claims
1. A fully homomorphic comparison method based on TFHE gate bootstrapping, characterized in that: Includes the following steps: Step 1: Initialization: Set the gate bootstrap inputs as TLWE ciphertext c1, TRLWE ciphertext c2, and TRGSW ciphertext C; where the key for TLWE ciphertext c1 is s. 1 ; Set the bootstrap key and transformation key For two fixed messages μ0, set up The integer closest to 2Nb; Another TLWE ciphertext at the same time n represents the length of the TLWE key, N represents the dimension of the polynomial, and an intermediate ciphertext is constructed. When i = 0, 1, ..., k-1, C i =0, k represents the number of polynomials; The accumulator ACC is initialized in the following form: Step 2: Calculate the CMux gate: make ACC i Perform Gadget decomposition with basis h to obtain the decomposition result Dec. h (ACC i )=(A 11 ,...,A 1,l ,...,A (k+1)l ); The decomposed Dec h (ACC i ) and BK i Perform multiplication, where BK i Represents the i-th bootstrap key; Finally, add the result of the multiplication operation to ACC0 to obtain the accumulator. ACC←ACC0+ACC i ·BK i Sample extraction is performed on the calculated ACC to obtain a TLWE ciphertext c′=TLWE with key s′. s′ (μ); Use conversion key The obtained TLWE ciphertext c′ is subjected to key conversion to obtain the final key s. 1 The TLWE ciphertext c″; Step 3: Replace all inputs and outputs of the CMux gate with TLWE ciphertext. Construct a homomorphic gate structure of L-CMux(a,b,c) = a? b:c multi-bit comparison and accelerate it in parallel using a GPU, where b and c represent the input TLWE ciphertext, and a represents the selection control. When a is 1 for encryption, L-CMux(a,b,c) outputs b, and when a is 0 for encryption, L-CMux(a,b,c) outputs c. The plaintext space is chosen as μ∈[-1 / 8,1 / 8]. Step 3.1: Based on the torus Give the basic gate structure used in homomorphic comparisons. First, map the plaintext AND, NOT, and XOR operations to the ciphertext operations as follows: L-AND(A,B)=Bootstrapping((0,-1 / 8)+A+B), L-NOT(A) = -A, L-XOR(A,B)=Bootstrapping((0,1 / 4)+2·(A+B)) It satisfies the following homomorphic property: Dec(L-AND(A,B)) = AND(a,b), L-NOT(A) = NOT(a), Dec(L-XOR(A,B)) = XOR(a,b) The final L-CMux gate is as follows: L-CMux(A,B,C)=KeySwitching(Bootstrapping_WoKS(L-AND(A,B))+Bootstrapping_WoKS(L-AND(L-NOT(A),C))) Bootstrapping_WoKS indicates a bootstrapping step without key conversion; Step 3.2: Construct a single-bit homomorphic comparator based on the L-CMux gate Let cmp = (cmp0, cmp1, cmp2) ∈ TLWE s1 (μ) represents the comparison result. Ciphertexts A and B are selected for comparison, and plaintexts a and b are selected to construct a single-bit homomorphic comparator as follows: cmp0=Bootstrapping(L-AND(L-NOT(A),B), cmp1=Bootstrapping(L-AND(A,L-NOT(B))), cmp2=Bootstrapping(L-NOT(L-XOR(A,B))) Satisfying homomorphic operations: Dec(cmp0)=L-AND(L-NOT(a),b), Dec(cmp1)=L-AND(a,L-NOT(b)), Dec(cmp2) = L-NOT(L-XOR(a,b)) After decrypting the output, if a > b, return cmp1 = TLWE s (1); When a < b, return cmp0 = TLWE s (1); When a = b, return cmp2 = TLWE s (1), where 1 corresponds to 1 / 8 on the torus; Step 3.3: Construct an arbitrary bit homomorphic comparator based on L-CMux gates Let the length of the bit string to be compared be... Using cmp from step 3.2 as the comparison result, pre = TLWE s (μ) serves as a temporary comparison result, and the base digits during the comparison process have the following form: have Let two plaintext bit strings to be compared have the following form: The corresponding ciphertexts A and B also have the following forms: in Compare from the most significant bit to the least significant bit of the bit string: First, determine a i With b i Whether they have the same bits, i.e., execute: pre=L-XOR(A i ,B i ) Then, the result of the judgment is used as the condition for selecting the L-CMux gate, and carry1 and pre are used as inputs, which are the selection results, to execute L-CMux: carry2=L-CMux(pre,B i ,carry1) carry2 is the temporary result of the comparison of the i-th bit. This result is copied to carry1, as defined below: L-COPY(out,in)=L-COPY(carry1,carry2) Repeat the comparison process until the entire bit string has been compared, and save the result to cmp: L-COPY(out,in)=L-COPY(cmp,carry1) The entire process satisfies the following homomorphic computation: Dec(pre)=L-XOR(a i ,b i ), Dec(carry2)=L-CMux(Dec(pre),b i ,Dec(carry1)) After decrypting the output, if a > b, return cmp = TLWE s (0), where 0 corresponds to -1 / 8 on the torus; when a≤b, return cmp=TLWE s (1), where 1 corresponds to 1 / 8 on the torus; Step 3.4: Construct an arbitrary bit homomorphic comparator based on GPU First, select the plaintext string and ciphertext structure from step 3.3; Next, for each ciphertext A in the ciphertext string... i With B i And the sign bit, using multi-threading technology, calls the single-bit homomorphic comparator in step 3.2 in parallel, and stores the result in... With cmp i middle; Again With cmp i Decryption will yield 2 A binary 0-1 vector of dimension, corresponding to One plain text; Finally, first check Dec(sign). If the sign bits of the two numbers are the same, then check Dec(sign). Finally, check cmp. i The final result is obtained.
2. The fully homomorphic comparison method based on TFHE gate bootstrapping as described in claim 1, characterized in that: In step 1, TLWE ciphertext s 1 For the encryption key, satisfy Taken from a uniform 0,1 distribution, n represents the TLWE key s 1 Length; mod 1 represents a real torus; Choose 1 / 8 to represent 1 and -1 / 8 to represent 0 from the torus; Corresponding to 0 and 1; e represents Gaussian noise; TRLWE Cipher Among them, plain text Key For a polynomial with k binary coefficients, N represents the dimension of the polynomial, and k represents the number of polynomials; TRGSW Cipher satisfy The key is a TRLWE key, where each item is a TRLWE ciphertext, Z is a 0-bit TRLWE encryption, and h is a Gadget factorization matrix. B g Let l denote the decomposition basis of the Gadget matrix, and l denote the decomposition length of the TRLWE ciphertext.
3. The fully homomorphic comparison method based on TFHE gate bootstrapping as described in claim 1, characterized in that: In step 1, The bootstrapping key consists of n TRGSW ciphertexts, which are used in conjunction with the TLWE key s. 1 The encryption key is... Define the bootstrap key as follows: Each item in the conversion key is a TLWE ciphertext, and the corresponding key is... n′=n·k, the conversion key is defined as: t is a setting value related to security parameters, and s′=KeyExtract(s″) is obtained by extracting polynomial coefficients from the TRLWE key.
4. The fully homomorphic comparison method based on TFHE gate bootstrapping according to claim 1, characterized in that: In step 2, ACC i The specific process of decomposing a Gadget is as follows: C i ′ represents set up The closest to C i,j 'of Integer multiples, B g Describe the basis of the Gadget matrix; then... Decompose into: get:
5. The fully homomorphic comparison method based on TFHE gate bootstrapping according to claim 1, characterized in that: In step 2, the sample extraction process for the calculated ACC is as follows: the highest-order bits of the polynomial coefficients are extracted sequentially to obtain the TLWE ciphertext c′=TLWE with key s′. s′ (μ).
6. The fully homomorphic comparison method based on TFHE gate bootstrapping according to claim 1, characterized in that: In step 3.2, the comparison processes cmp0 and cmp1 using the L-CMux gate are merged, and the greater than and less than comparisons are completed simultaneously using only one key conversion process. The comparison process is constructed as follows: cmp=L-CMux(A,B,B)=KeySwitching(Bootstrapping_WoKS(L-AND(A,B))+Bootstrapping_WoKS(L-AND(L-NOT(A),B))) Satisfying homomorphic operations: Dec(L-CMux(A,B,B))=L-CMux(a,b,b) when hour, This means a > b; when hour, This means a < b.
7. The fully homomorphic comparison method based on TFHE gate bootstrapping according to claim 1, characterized in that: Step 3.3 employs an arbitrary-bit homomorphic comparator that does not use radix bits: First, select plaintext binary strings a and b to be compared, and the corresponding TLWE encrypted ciphertext strings A and B, and compare them from the high bit to the low bit of the bit string; Secondly, let the sign bit The sign bits of A and B represent the ciphertext for each bit other than the sign bit. Homomorphic comparison is performed using the single-bit homomorphic comparator described in step 3.2; Length is The string comparison result is Decrypt the sign bit: Dec(sign) If Dec(sign) = (1,0) or Dec(sign) = (0,1), the comparison process ends, and at this time a b; If Dec(sign) = (1,1) or Dec(sign) = (0,0), first determine... when Time represents a j =b j Continue comparing the next one; when time for cmp i Make a judgment when cmp i =0 or cmp i When a=1, the program terminates directly and outputs either a>b or a<b; otherwise, the comparison of the entire bit string ends and a=b is output.
8. The fully homomorphic comparison method based on TFHE gate bootstrapping according to claim 7, characterized in that: In step 3.4, when the plaintext is expanded to k elements, the plaintext takes the following form: The corresponding ciphertext It can also take the following form: Similarly, executing the single-bit homomorphic comparator in parallel will yield k results. With cmp i After decryption, two results are obtained. A binary 0-1 vector of dimension, corresponding to An explicit statement.
Citation Information
Patent Citations
Bootstrap-type symmetrical fully-homomorphic encryption method
CN107864033A
Fully homomorphic encryption gate bootstrap method based on GPU fast number theory conversion
CN114936350A
