Phantom: A Unified, High-Speed GPU Library for Homomorphic Encryption
Homomorphic Encryption (HE) is often described as the "holy grail" of cryptography—it allows us to perform computations on data while it remains encrypted. However, the massive computational overhead of HE has long kept it confined to theoretical research and small-scale prototypes.
In their paper, "Phantom: A CUDA-Accelerated Word-Wise Homomorphic Encryption Library," researchers from Nanjing University, Fudan University, and Zhejiang Lab introduce a high-performance library designed to bridge the gap between HE theory and real-world application.
TL;DR
The authors present Phantom, a unified GPU-accelerated library for the three major word-wise homomorphic encryption schemes: BGV, BFV, and CKKS. By combining theoretical optimizations in key-switching with aggressive CUDA kernel fusing, Phantom achieves significant speedups (up to 1.4x in key-switching) over previous state-of-the-art GPU implementations.
What Problem Does This Paper Address?
While HE provides unparalleled privacy, it is notoriously slow. Word-wise HE schemes (like BGV, BFV, and CKKS) are preferred for practical use because they allow for "batching"—packing multiple data points into a single ciphertext to be processed in parallel (SIMD style).
Despite this, CPU-based libraries (like Microsoft SEAL) are still too slow for complex tasks like deep learning inference. Previous attempts to use GPUs have been fragmented, often focusing on only one scheme or a subset of operations. There was a clear need for a unified framework that optimizes the entire pipeline—from low-level polynomial math to high-level scheme management—across all major HE variants.
Methods
The authors built Phantom from the ground up using a three-layer architecture: a math/polynomial layer, an RNS (Residue Number System) arithmetic layer, and a scheme layer. Their primary innovations include:
- NWT-2D (Number-theoretic Weighted Transform): Instead of a standard 1D transform, they use a hierarchical 2D approach for polynomial multiplication. This reduces register pressure on the GPU, allowing for higher occupancy and fewer slow accesses to global memory.
- Kernel Fusing: This is a major engineering highlight. By "fusing" multiple operations (like modulus-switching and error correction) into a single GPU kernel, they keep data in fast on-chip registers and shared memory, drastically reducing the IO latency caused by moving data back and forth to the GPU's main memory (VRAM).
- Optimized Hybrid Key-Switching: Key-switching is one of the most expensive operations in HE. The authors refined the "hybrid" technique to eliminate redundant transforms, saving significant computational cycles.
- Karatsuba Multiplication: They applied the Karatsuba algorithm to homomorphic multiplication, trading expensive 64-bit multiplications for cheaper additions and shifts at the instruction level.
Datasets
As a systems and cryptography paper, the "datasets" used are standard cryptographic parameter sets rather than traditional machine learning data.
- Security Levels: Parameters were chosen to meet 128-bit security standards based on the LWE estimator.
- Benchmarks: The authors compared Phantom against Microsoft SEAL (the industry-standard CPU library) and the work of Jung et al. (2021), which was the previous state-of-the-art for GPU-based CKKS.
- Hardware: Evaluation was performed on an NVIDIA Tesla A100 80G GPU.
Key Insights and Ideas
- Memory is the Bottleneck: The authors realized that the "math" of HE isn't the only thing slowing down GPUs; it's the data movement. Their focus on kernel fusing proves that managing the GPU's memory hierarchy is just as important as optimizing the underlying algebra.
- Unified Logic: By creating a framework that handles BGV, BFV, and CKKS simultaneously, they demonstrate that these schemes share enough algebraic DNA to benefit from a single, highly-optimized codebase.
- BGV on GPU: This paper provides the first comprehensive performance report for the BGV scheme on a GPU, filling a significant gap in the literature.
Key Results
- Key-Switching Speedup: Phantom achieved a 1.4x speedup in the total time for the key-switching module compared to the previous best implementation.
- NWT/INWT Efficiency: Their optimized transforms showed up to a 19.8% improvement in speed and a 24.7% increase in memory throughput.
- Kernel Fusing Impact: Fusing the
ModDownoperation with error correction in BGV resulted in a speedup of 1.73x to 1.90x for that specific task. - Scalability: Phantom supports larger parameter sizes (polynomial degrees up to $2^{17}$) than many previous works, making it more suitable for complex, deep-circuit computations.
Limitations and Future Work
While Phantom is a major step forward, the authors note a few areas for growth:
- Bootstrapping: Although the library supports the operations needed for bootstrapping (the process of "refreshing" a ciphertext to allow for more computation), a fully optimized, end-to-end bootstrapping benchmark for all three schemes was not the primary focus of this paper.
- Multi-GPU Scaling: The current work focuses on single-GPU performance. Scaling these unified optimizations across multiple GPUs or clusters remains a promising direction for even larger-scale privacy-preserving applications.
The library is open-source and available at: https://github.com/encryptorion-lab/phantom-fhe
Summary updated