Skip to content

antoniocgj/MOSFHET

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MOSFHET: Optimized Software for FHE over the Torus

MOSFHET is a research-oriented highly-optimized implementation of TFHE. It includes the main techniques proposed so far for improving performance or error rate in TFHE. The library is fully portable with optional optimizations for Intel AVX2, FMA, AVX-512, and VAES.

Citation

@article{guimaraes_mosfhet_2024,
	title = {{MOSFHET}: {Optimized} {Software} for {FHE} over the {Torus}},
	issn = {2190-8516},
	url = {https://doi.org/10.1007/s13389-024-00359-z},
	doi = {10.1007/s13389-024-00359-z},
	journal = {Journal of Cryptographic Engineering},
	author = {Guimarães, Antonio and Borin, Edson and Aranha, Diego F.},
	month = jul,
	year = {2024},
}

Paper Eprint 2022/515

Implemented Techniques

  • The Functional [1] or Programmable [2] Bootstrap and its improved version [3].

  • The Circuit Bootstrap [4] and its optimizations [3].

  • The multi-value bootstrap [3,5] and its optimizations [6].

  • The Key Switching [7] and its optimizations [8].

  • The BlindRotate Unfolding [9] and its optimizations [10].

  • The Full TRGSW bootstrap.

  • Three different approaches [3,12,13] for evaluating the Full-Domain Functional Bootstrap (FDFB).

  • Public Key compression using randomness seed [14].

  • BFV-like multiplication [3].

  • Bootstrap using Galois Automorphism [15], adapted to TFHE and optimized for an all-odd case.

For more details, see our paper. It considers the initial commit (0d58320559) of the library in this repository.

Build

By default, we use the AVX-512 version of SPQLIOS for fast polynomial arithmetic. It requires AVX-512 support. You can use the option FFT_LIB to specify other libraries, and the option A_PRNG to choose the PRNG used to generate/expand a (options are: shake, vaes, xoshiro, and no).

Default compilation (using AVX-512 SPQLIOS):

make

AVX2/FMA build (without AVX512 or VAES):

make FFT_LIB=spqlios A_PRNG=none ENABLE_VAES=false

AVX2/FMA build (without AVX512 or VAES) with Xoshiro:

make FFT_LIB=spqlios A_PRNG=xoshiro ENABLE_VAES=false

FFNT library (pure-C, fully portable):

make FFT_LIB=ffnt A_PRNG=none ENABLE_VAES=false

For other compiling options, see the Makefile and Makefile.def.

Running

There are two main ways of using MOSFHET:

  1. The most efficient is to compile your code and MOSFHET together. We do that for our benchmark.c and tests.c files, and for the examples in the applications folder. See the Makefile in our basic template for building an application.
  2. Dynamic or Static Link. After compiling MOSFHET as a library, you can dynamically/statically link it with your code. See MOSFHET_MCA for an example. Please note that this should add significant performance overhead (as function inlining is disabled for almost the entire library.)

Examples

For examples on how to use MOSFHET, see our unit tests file and the applications folder.

Unit tests and Benchmark

We provide a set of unit tests and a simple benchmark file for the library. They use parameters hard-coded at the beginning of each file. The default parameters are high memory consuming (they are the same as TFHEpp Level 2). The parameters can be reduced in exchange for performance (especially for the Key Switching) or error rate.

To run the unit tests (It is expected for many of the tests to fail depending on the parameters):

make test -B

make test FFT_LIB=spqlios -B

make test FFT_LIB=ffnt -B

To run the benchmark:

make bench -B

make bench FFT_LIB=spqlios -B

make bench FFT_LIB=ffnt -B

License

Apache License Version 2.0

This repository includes code from the following third party libraries:

Additionally, our library may contain small code snippets, variable names, or implementation logic based on or adapted from:

About

MOSFHET: Optimized Software for FHE over the Torus

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published