/MOSFHET

MOSFHET: Optimized Software for FHE over the Torus

Primary LanguageCApache License 2.0Apache-2.0

MOSFHET: Optimized Software for FHE over the Torus

MOSFHET is a pure-C 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, and AVX-512.

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].

For more details, see our paper.

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.

Default compilation (using AVX-512 SPQLIOS):

make

SPQLIOS (FMA):

make FFT_LIB=spqlios

FFNT library (pure-C, fully portable):

make FFT_LIB=ffnt

For other compiling options, see the Makefile.

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. See the test/benchmark rule in the Makefile.
  2. Dynamic Link. After compiling MOSFHET as a shared library, you can dynamically link it with your code. See MOSFHET_MCA for an example.

Examples

For examples on how to use MOSFHET, see our unit tests file and MOSFHET_MCA.

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:

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

Citation

@misc{cryptoeprint:2022:515,
    author       = {Antonio Guimarães and
		    Edson Borin and
		    Diego F. Aranha},
    title        = {MOSFHET: Optimized Software for FHE over the Torus},
    howpublished = {Cryptology ePrint Archive, Report 2022/515},
    year         = {2022},
    note         = {\url{https://ia.cr/2022/515}},
}

The paper consider the initial commit (0d58320559) of the library in this repository.

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: