Skip to content

kenmaro3/TFHEpp

 
 

Repository files navigation

TFHEpp

TFHEpp is full Scracthed pure C++ Ver. of TFHE. TFHEpp is slightly(about 10%) faster than original TFHE implementation. In addition to that, THFEpp supports Circuit Bootstrapping and Private Boootstrapping many LUT. TFHEpp depends on AVX2 because we use SPQLIOS FMA. If you want run TFHEpp without AVX2, see spqlios++ branch. It include pure C++ implementation of SPQLIOS as header only library, but slow.

Supported Compiler

This code includes utf-8 identifiers like alpha. Therefore, Clang and GCC10 or later are primarily supported compilers. GCC9 is not supported.

Parameter

The default parameter is 128 bit security. Please add -DUSE_80BIT_SECURITY=ON to use faster but less secure parameter.

Third party libraries

Codes under thirdparties directory contain third-party libraries, Randen, Cereal, and SPQLIOS. See the corresponding directory to check the licenses.

Randen

TFHEpp uses this as a Cryptographically Secure Pseudo-Random Number Generator (CSPRNG). Original repository is here. I just removed some unnecessary codes, no modification.

Cereal

cereal is a header-only C++11 serialization library. TFHEpp uses this to export ciphertexts and keys. Cereal is treated by git submodule.

SPQLIOS

SPQLIOS is the FFT library that is dedicated to the ring R[X]/(X^N+1) for N a power of 2. These codes come from experimental-tfhe. We just renamed instances to adapt with our codes.

Speed Test

Following Code measure how many time homomorphic NAND takes on your computer with TFHEpp.

git clone https://github.com/virtualsecureplatform/TFHEpp
cd TFHEpp
mkdir build
cd build
cmake .. -DENABLE_TEST=ON
make
./test/nand 

If you want to run semantically equivalent test on original TFHE, run below code.

git clone https://github.com/tfhe/tfhe.git --recursive
cd tfhe
mkdir build
cd build
cmake ../src -DENABLE_TESTS=on -DENABLE_NAYUKI_PORTABLE=off -DENABLE_NAYUKI_AVX=off -DENABLE_SPQLIOS_AVX=off -DENABLE_SPQLIOS_FMA=on -DCMAKE_BUILD_TYPE=optim
make
./test/test-gate-bootstrapping-spqlios-fma

If you have Docker on your system, this will do above on docker.

git clone https://github.com/virtualsecureplatform/TFHEpp
cd TFHEpp
docker build -t tfheppbench .

This is for TFHE-10ms. Because TFHE-10ms only supports 80-bit security parameter, this is not included in Dockerfile

git clone https://github.com/virtualsecureplatform/tfhe-10ms.git --recursive
cd tfhe-10ms
mkdir build
cd build
cmake ../src -DENABLE_TESTS=on -DENABLE_NAYUKI_PORTABLE=off -DENABLE_NAYUKI_AVX=off -DENABLE_SPQLIOS_AVX=off -DENABLE_SPQLIOS_FMA=on -DCMAKE_BUILD_TYPE=optim
make
./test/test-bootstrapping-fft-spqlios-fma 

Theory

Here is the slides (in japanese). https://nindanaoto.github.io/

Citation

For the people who want to cite this library directly (may be in addition to VSP paper), I give a below example of bibtex citation.

@misc{TFHEpp,
	author = {Kotaro Matsuoka},
	title = {{TFHEpp: pure C++ implementation of TFHE cryptosystem}},
  	year = {2020},
	howpublished = {\url{https://github.com/virtualsecureplatform/TFHEpp}}
}

About

Pure C++ Ver. of TFHE.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 88.3%
  • Assembly 10.5%
  • Other 1.2%