ReLU Function under FHE
The article details the solution provided by the winners of the ReLU Function challenge.
Authors: Janis Adamek, Dieter Teichrib, Philipp Binfet, and Moritz Schulze Darup from Control and Cyberphysical Systems Group, TU Dortmund, Germany.
Introduction
The rectified linear unit (ReLU) is commonly used as a nonlinear activation function in neural networks (NN). An encrypted implementation of such NN can, e.g., be realized by substituting the ReLU activation with polynomial approximations. In this context, the common limitation to a fixed multiplicative depth often requires polynomial approximations of low or moderate order. For instance, the multiplicative depth for this particular challenge was limited by for Testcase #1 and by for Testcase #2. Now, it is well known in the literature (see [1]) that a multiplicative depth of enables the implementation of polynomials of order in an encrypted fashion.
Testcase #1
For as in Testcase #1, evaluates to . Thus, since very high orders are supported, it has been straightforward to fit a polynomial approximating the ReLU in such a way that % accuracy is achieved for the encrypted samples in the interval . In fact, we simply used OpenFHE's built-in Chebyshev approximation of order . The nearly perfect fit is illustrated in Figure 1.

Figure 1: ReLU approximation using a Chebyshev polynomial of order 1000.
Testcase #2
Obtaining a decent result for Testcase #2 with has been significantly more challenging. In fact, a standard Chebyshev approximation of order (see Figure 2 for the illustration) here resulted in an accuracy of only %.

Figure 2: (left) ReLU approximation using a Chebyshev polynomial of order 15. (right) Chebyshev approximation with error threshold.
We improved this result by applying the following two tricks. First, we formulated a regression problem, which explicitly took the requirements for the challenge into account. More precisely, we considered a regular grid of sample points and searched for a polynomial , which is such that the number of outliers is minimal, where the tolerance has been specified in the task.
Second, we found a way to extend the maximum implementable order to given that the leading coefficient of the polynomial is integer. In fact, in this special case, we can avoid the multiplication (which would have otherwise consumed one level of the available multiplicative depth) and compute the sum with summands using "cheap" encrypted additions (or subtractions). Both tricks, i.e., minimizing the number of outliers and considering an integer lead coefficient can be implemented using mixed-integer (MI) programming. More precisely, we formulated the design problem as an MI linear program (MILP) and solved it using MOSEK [2]. The resulting polynomial is
\begin{align*} &-407.0473x^{12}+230.3549x^{14}-54x^{16} \end{align*}
and it is illustrated in **Figure 3**. The achieved accuracy on **Testcase #2** is $88.4$%.  ***Figure 3**: (left) Approximation of the ReLU function with a polynomial of order 16. (right) Polynomial approximation with error threshold.* ## References [1] **Eunsang Lee, Joon-Woo Lee, Jong-Seon No, and Young-Sik Kim**. Minimax approximation of sign function by composite polynomial for homomorphic comparison. IEEE Transactions on Dependable and Secure Computing, 19(6):3711–3727, 2022. Preprint available online at https://eprint.iacr.org/2020/834 [2] **MOSEK ApS**. The MOSEK optimization toolbox for MATLAB manual. Version 10.0, 2024. https://docs.mosek.com/10.0/toolbox/index.html.CITING THIS WORK
This write-up documents a component of the FHERMA library. If it informs your work, cite the two papers below rather than the article URL.
- 01FHERMA Cookbook: FHE Components for Privacy-Preserving ApplicationsJanis Adamek, Aikata Aikata, Ahmad Al Badawi, Andreea Alexandru, Armen Arakelov, Philipp Binfet, Victor Correa, Jules Dumezy, Sergey Gomenyuk, Valentina Kononova, Dmitrii Lekomtsev, Vivian Maloney, Chi-Hieu Nguyen, Yuriy Polyakov, Daria Pianykh, Hayim Shaul, Moritz Schulze Darup, Dieter Teichrib, Dmitry Tronin, Gurgen ArakelovCryptology ePrint Archive, Paper 2025/1302 · doi:10.1145/3733811.3767313
- 02FHERMA: Building the Open-Source FHE Components Library for Practical UseGurgen Arakelov, Nikita Kaskov, Daria Pianykh, Yuriy PolyakovCryptology ePrint Archive, Paper 2024/612
