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.
-
The Functional [1] or Programmable [2] Bootstrap and its improved version [3].
-
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.
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.
There are two main ways of using MOSFHET:
- 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. - Dynamic Link. After compiling MOSFHET as a shared library, you can dynamically link it with your code. See MOSFHET_MCA for an example.
For examples on how to use MOSFHET, see our unit tests file and MOSFHET_MCA.
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
@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.
This repository includes code from the following third party libraries:
- FFNT: MIT License, Copyright (c) 2021 Jakub Klemsa
- SPQLIOS: Apache License Version 2.0, Copyright 2016 - Nicolas Gama nicolas.gama@gmail.com et al.
- Unity Test: MIT License, Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams
- FIPS202 from Kyber: Public Domain
- xoshiro / xoroshiro: Public Domain, David Blackman and Sebastiano Vigna (vigna@acm.org)
Additionally, our library may contain small code snippets, variable names, or implementation logic based on or adapted from:
- TFHE: Apache License Version 2.0, Copyright 2016 - Nicolas Gama nicolas.gama@gmail.com et al.
- TFHEpp: Apache License Version 2.0, Copyright 2019 Kotaro MATSUOKA
- dbush: CC BY-SA 4.0
- Lattigo: Apache License Version 2.0