A GPU-based method and system for homomorphic encryption modular operation
By optimizing the modular subtraction and modular multiplication algorithm on the GPU and combining CPU pre-calculation, the problem of low modular computing efficiency in the fully homomorphic encryption scheme is solved, more efficient modular computing performance is achieved, and the practicality of the fully homomorphic encryption scheme is enhanced.
Patent Information
- Application Number
- CN202510586016.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-08
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2045-05-08
AI Technical Summary
In the existing fully homomorphic encryption scheme, the mode operation operation efficiency is inefficient, especially when executed on the GPU, which is difficult to effectively accelerate.
The Barrett method based on GPU is used to optimize the modular subtraction algorithm and the Shupp method are optimized. Combined with the CPU pre-calculation constants, the multiplication statement is reduced, and simple addition, multiplication and shift operations are used to achieve the acceleration of modular subtraction, modulation multiplication and modulation operations.
It improves the execution efficiency of the fully homomorphic encryption solution, enhances its availability on the GPU, and achieves a breakthrough in modular computing performance by reducing hardware resource usage and improving computing speed.
Smart Images

Figure CN120110643B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of computer and information security algorithms, and relates to a fully homomorphic encryption modular operation method and system based on a GPU. Background Art
[0002] Homomorphic encryption is a cryptographic technique that allows operations to be performed directly on encrypted data without decrypting it. The result of a homomorphic encryption calculation is also encrypted data, which can only be decrypted by the key holder. Second-generation homomorphic encryption schemes, such as BFV (Brakerski-Fan-Vercauteren) and BGV (Brakerski-Gentry-Vaikuntanathan), are a core class of fully homomorphic encryption schemes, and are integer-based homomorphic encryption schemes. Fully homomorphic encryption schemes allow modular addition and multiplication of encrypted integers, which means that a large number of modular reduction, modular multiplication, and modular addition operations are generated during the execution of fully homomorphic encryption schemes. Since the operands in fully homomorphic encryption schemes are often integers, and modular operations on integers are often complex and inefficient in real applications, accelerating modular operations on integers can effectively improve the execution efficiency of the entire fully homomorphic encryption scheme.
[0003] CPUs and GPUs are two different types of processors. The main difference is that CPUs excel at handling complex logic control and optimizing serial program execution, while GPUs excel at handling simple data-parallel tasks and optimizing parallel program execution. The modular reduction and modular multiplication operations in fully homomorphic encryption schemes are simple in logic, have a single computational form, and handle large amounts of data, making them well-suited for effective acceleration using GPU computing.
[0004] The Barrett method is a fast modular reduction algorithm that can quickly perform modular reduction operations using only normal addition, multiplication, and shift operations. The Shoup method is a fast modular multiplication algorithm that can quickly perform modular multiplication operations using only normal addition, multiplication, and shift operations when one operand remains unchanged. However, in practical applications, the scale of calculations often exceeds the integer data type size preset by the programming language, requiring the implementation of high-precision multiplications including carry operations. This means that the Barrett method still contains a large number of multiplication-addition operations including carry operations, leaving room for improvement in the acceleration of modular reduction operations. Furthermore, both methods use conditional branching steps to ensure that the calculation results are within a given modulus size range. However, executing conditional branch statements on a GPU results in a certain performance loss. Therefore, a naive implementation of these two algorithms on a GPU will not achieve a good acceleration effect. Summary of the Invention
[0005] Purpose of the invention: The purpose of the present invention is to address the problem of low implementation efficiency of traditional fully homomorphic encryption schemes, and to propose a GPU-based fully homomorphic encryption modular operation method and system. While ensuring the correctness of the calculation results, the GPU is used to accelerate the modular reduction, modular multiplication, and modular addition operations in the fully homomorphic encryption scheme, thereby improving the execution efficiency of the fully homomorphic encryption scheme and enhancing the practicality of the fully homomorphic encryption scheme.
[0006] Technical solution: To achieve the above-mentioned purpose, the present invention adopts the following technical solution:
[0007] In a first aspect, the present invention provides a fully homomorphic encryption modular operation method based on a GPU, comprising the following steps:
[0008] Based on the GPU implementation, given the input parameters a1 and q1 and the constant mu1 related to q1, the modular reduction result a1 mod q1 of the 2X-bit integers a1 and q1 is calculated. Where a1 and mu1 are constructed 2X-bit integer data types, q1 is a constructed X-bit integer data type, mu1 is pre-computed in the initialization step of the fully homomorphic encryption scheme based on the fixed value of q1, and q1 is restricted to ensure that the multiplication statement in the Barrett method does not cause carry. X is the number of operands.
[0009] Based on GPU implementation, given input parameters a2, b2, q2, and constant mu2 related to b2 and q2, calculate the modular multiplication result of a2 and b2 as X-bit integers ; where a2, b2, q2, and mu2 are all X-bit integer data types, mu2 is pre-calculated in the initialization step of the fully homomorphic encryption scheme using the fixed values of b2 and q2; b2 is a pre-set fixed operand.
[0010] Furthermore, the modular reduction result a1 mod q1 of the 2X-bit integers a1 and q1 is calculated, including:
[0011] Calculation results and store it in 64-bit unsigned integer registers; for a1, split it into 64-bit unsigned integers and perform calculations on 64-bit integer data types respectively; Indicates rounding up;
[0012] calculate ;
[0013] Calculate res1=res1-2q1;
[0014] calculate ;
[0015] Calculate res1=res1-q1;
[0016] calculate ;
[0017] Let a1=res1, return a1 as the calculation result of the algorithm, where the calculation result res1 is stored in 64-bit unsigned integer registers.
[0018] Furthermore, by The values of the registers are passed to the corresponding registers storing the low-order data of a1 in sequence, and the value of the register storing the high-order data of a1 is set to 0 to pass the value of res1 to a1 as the final calculation result of the algorithm.
[0019] Furthermore, the modular multiplication result of the X-bit integers a2 and b2 is calculated. ,include:
[0020] Calculation results and store it in 64-bit unsigned integer registers;
[0021] calculate ;
[0022] Calculating temporary values and store it in 64-bit unsigned integer registers;
[0023] Calculate res2 = tmp-res2;
[0024] Calculate res2 = res2 - q2;
[0025] calculate ;
[0026] Returns res2 as the result of the algorithm.
[0027] Furthermore, the method also includes: based on the GPU, given input parameters a3 and b3, or a3, b3 and c3, calculating the modular addition result of 2X-bit integers a3=a3+b3 or c3=a3+b3; wherein a3, b3 and c3 are all constructed 2X-bit integer data types.
[0028] Furthermore, calculating the modular addition result a3=a3+b3 of the 2X-bit integer includes: calculating a3=a3+b3; returning a3 as the calculation result of the algorithm; calculating the modular addition result c3=a3+b3 of the 2X-bit integer includes: calculating c3=a3+b3; returning c3 as the calculation result of the algorithm.
[0029] Furthermore, the constant mu1= is calculated according to the Barrett method. , Indicates rounding down, and the constant mu2= is calculated according to the Shoup method. ; When the fully homomorphic encryption scheme is initialized, all possible values of the constants mu1 and mu2 are precomputed in the CPU and the calculation results are stored in the global memory of the GPU.
[0030] In a second aspect, the present invention provides a fully homomorphic encryption modular operation system based on a GPU, comprising:
[0031] Fast modular reduction module, used to implement the GPU-based implementation of the modular reduction result a1 mod q1 of the 2X-bit integers of a1 and q1 given input parameters a1, q1 and a constant mu1 related to q1;
[0032] Fast modular multiplication module, used to implement the modular multiplication of X-bit integers of a2 and b2 based on GPU given input parameters a2, b2, q2, and constant mu2 related to b2 and q2 ;
[0033] Furthermore, the system also includes a modular addition module for implementing, based on a GPU, given input parameters a3 and b3, or a3, b3 and c3, to calculate the modular addition result a3=a3+b3 or c3=a3+b3 of a 2X-bit integer.
[0034] In a third aspect, the present invention provides a computer program product, comprising a computer program, which, when executed by a processor, implements the steps of the GPU-based fully homomorphic encryption modular operation method.
[0035] Beneficial effects: The present invention utilizes the hardware characteristics of the GPU and uses a fast modular reduction algorithm further optimized based on the Barrett method to accelerate a class of 2X-bit modular reduction operations with the same modulus in the fully homomorphic encryption scheme, uses the fast modular multiplication algorithm in the Shoup method to accelerate a class of X-bit modular multiplication operations with the same operand and the same modulus in the fully homomorphic encryption scheme, and accelerates the 2X-bit modular addition operation in the fully homomorphic encryption scheme, achieving a performance breakthrough for integer modular reduction, modular multiplication and modular addition operations in a homomorphic encryption environment, and enhancing the usability of the fully homomorphic encryption scheme. Compared with the existing technology, on the one hand, the fully homomorphic encryption modular operation method implemented by the present invention based on GPU can effectively accelerate the execution efficiency of the fully homomorphic encryption scheme compared with the method based on CPU implementation; on the other hand, the fully homomorphic encryption modular reduction operation method implemented by the present invention reduces the number of multiplication statements at the assembly statement level, and the fully homomorphic encryption modular multiplication operation method pre-calculates one of the fixed operands. These two modular operation methods also use relatively simple addition, multiplication and shift operations to replace the division in the modular operation, thereby quickly realizing modular reduction and modular multiplication, reducing the occupation of hardware resources while improving the operation speed, and further accelerating the execution efficiency of the fully homomorphic encryption scheme. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 This is a flow chart of a 2X-bit fast modular reduction method based on a GPU in an embodiment of the present invention.
[0037] Figure 2 Flowchart of the GPU-based X-bit fast modular multiplication method in an embodiment of the present invention.
[0038] Figure 3 Flowchart of a 2X bit modular addition method based on GPU in an embodiment of the present invention; wherein (a) is a modular addition operation with two input parameters, and (b) is a modular addition operation with three input parameters.
[0039] Figure 4 This is a flow chart of the fully homomorphic encryption modular operation method based on GPU in an embodiment of the present invention. DETAILED DESCRIPTION
[0040] The following will provide a clear and complete description of the technical solutions of the present invention in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described are intended only to illustrate the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
[0041] This embodiment provides a fully homomorphic encryption modular operation method based on GPU, involving a 2X-bit fast modular reduction operation based on GPU, an X-bit fast modular multiplication operation based on GPU with a fixed operand, and a 2X-bit modular addition operation based on GPU, where X is the number of operands. The main improvement lies in the fast modular reduction operation and the fast modular multiplication operation. Specifically, the fast modular reduction operation is: based on GPU implementation, given input parameters a1, q1 and a constant mu1 related to q1, calculate the modular reduction result a1 mod q1 of the 2X-bit integers of a1 and q1; wherein a1 and mu1 are constructed 2X-bit integer data types, q1 is a constructed X-bit integer data type, mu1 is pre-calculated in the initialization step of the fully homomorphic encryption scheme according to the fixed value of q1 using the Barrett method, and by restricting q1, it is ensured that no carry occurs in the multiplication statement in the Barrett method. Fast modular multiplication is: based on GPU implementation, given input parameters a2, b2, q2, and constant mu2 related to b2 and q2, calculate the modular multiplication result of X-bit integers a2 and b2 a2, b2, q2, and mu2 are all X-bit integer data types. Mu2 is precomputed using Shoup's method during the initialization of the fully homomorphic encryption scheme using fixed values for b2 and q2. b2 is a pre-set fixed operand. The modular addition operation is implemented on a GPU: Given input parameters a3 and b3, or a3, b3, and c3, calculate the modular addition result of 2X-bit integers: a3 = a3 + b3 or c3 = a3 + b3. Where a3, b3, and c3 are all constructed 2X-bit integer data types.
[0042] Specifically, if Figure 1 As shown, given input parameters a1, q1 and constant mu1, the calculation of the modular reduction result a1 mod q1 of the 2X-bit integer includes the following steps:
[0043] Step S101: input a1, q1 and mu1, wherein a1 is a 2X-bit integer data type constructed by the system, q1 is an X-bit integer data type constructed by the system, and mu1 is a 2X-bit integer data type constructed by the system.
[0044] Step S102: Calculation results and store it in 64-bit unsigned integer registers. For 2X-bit integer data types present in input parameters, split them into 64-bit unsigned integers and perform calculations on 64-bit integer data types.
[0045] Step S103: For a1, q1, and res1, calculate .
[0046] Step S104: For q1 and res1, calculate res1=res1-2q1.
[0047] Step S105: For q1 and res1, calculate .
[0048] Step S106: For q1 and res1, calculate res1=res1-q1.
[0049] Step S107: For q1 and res1, calculate .
[0050] Step S108: Let a1=res1, return a1 as the calculation result of the algorithm, where the calculation result res1 is stored in 64-bit unsigned integer registers by placing this The values of the registers are passed to the corresponding registers storing the low-order data of a1 in sequence, and the value of the register storing the high-order data of a1 is set to 0 to pass the value of res1 to a1 as the final calculation result of the algorithm.
[0051] like Figure 2 As shown, given the input parameters a2, b2, q2 and the constant mu2, calculate the modular multiplication result of X-bit integers , including the following steps:
[0052] Step S201: Input a2, b2, q2 and mu2, where a2, b2, q2 and mu2 are all X-bit integer data types constructed by the system. Mu2 is pre-calculated in the fully homomorphic encryption scheme initialization step through the fixed values of parameters b2 and q2. Therefore, the value range of the input parameter b2 is pre-set and cannot be selected arbitrarily.
[0053] Step S202: Calculation results and store it in 64-bit unsigned integer registers.
[0054] Step S203: Calculation .
[0055] Step S204: Calculate temporary value and store it in 64-bit unsigned integer registers.
[0056] Step S205: Calculate res2=tmp-res2.
[0057] Step S206: For q2 and res2, calculate res2=res2-q2.
[0058] Step S207: For q2 and res2, calculate ;
[0059] Step S208: Return res2 as the calculation result of the algorithm.
[0060] like Figure 3 As shown, given input parameters a3 and b3, or input parameters a3, b3, and c3, calculating the modular addition result of 2X-bit integers a3=a3+b3 or c3=a3+b3 includes the following steps:
[0061] Solution for calculating a3=a3+b3:
[0062] Step S301: input a3 and b3, where a3 and b3 are both 2X-bit integer data types constructed by the system.
[0063] Step S302: Calculate a3=a3+b3.
[0064] Step S303: Return a3 as the calculation result of the algorithm.
[0065] Solution for calculating c3=a3+b3:
[0066] Step S401: input a3, b3 and c3, wherein a3, b3 and c3 are all 2X-bit integer data types constructed by the system.
[0067] Step S402: Calculate c3=a3+b3.
[0068] Step S403: Return c3 as the calculation result of the algorithm.
[0069] Based on the above-mentioned GPU-based 2X-bit fast modular reduction operation, GPU-based X-bit fast modular multiplication operation with a fixed operand, and GPU-based 2X-bit modular addition operation, when implementing a fully homomorphic encryption scheme, the parameters for the fast modular operation are first determined, pre-calculated in the CPU when the fully homomorphic encryption scheme is initialized, and the results are stored in the GPU global memory; then, according to system needs, the above-mentioned GPU-based fast modular reduction, fast modular multiplication, or modular addition operation method is called; finally, the calculation result of the corresponding modular operation method is returned to the system.
[0070] The following embodiment takes the value of X being 64 as an example and uses PTX assembly statements as an example to introduce the specific implementation process of the modular operation method.
[0071] This embodiment provides a fully homomorphic encryption modular operation method based on a GPU. For input parameters a1, q1, mu1 (mu1 is a constant related to q1), the hardware characteristics of the GPU and the fast modular reduction algorithm further optimized based on the Barrett method are used to accelerate a class of 128-bit modular reduction operations with the same modulus in the fully homomorphic encryption scheme; for input parameters a2, b2, q2, mu2 (b2 is a constant, and mu2 is a constant related to b2 and q2), the hardware characteristics of the GPU and the fast modular multiplication algorithm in the Shupe method are used to accelerate a class of 64-bit modular multiplication operations with the same operand and the same modulus in the fully homomorphic encryption scheme; for input parameters a3, b3 or a3, b3, c3, the hardware characteristics of the GPU are used to accelerate the 128-bit modular addition operation in the fully homomorphic encryption scheme. Through the above three methods, a performance breakthrough of integer modular reduction, modular multiplication and modular addition operations in a homomorphic encryption environment is achieved, thereby enhancing the usability of the fully homomorphic encryption scheme.
[0072] First, the fast modular reduction method is introduced.
[0073] In the Barrett method, since multiplication statements may cause carry, the multiplication and addition statements need to consider the carry caused by low-order multiplication. This embodiment restricts the modulus q1 so that the value of q1 satisfies q1. 2 hi +2q1 2 lo<2 64 ,q1 2 hi Indicates q1 2 The high 64 bits of q1 2 lo Indicates q1 2 The lower 64 bits of the multiplication function are used to ensure that a carry does not occur, and the multiplication statements related to the carry in the Barrett method are omitted, thereby improving the execution efficiency of the algorithm.
[0074] Fast modular reduction method Mod_Reduce(a1,q1,mu1): input parameters are a1,q1,mu1∈ , 0≤a1 <q1 2 ,mu1= ,in Indicates integers, a1 and mu1 are 128-bit integer data types, and q1 is a 64-bit integer data type. , Where subscript 1 represents the upper 64 bits and subscript 0 represents the lower 64 bits. The output is a1. The specific steps of the algorithm are as follows:
[0075] Step S501: Set a 64-bit unsigned integer register to store 64-bit integer data res1, calculate , use the high 64-bit integer data of the calculation result as the value of res1. The implementation of this step is as follows: ul.hi.u 64 res1, a10,mu11.
[0076] Step S502: Calculation , use the high 64-bit integer data of the calculation result as the value of res1. The implementation of this step is as follows: mad.hi.u 64 res1,a11,mu10,res1.
[0077] Step S503: Calculation , use the lower 64-bit integer data of the calculation result as the value of res1. The implementation of this step is as follows: mad.lo.u 64 res1,a11,mu11,res1.
[0078] Step S504: Calculation , use the lower 64-bit integer data of the calculation result as the value of res1. The implementation of this step is as follows: mul.lo.u 64 res1,res1,q1.
[0079] Step S505: Calculate res1=a10-res1. The implementation of this step is as follows: sub.u 64 res1,a10,res1.
[0080] Step S506: Calculate res1=res1-2q1.
[0081] Step S507: Calculation .
[0082] Step S508: Calculate res1=res1-q1.
[0083] Step S509: Calculation .
[0084] Step S510: Set the lower 64-bit integer data of a1 to the value of res1, and set the upper 64-bit integer data to 0.
[0085] Step S511: Output calculation result a1.
[0086] Next, we introduce the fast modular multiplication method.
[0087] Fast modular multiplication method Mod_Mul(a2,b2,q2,mu2): input parameters are a2,b2,q2,mu2∈ ,0≤a2,b2 <q2,mu2= , where a2, b2, q2, and mu2 are all 64-bit integer data types, and all values of b2 are determined during precalculation. The output result is a 64-bit integer data res2. The specific steps of the algorithm are as follows:
[0088] Step S601: Set a 64-bit unsigned integer register to store res2, calculate , use the high 64-bit integer data of the calculation result as the value of res2. The implementation of this step is as follows: mul.hi.u 64 res2,a2,mu2.
[0089] Step S602: Calculation , use the lower 64-bit integer data of the calculation result as the value of res2. The implementation of this step is as follows: mul.lo.u 64 res2,res2,q2.
[0090] Step S603: Calculation And store it in a 64-bit unsigned integer register, using the lower 64-bit integer data of the calculation result as the value of tmp. The implementation method of this step is as follows: mul.lo.u 64 tmp,a2,b2.
[0091] Step S604: Calculate res2=tmp-res2. The implementation of this step is as follows: sub.u 64 res2,tmp,res2.
[0092] Step S605: Calculate res2=res2-q2.
[0093] Step S606: Calculation .
[0094] Step S607: Output the calculation result res2.
[0095] Finally, the modular addition method is introduced.
[0096] Mod_Add(a3,b3): Input parameters are a3,b3∈ , where a3 and b3 are both 128-bit integer data types. , The output is a3. The specific steps are as follows:
[0097] Step S701: Calculate a30=a30+b30 and set the condition code to mark the carry information. The implementation of this step is as follows: add.cc.u 64 a30,a30,b30.
[0098] Step S702: Calculate a31=a31+b31 using the carry information in S701. The implementation of this step is as follows: addc.u 64 a31,a31,b31.
[0099] Step S703: Output calculation result a3.
[0100] Mod_Add(a3,b3,c3): Input parameters are a3,b3,c3∈ , where a3, b3, and c3 are all 128-bit integer data types. , , The output is c3. The specific steps are as follows:
[0101] Step S801: Calculate c30=a30+b30 and set the condition code to mark the carry information. The implementation of this step is as follows: add.cc.u 64 c30,a30,b30.
[0102] Step S802: Calculate c31=a31+b31 using the carry information in S801. The implementation of this step is as follows: addc.u 64 c31,a31,b31.
[0103] Step S803: Output calculation result c3.
[0104] The above four algorithms are combined to form a GPU-based fully homomorphic encryption modular operation method proposed in this embodiment.
[0105] Based on the same inventive concept, this embodiment provides a fully homomorphic encryption modular operation system based on a GPU, which mainly includes: a fast modular reduction module for implementing on the GPU given input parameters a1, q1 and a constant mu1 related to q1, and calculating the modular reduction result a1 mod q1 of the 2X-bit integers of a1 and q1; a fast modular multiplication module for implementing on the GPU given input parameters a2, b2, q2, and a constant mu2 related to b2 and q2, and calculating the modular multiplication result of the X-bit integers of a2 and b2 The invention also includes a modular addition module for implementing, based on a GPU, given input parameters a3 and b3, or a3, b3 and c3, to calculate the modular addition result a3=a3+b3 or c3=a3+b3 of 2X-bit integers.
[0106] Combined with the above methods, the specific implementation plan of the GPU-based fully homomorphic encryption modular operation system is described, such as Figure 4 As shown, the process is as follows:
[0107] First, initialize the parameters mu1 and mu2. In the fully homomorphic encryption scheme, the optional values of the candidate moduli for q1 and q2 have been determined when the scheme is initialized. Therefore, according to the formula in the Barrett method, mu1= And the formula mu2= in Shoup's method , all possible values of mu1,mu2 can be precomputed in the CPU when the fully homomorphic encryption scheme is initialized and the calculation results can be stored in the global memory of the GPU.
[0108] During execution, the GPU-based fully homomorphic encryption scheme receives input data from the GPU's global memory and calls kernel functions to accelerate computation. Within these kernel functions, calls are made to the modular reduction method Mod_Reduce, the modular multiplication method Mod_Mul, and the modular addition method Mod_Add. For the Mod_Reduce algorithm, the system first prepares parameters a1, q1, and mu1, then calls the fast modular reduction method Mod_Reduce with these as input parameters for the modular reduction operation, ultimately returning parameter a1 as the calculation result. For the Mod_Mul algorithm, the system first prepares parameters a2, b2, q2, and mu2, then calls the fast modular multiplication method Mod_Mul with these as input parameters for the modular multiplication operation, ultimately returning parameter res2 as the calculation result. For the Mod_Add algorithm, the system first prepares parameters a3, b3 or a3, b3, c3, then calls the modular addition method Mod_Mul with these as input parameters for the modular addition operation, ultimately returning parameter a3 or c3 as the calculation result, depending on the input parameters.
[0109] This embodiment also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the aforementioned GPU-based fully homomorphic encryption modular operation method.
[0110] In summary, the GPU-based fully homomorphic encryption modular operation method and system proposed in the present invention improves the computational efficiency of the underlying operators of modular operation in the fully homomorphic encryption system by optimizing modular reduction, modular multiplication and modular addition operations, thereby accelerating the calculation process of the kernel function performing modular operation in the GPU-based fully homomorphic encryption system, which plays an important role in improving the execution efficiency of the fully homomorphic encryption scheme.
[0111] In addition to being applicable to the CUDA (Compute Unified Device Architecture) platform architecture, the present invention can also be applied to other multi-core computing structures with parallel computing characteristics.
[0112] The above is merely one embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the scope of protection of the present invention. For example, in the above specific embodiment, the value of X is 64. If, due to register size limitations, other values of X require simple modifications to the addition, multiplication, shift, and storage statements in the algorithm without further optimization, such modifications shall be considered equivalent transformations or substitutions based on the technical solution of the present invention and shall also fall within the scope of protection of the claims of the present invention.
Claims
1. A fully homomorphic encryption modular operation method based on GPU, characterized in that: The following steps are involved: Based on the GPU, given the input parameters a1 and q1 and the constant mu1 related to q1, calculate the modular reduction result a1 mod q1 of the 2X-bit integers a1 and q1. Where a1 and mu1 are constructed 2X-bit integer data types, q1 is a constructed X-bit integer data type, mu1 is pre-computed in the initialization step of the fully homomorphic encryption scheme using the Barrett method based on the fixed value of q1, and q1 is restricted to ensure that the multiplication statement in the Barrett method does not cause carry. X is the number of operands. Based on GPU implementation, given input parameters a2, b2, q2, and constant mu2 related to b2 and q2, calculate the modular multiplication result of a2 and b2 as X-bit integers Where a2, b2, q2, and mu2 are all X-bit integer data types. Mu2 is pre-calculated in the initialization step of the fully homomorphic encryption scheme using the fixed values of b2 and q2 using the Shoup method. b2 is a pre-set fixed operand. Calculate the modular reduction result a1 mod q1 of the 2X-bit integers a1 and q1, including: Calculation results and store it in 64-bit unsigned integer registers; for a1, split it into 64-bit unsigned integers and perform calculations on 64-bit integer data types respectively; Indicates rounding up; calculate ; Calculate res1=res1-2q1; calculate ; Calculate res1=res1-q1; calculate ; Let a1=res1, return a1 as the calculation result of the algorithm, where the calculation result res1 is stored in 64-bit unsigned integer registers.
2. A GPU-based fully homomorphic encryption modular operation method according to claim 1, characterized in that: By The values of the registers are passed to the corresponding registers storing the low-order data of a1 in sequence, and the value of the register storing the high-order data of a1 is set to 0 to pass the value of res1 to a1 as the final calculation result of the algorithm.
3. The GPU-based fully homomorphic encryption modular operation method according to claim 1, characterized in that: Calculates the modular multiplication of a2 and b2, which are X-digit integers. ,include: Calculation results and store it in 64-bit unsigned integer registers, Indicates rounding up; calculate ; Calculating temporary values and store it in 64-bit unsigned integer registers; Calculate res2 = tmp-res2; Calculate res2 = res2 - q2; calculate ; Returns res2 as the result of the algorithm.
4. The GPU-based fully homomorphic encryption modular operation method according to claim 1, characterized in that: Also includes: GPU-based implementation: Given input parameters a3 and b3, or a3, b3, and c3, calculate the modular addition of 2X-bit integers: a3=a3+b3 or c3=a3+b3. Where a3, b3 and c3 are all constructed 2X-bit integer data types.
5. A GPU-based fully homomorphic encryption modular operation method according to claim 4, characterized in that: Calculating the modular addition result a3=a3+b3 of 2X-bit integers includes: calculating a3=a3+b3; returning a3 as the calculation result of the algorithm; calculating the modular addition result c3=a3+b3 of 2X-bit integers includes: calculating c3=a3+b3; returning c3 as the calculation result of the algorithm.
6. The GPU-based fully homomorphic encryption modular operation method according to claim 1, characterized in that: According to Barrett's method, the constant mu1= , Indicates rounding down, and the constant mu2= is calculated according to the Shoup method. ; When the fully homomorphic encryption scheme is initialized, all possible values of the constants mu1 and mu2 are precomputed in the CPU and the calculation results are stored in the global memory of the GPU.
7. A fully homomorphic encryption modular operation system based on GPU, characterized in that: include: A fast modular reduction module is used to implement a GPU-based implementation of the modular reduction of 2X-bit integers a1 and q1, given input parameters a1 and q1 and a constant mu1 related to q1. The result a1 mod q1 is the modular reduction of a1 and q1, where a1 and mu1 are constructed 2X-bit integer data types, q1 is a constructed X-bit integer data type, mu1 is pre-computed in the initialization step of the fully homomorphic encryption scheme based on the fixed value of q1, and q1 is constrained to ensure that no carry occurs in the multiplication statement in the Barrett method. X is the number of operands. Fast modular multiplication module, used to implement the modular multiplication of X-bit integers of a2 and b2 based on GPU given input parameters a2, b2, q2, and constant mu2 related to b2 and q2 Where a2, b2, q2, and mu2 are all X-bit integer data types. mu2 is pre-calculated in the initialization step of the fully homomorphic encryption scheme using the fixed values of b2 and q2. b2 is a pre-set fixed operand. Calculate the modular reduction result a1 mod q1 of the 2X-bit integers a1 and q1, including: Calculation results and store it in 64-bit unsigned integer registers; for a1, split it into 64-bit unsigned integers and perform calculations on 64-bit integer data types respectively; Indicates rounding up; calculate ; Calculate res1=res1-2q1; calculate ; Calculate res1=res1-q1; calculate ; Let a1=res1, return a1 as the calculation result of the algorithm, where the calculation result res1 is stored in 64-bit unsigned integer registers.
8. The GPU-based fully homomorphic encryption modular operation system according to claim 7, characterized in that: The module further includes a modular addition module for calculating the modular addition result a3=a3+b3 or c3=a3+b3 of 2X-bit integers based on the GPU given input parameters a3 and b3, or a3, b3 and c3; Where a3, b3 and c3 are all constructed 2X-bit integer data types.
9. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of a GPU-based fully homomorphic encryption modular operation method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Self-adaptive large integer modular multiplication operation method and device based on homomorphic encryption
CN115374458A
GPU acceleration method for fully homomorphic multiplication
CN118466898A