Design and implementation of fast fully homomorphic encryption algorithm based on GPU acceleration
Online published: 2024-11-16
Copyright
Fully homomorphic encryption supports direct algebraic operations on encrypted data (ciphertext), with the foundation of its ciphertext evaluation phase involving numerous high-dimensional integer coefficient polynomial ring additions and multiplications. This limits its widespread application in the field of privacy computing. The CPU implementation scheme offers low parallelism for the Number Theoretic Transform (NTT) algorithm calculations. A CPU+GPU heterogeneous fully homomorphic encryption implementation scheme was proposed. Firstly, a cache strategy of data temporarily stored in shared memory was introduced, which stored repeatedly read and unchanging data, including NTT input data and rotation factors, in shared memory to reduce frequent global memory access. Secondly, to address the issue of partially idle threads caused by variable data sizes, it dynamically allocates thread workloads based on data size and hardware resources, adopting butterfly transformation structures of different radices to achieve optimal parallel strategies while enhancing the flexibility of data input. Thirdly, it introduces a single-multi-core mixed invocation mode, dynamically switching the kernel invocation mode based on the group size of butterfly transformations in each NTT iteration, to fully utilize the parallel potential of multi-core invocations on GPU. Finally, it designs and implements a higher parallelism, lower computational complexity NTT algorithm for GPU, uses this algorithm to perform parallel homomorphic multiplication operations, and implements a CPU+GPU heterogeneous CKKS fully homomorphic encryption algorithm based on the HElib library. Experimental results show NTT/INTT computation time is reduced by nearly 65% compared to HElib library using AVX-512 acceleration technology.
TAN Zejiu , ZHAO Xin , WAN Junping , LIU Hucheng , JIANG Lin , XU jinming , JI Shouling , WANG Xuan . Design and implementation of fast fully homomorphic encryption algorithm based on GPU acceleration[J]. Journal of Cybersecurity, 2024 , 2(3) : 41 -52 . DOI: 10.20172/j.issn.2097-3136.240304
表 1 不同基数的NTT对比Table 1 Comparison of NTT with different cardinals |
| NTT基数 | 计算规模 | 迭代次数 | 单次迭代访存次数 | 蝶形变换乘法次数 |
| Radix2 | ||||
| Radix4 | ||||
| Radix8 | ||||
| Radix16 |
表 2 CKKS参数Table 2 Parameters of CKKS |
| 分圆多项 式次数 | 密文模位数 bits | 精度位数 precision | 密钥切换矩 阵的列数c |
| 216 | 1 445 | 20 | 8 |
表 3 GPU参数Table 3 GPU parameters |
| GTX 980 | GTX 1050ti | Quadro RTX 8000 | |
| CUDA核心 | 768 | ||
| 显存/GB | 4 | 4 | 48 |
| 核心频率/MHz | |||
| 显存带宽/GB·s−1 | 224 | 112 | 672 |
表 4 GTX 1050ti 上优化的性能结果Table 4 Performance results optimized on GTX 1050ti |
| 操作 | 方案 | 计算规模(log2N) | |||||
| 11 | 12 | 13 | 14 | 15 | 16 | ||
| NTT | 1 | 12 | 21 | 38 | 73 | 149 | 309 |
| 2 | 95 | 98 | 103 | 109 | 117 | 127 | |
| 3 | 10 | 16 | 32 | − | − | − | |
| 4 | 16 | 32 | 42 | 49 | 61 | ||
| INTT | 1 | 14 | 24 | 40 | 75 | 151 | 315 |
| 2 | 88 | 102 | 108 | 111 | 114 | 118 | |
| 3 | 13 | 17 | 33 | − | − | − | |
| 4 | 13 | 17 | 21 | 30 | 36 | 46 | |
表 5 NTT和INTT实现的性能结果Table 5 Performance results of NTT and INTT |
| 操作 | 平台 | 模数大小( | 计算规模(log2N) | ||||
| NTT | GTX 980 | ||||||
| GTX 1050ti | |||||||
| RTX | |||||||
| INTT | GTX 980 | ||||||
| GTX 1050ti | |||||||
| RTX | |||||||
表 6 不同方案密文乘法时间Table 6 Ciphertext multiplication time of different schemes |
| 参数 | 乘法时间/ms | |
| HElib库 | 本方案 | |
表 7 不同参数下密文推理时间Table 7 Ciphertext inference time under different parameters |
| 计算层 | ||||||||
| HElib库 | 本方案 | HElib库 | 本方案 | HElib库 | 本方案 | |||
| conv2d_1 | ||||||||
| conv2d_2 | ||||||||
| flatten_1 | ||||||||
| dense_1 | ||||||||
| dense_2 | ||||||||
| 总时间 | ||||||||
| 1 |
GENTRY C. A fully homomorphic encryption scheme[M]. California:Stanford University,2009.
|
| 2 |
DUCAS L,MICCIANCIO D. Fhew:Bootstrapping homomorphic encryption in less than a second[C]//Annual International Conference on the Theory and Applications of Cryptographic Techniques. Springer,2015:617-640.
|
| 3 |
CHILLOTTI I,GAMA N,GEORGIEVA M,et al. Faster fully homomorphic encryption:Bootstrapping in less than 0.1 seconds[C]// Advances in Cryptology - ASIACRYPT 2016:22nd International Conference on the Theory and Application of Cryptology and Information Security,Hanoi,Vietnam,December 4-8,2016,Proceedings,Part I,2016:3-33.
|
| 4 |
CHEN H,HAN K. Homomorphic lower digits removal and improved FHE bootstrapping[C]// Annual International Conference on the Theory and Applications of Cryptographic Techniques. Cham:Springer International Publishing,2018:315-337.
|
| 5 |
SMART N P, VERCAUTEREN F. Fully homomorphic SIMD operations[J]. Designs, Codes and Cryptography, 2014, 71, 57- 81.
|
| 6 |
CASTRYCK W,ILIASHENKO I,VERCAUTEREN F. Homomorphic SIM D operations:Single instruction much more data[C]//Annual International Conference on the Theory and Applications of Cryptographic Techniques. Cham:Springer International Publishing,2018:338-359.
|
| 7 |
王励成, 李婧. 无噪声全同态加密浅析[J]. 密码学报, 2017, 4 (6): 579- 595.
WANG L C, LI J. Simple snalysis on noiseless fully homomorphic encryptions[J]. Journal of Cryptologic Research, 2017, 4 (6): 579- 595.
|
| 8 |
NUIDA K,KUROSAWA K. (Batch) fully homomorphic encryption over integers for non-binary message spaces[C]//Annual International Conference on the Theory and Applications of Cryptographic Techniques. Berlin,Heidelberg:Springer Berlin Heidelberg,2015:537-555.
|
| 9 |
AGARWAL R C, BURRUS C S. Number theoretic transforms to implement fast digital convolution[J]. Proceedings of the IEEE, 1975, 63 (4): 550- 560.
|
| 10 |
PANDEY M, FERNANDEZ M, GENTILE F, et al. The transformational role of GPU computing and deep learning in drug discovery[J]. Nature Machine Intelligence, 2022, 4 (3): 211- 221.
|
| 11 |
WANG W,HU Y,CHEN L,et al. Accelerating fully homomorphic encryption using GPU[C]//2012 IEEE Conference on High Performance Extreme Computing. IEEE,2012:1-5.
|
| 12 |
DAI W,DORÖZ Y,SUNAR B. Accelerating NTRU based homomorphic encryption using GPUs[C]//2014 IEEE High Performance Extreme Computing Conference (HPEC). IEEE,2014:1-6.
|
| 13 |
LEI X,GUO R,ZHANG F,et al. Accelerating homomorphic full adder based on fhew using multicore CPU and GPUS[C]//2019 IEEE 21st International Conference on High Performance Computing and Communications; IEEE 17th International Conference on Smart City; IEEE 5th International Conference on Data Science and Systems (HPCC/SmartCity/DSS). IEEE,2019:2508-2513.
|
| 14 |
BERTELS J,VAN BEIRENDONCK M,TURAN F,et al. Hardware acceleration of FHEW[C]//2023 26th International Symposium on Design and Diagnostics of Electronic Circuits and Systems (DDECS). IEEE,2023:57-60.
|
| 15 |
CHEON J H,KIM A,KIM M,et al. Homomorphic encryption for arithmetic of approximate numbers[C]//Advances in Cryptology - ASIACRYPT 2017:23rd International Conference on the Theory and Applications of Cryptology and Information Security,2017:409-437.
|
| 16 |
BRAKERSKI Z, GENTRY C, VAIKUNTANATHAN V. (Leveled) fully homomorphic encryption without bootstrapping[J]. ACM Transactions on Computation Theory (TOCT), 2014, 6 (3): 1- 36.
|
| 17 |
RIAZI M S,LAINE K,PELTON B,et al. HEAX:An architecture for computing on encrypted data[C]//Proceedings of the Twenty-fifth International Conference on Architectural Support for Programming Languages and Operating Systems,2020:1295-1309.
|
| 18 |
REAGEN B,CHOI W S,KO Y,et al. Cheetah:Optimizing and accelerating homomorphic encryption for private inference[C]//2021 IEEE International Symposium on High-Performance Computer Architecture (HPCA). IEEE,2021:26-39.
|
| 19 |
SAMARDZIC N,FELDMANN A,KRASTEV A,et al. F1:A fast and programmable accelerator for fully homomorphic encryption[C]//MICRO-54:54th Annual IEEE/ACM International Symposium on Microarchitecture,2021:238-252.
|
| 20 |
SAMARDZIC N,FELDMANN A,KRASTEV A,et al. Craterlake:A hardware accelerator for efficient unbounded computation on encrypted data[C]//Proceedings of the 49th Annual International Symposium on Computer Architecture,2022:173-187.
|
| 21 |
KIM J,LEE G,KIM S,et al. Ark:Fully homomorphic encryption accelerator with runtime data generation and inter-operation key reuse[C]//2022 55th IEEE/ACM International Symposium on Microarchitecture (MICRO). IEEE,2022:1237-1254.
|
| 22 |
JIANG L,LOU Q,JOSHI N. Matcha:A fast and energy-efficient accelerator for fully homomorphic encryption over the torus[C]// Proceedings of the 59th ACM/IEEE Design Automation Conference,2022:235-240.
|
| 23 |
VAN BEIRENDONCK M,D'ANVERS J P,TURAN F,et al. FPT:A fixed-point accelerator for torus fully homomorphic encryption[C]//Proceedings of the 2023 ACM SIGSAC Conference on Computer and Communications Security,2023:741-755.
|
| 24 |
YANG Y,ZHANG H,FAN S,et al. Poseidon:Practical homomorphic encryption accelerator [C]//2023 IEEE International Symposium on High-Performance Computer Architecture (HPCA). IEEE,2023:870-881.
|
| 25 |
ZHU Y,WANG X,JU L,et al. FxHENN:FPGA-based acceleration framework for homomorphic encrypted CNN inference[C]//2023 IEEE International Symposium on High-Performance Computer Architecture (HPCA). IEEE,2023:896-907.
|
| 26 |
BRUTZKUS A,GILAD-BACHRACH R,ELISHA O. Low latency privacy preserving inference[C]// International Conference on Machine Learning. PMLR,2019:812-821.
|
| 27 |
FAN S,WANG Z,XU W,et al. Tensorfhe:Achieving practical computation on encrypted datausing gpgpu[C]//2023 IEEE International Symposium on High Performance Computer Architecture (HPCA). IEEE,2023:922-934.
|
/
| 〈 |
|
〉 |