CUDA-accelerated Fully Homomorphic Encryption Library
v1.0_beta -- release on Mar/14/2018
The cuFHE library is an open-source library for Fully Homomorphic Encryption (FHE) on CUDA-enabled GPUs. It implements the TFHE scheme [CGGI16][CGGI17] proposed by Chillotti et al. in CUDA C++. Compared to the TFHE lib which reports the fastest gate-by-gate bootstrapping performance on CPUs, the cuFHE library yields roughly 20 times of speedup on an NVIDIA Titan Xp graphics card. The cuFHE library benefits greatly from an improved CUDA implementation of the number-theoretic transform (NTT) proposed in the cuHE library [Dai15] by Dai and Sunar.
TFHE lib | cuFHE | Speedup |
---|---|---|
13 ms | 0.5 ms | 26 times |
The library has been tested on Ubuntu Desktop 16.04 only. This "Makefile" is created for Linux systems. Please create your own Makefile for MacOS and Windows. We are working on cross-platform support.
GPU support requires NVIDIA Driver, NVIDIA CUDA Toolkit and a GPU with Compute Capability no less than 6.0. For devices with Compute Capability less than 6.0, there is an issue that have not been solved yet. Any fix or suggestion is welcomed.
Our implementation requires the use of KeyGen, Client1, Client2, Server, and Verif. Simply run the script.sh
file to compile all relevant files. We have used the topology shown in doc
and transferred relevant files using sockets from ports 4380-4388. Operators +, -, x that were created using arithmetic gates can be found in newserver.cu
. IP addresses have been set statically and can be changed be the user.
For more details, do look in doc
for a detailed explanation and analysis of CuFHE utilising Addition, Subtraction, and Multiplication.
- Server: 192.168.0.1
- Verif: 192.168.0.2
- Client1: 192.168.0.3
- Client2: 192.168.0.4
- KeyGen: 192.168.0.5
-
Run
make
from the directorycufhe/
for default compilation. This will- Set static IP addresses according to
Subnet
- create directories
build
andbin
, - generate shared libraries
libcufhe_cpu.so
(CPU standalone), libcufhe_gpu.so
(GPU support) inbin
directory, and 3) create test and benchmarking executablestest_api_cpu
andtest_api_gpu
inbin
.
- Set static IP addresses according to
-
Alternatively, run
make cpu
ormake gpu
for individual library and executable. -
Copy the library files and
include
folder to any desirable location. Remember to export your library directory withexport LD_LIBRARY_PATH=directory
. Runtest_api_gpu
to see the latency per gate. -
We provide a Python wrapper which uses boost-python tool. To use the Python interface, you will need
- a python interpreter, (probably in
/usr/bin/
) - boost-python library, (Run
sudo apt-get install libboost-python-dev
, if you don't have it installed.) - to change the Makefile if your python and boost include/lib paths are different than default,
- to run
make python_cpu
for CPU library andmake python_gpu
for GPU library, and finally - to test the python scripts under
cufhe/python/
.
- a python interpreter, (probably in
Use files in cufhe/test/
as examples. To summarize, follow the following function calling procedures.
SetSeed(); // init random generator seed
PriKey pri_key;
PubKey pub_key;
KeyGen(pub_key, pri_key); // key generation
// alternatively, write / read key files
Ptxt pt[2];
pt[0] = 0; // 0 or 1, single bit
pt[1] = 1;
Ctxt ct[2];
Encrypt(ct[0], pt[0], pri_key);
Encrypt(ct[1], pt[1], pri_key);
Initialize(pub_key); // for GPU library
Nand(ct[0], ct[0], ct[1], pub_key); // for CPU library
Nand(ct[0], ct[0], ct[1]); // for GPU library non-parallelized gates
cudaSteam_t stream_id;
cudaStreamCreate(&stream_id);
Nand(ct[0], ct[0], ct[1], stream_id); // for GPU library parallelized gates
Decrypt(pt[0], ct[0], pri_key);
CleanUp(); // for GPU library
Currently implemented gates are And, Or, Nand, Nor, Xor, Xnor, Not, Copy
.
- version 1.0_beta -- released on Mar/14/2018.
- Supports single-bit unpacked encryption / decryption / gates.
- C++ interface with CPU and GPU separate libraries.
- We appreciate any bug reports or compiling issues.
- Dai and Sunar’s work was in part provided by the US National Science Foundation CNS Award #1319130 and #1561536.
- We gratefully acknowledge the support of NVIDIA Corporation with the donation of the Titan X Pascal GPU used for this research.
[CGGI16]: Chillotti, I., Gama, N., Georgieva, M., & Izabachene, M. (2016, December). Faster fully homomorphic encryption: Bootstrapping in less than 0.1 seconds. In International Conference on the Theory and Application of Cryptology and Information Security (pp. 3-33). Springer, Berlin, Heidelberg.
[CGGI17]: Chillotti, I., Gama, N., Georgieva, M., & Izabachène, M. (2017, December). Faster Packed Homomorphic Operations and Efficient Circuit Bootstrapping for TFHE. In International Conference on the Theory and Application of Cryptology and Information Security (pp. 377-408). Springer, Cham.
[Dai15]: Dai, W., & Sunar, B. (2015, September). cuHE: A homomorphic encryption accelerator library. In International Conference on Cryptography and Information Security in the Balkans (pp. 169-186). Springer, Cham.