This repository contains the implementation of the paper "High-Precision Functional Bootstrapping for CKKS from Fourier Extension", built on the OpenFHE library.
Please refer to OpenFHE Installation Documentation.
The Fourier coefficient generation relies on Python scripts. Please ensure you have Python 3 installed with the following libraries:
pip install numpy sympymkdir build
cd build
cmake ..
make -jThe source code for the test experiments is located in src/pke/examples/FEFBS/, which includes test files various benchmarking examples. (e.g. GeLU(x), exp(x))
After a successful build, the corresponding executable binaries are generated in the build/bin/examples/pke/ directory.
The test binaries support two modes of operation for obtaining the necessary Fourier coefficients:
Our framework invokes fourier_calculator.py at runtime to calculate Fourier coefficients. Therefore, you must specify the PYTHONPATH environment variable so the binary can locate the script.
To run a test with online generation (e.g., the exp function):
# Replace [script_path] with the directory of fourier_calculator.py
PYTHONPATH=[script_path] ./build/bin/examples/pke/exp_testYou can bypass the coefficients generation by providing the coefficient file path using the -f flag:
# Example: Running GeLU with pre-computed coefficients
./bin/examples/pke/gelu_test -f ../coeffs/gelucoeff.txtWe provide a Python-based plaintext simulation tool in the project root directory: fourier_extension.py, which is used to prototype the Fourier Extension algorithm and find efficient parameters before running the homomorphic version.
The Parameters of the function can be provided directly via command-line arguments:
-
--func: Target function string (e.g.,"x","exp(x)"). -
--left/--right: Evaluation interval$[a, b]$ . -
--degree: Truncation degree$n$ of the Fourier series.
- Run with default parameters (
$f(x)=x,x\in[-1,1],n=40$ ):
python fourier_extension.pyThe script will output the recommended smoothness parameter, the estimated bit precision, and the generated coefficients:
ke: 33, Precision: 50.5166 bits
Fourier Coefficients (a_n, b_n): [(-3.885780586188048e-18+0j), (-1.8041124150158794e-18-0.625001603545843j), ....]- Evaluate a custom function with specific parameters, like
$f(x)=e^x, x\in[-2,2],n=20$ :
python fourier_extension.py --func "exp(x)" --left -2 --right 2 --degree 20