OpenFHE Lattice Cryptography Library - Arbitrary Smooth Function Evaluation

August 15, 2025 · View on GitHub

License Information

Document Description

This document describes how to evaluate an arbitrary smooth function on a ciphertext in CKKS using Chebyshev approximation. The Chebyshev approximation is a method of approximating a smooth function using polynomials. Note that Chebyshev evaluation only works with real inputs (or complex inputs with zero imaginary parts).

Example Description

The example for this code is located in function-evaluation.cpp. The file gives examples on how to run EvalLogistic, the logistic function 11+ex,\frac{1}{1 + e^{-x}}, and an arbitrary function using EvalChebyshevFunction. We use the square root function in our example for EvalChebyshevFunction.

Input Parameters

  • ciphertext: This is the ciphertext we wish to operate on.
  • a: This is the lower bound of underlying plaintext values we could have.
  • b: This is the upper bound of underlying plaintext values we could have.
  • degree: This is the polynomial degree of the Chebyshev approximation. A higher degree gives a more precise estimate, but takes longer to run.

How to Choose Multiplicative Depth

Each run of EvalChebyshevFunction requires a certain number of multiplications which depends on the input polynomial degree. We give a table below to map polynomial degrees to multiplicative depths.

DegreeMultiplicative Depth
3-54
6-135
14-276
28-597
60-1198
120-2479
248-49510
496-100711
1008-203112
2032-403113
4032-812714
8128-1625515
16256-3263916
32640-6527917
65280-13081518
130816-26163119

Note that if we use a range (a,b)=(1,1),(a, b) = (-1, 1), the multiplicative depth is 1 less than the depths listed in the table.