A Constant-Time Implementation Methodology for Activation Functions on Microcontrollers

Andrii Tyvodar, Andreas Rechberger, Dirmanto Jap, Shivam Bhasin, Bernhard Jungk, Jakub Breier, Xiaolu Hou · 2026

Read A Constant-Time Implementation Methodology for Activation Functions on Microcontrollers by Andrii Tyvodar, Andreas Rechberger, Dirmanto Jap, Shivam Bhasin, Bernhard Jungk, Jakub Breier, Xiaolu Hou (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2605-22441.txt.

Introduction

Tyvodar and colleagues propose a constant-time method for activation functions on microcontrollers, where timing leaks can expose neural network inference. Their method blends branchless selection, fixed-cost Padé maths, dummy arithmetic and cycle alignment. A desync defence is also tested and shown still open to a timing attack. Protected versions give same cycle counts for all inputs, 88 cycles for three functions and 108 for five. Approximated functions keep high accuracy, offering a practical basis for side-channel-resistant use.

Catalog record

CREATORAndrii Tyvodar, Andreas Rechberger, Dirmanto Jap, Shivam Bhasin, Bernhard Jungk, Jakub Breier, Xiaolu Hou
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE59086
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2605.22441

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

A Constant-Time Implementation Methodology for Activation Functions on Microcontrollers Andrii Tyvodar, Andreas Rechberger, Dirmanto Jap, Shivam Bhasin, Bernhard Jungk, Jakub Breier, Xiaolu Hou Abstract Embedded neural-network inference can leak information through timing side channels, including leakage caused by the evaluation of activation functions. This work proposes a constant-time implementation methodology for activation functions on embedded microcontrollers and validates it on ReLU, sigmoid, tanh, GELU, and Swish on an ARM Cortex-M4 platform. The proposed methodology combines branchless selection, fixed-cost Padé-based approximation, dummy arithmetic where needed, and cycle alignment to obtain timing-regular activation-function implementations. As motivation, we also evaluate a desynchronization-based countermeasure and show that it remains vulnerable to a template-based timing attack. Experimental results show that the resulting protected implementations achieve identical cycle counts for all tested inputs, including 88 88 cycles in the three-function setting and 108 108 cycles in the five-function setting. At the same time, the numerical-error analysis indicates that the approximated nonlinear functions retain high accuracy. These results suggest that the proposed methodology provides a practical basis for constructing side-channel-resistant activation functions in embedded inference. I Introduction Deep neural networks (DNNs) are increasingly deployed on embedded and edge platforms, where inference must be executed under strict constraints on latency, memory usage, and energy consumption. In such settings, software implementations are often optimized at a low level in order to achieve practical performance on microcontrollers and other resource-constrained devices. Prior work has studied neural-network deployment through hardware/software co-exploration [ 12 ] , timing-constrained implementation [ 11 ] , and timing-aware scheduling of DNN workloads [ 13 ] . At the same time, these implementations may expose side-channel leakage, including timing-dependent behavior that can reveal information about the internal computation [ 3 ] . Recent work has shown that neural-network implementations are vulnerable to side-channel analysis, enabling reverse engineering of model architectures and extraction of information about intermediate computations and processed inputs [ 4 , 8 , 16 ] . In particular, activation functions have been identified as a source of distinguishable leakage, since different nonlinearities and different input regions may exhibit characteristic execution patterns [ 23 , 4 ] . This is especially relevant in embedded inference, where timing observations may be accessible to an attacker and where even seemingly simple implementation choices can affect side-channel behavior. A recent direction for mitigating such leakage is to apply hiding-oriented countermeasures, such as desynchronization, in which random delays are introduced in order to obscure the timing pattern of activation-function evaluation [ 5 ] . Such techniques can make the leakage harder to interpret, but they do not remove the underlying input-dependent timing behavior itself. This raises the question of whether a stronger mitigation can be achieved by redesigning activation-function implementations so that their execution time no longer depends on the processed input. In this work, we propose a constant-time implementation methodology for activation functions and instantiate it on five widely used examples: ReLU, sigmoid, \tanh , Gaussian Error Linear Unit (GELU) [ 7 ] , and Swish [ 20 ] . The proposed methodology combines branchless, masking-based selection, cycle-aligned implementation techniques, and, for nonlinear activations, Padé-type rational approximation in order to construct implementations whose execution time is independent of the input value. In contrast to prior work that uses approximation primarily for efficiency, here the approximation also serves as a component of the side-channel countermeasure itself. The overview of the proposed approach, along with the threat model and the experimental results is provided in Fig. 1 . The contributions of this work are as follows: • We propose a constant-time implementation methodology for activation functions on embedded microcontrollers, based on branchless, masking-based selection, fixed-cost Padé approximation based computation, and cycle alignment. • We instantiate this methodology on ReLU, sigmoid, \tanh , GELU, and Swish, using a shared rational approximation for the nonlinear components. • We show, for ReLU, sigmoid, and \tanh , that a desynchronization-based countermeasure can still be attacked using a template-based timing analysis. • We demonstrate experimentally that the protected implementations exhibit identical cycle counts for all tested inputs, including a five-function evaluation over the extended interval [-500,500] in which all protected implementations execute in 108 clock cycles. • We evaluate the resulting trade-offs in execution time and numerical accuracy. Fig. 1 : Summary of the threat model, proposed methodology, and experimental results. Timing leakage in embedded activation-function evaluation is mitigated using a combination of masking-based selection, Padé approximation, fixed-cost dummy arithmetic, and limited cycle-alignment padding. This supports uniform execution latency for both nonlinear and piecewise-linear activation functions while maintaining low approximation error for the nonlinear functions. The remainder of this paper is organized as follows. Section II introduces the considered threat model. Section III reviews the most relevant prior work. Section IV presents the proposed constant-time implementation methodology and its instantiation on the considered activation functions. Section V describes the experimental setup. Section VI presents the experimental results, Section VII discusses their implications and limitations, and Section VIII concludes the paper. II Threat Model We consider an attacker who targets embedded neural-network inference implemented on a microcontroller. The attacker is assumed to be able to observe the execution time of activation-function evaluations, either directly through local interaction or indirectly through repeated timing measurements of the device. In the profiled setting considered in this work, the attacker may additionally collect reference measurements from known activation functions to build statistical models and use them to classify unknown observations. The attacker’s objective is to exploit timing leakage to distinguish activation functions and, more generally, to infer information about the internal behavior of the neural-network implementation. This information can support higher-level goals such as model analysis, reverse engineering, or the identification of sensitive computation patterns. The goal of the proposed methodology is therefore to suppress timing leakage in activation-function execution, rather than merely obscure it through randomization or desynchronization. III Background and Related Work This section reviews prior work most relevant to the present study. Section III-A summarizes side-channel attacks on neural-network implementations, with emphasis on leakage from activation functions. Section III-B discusses countermeasures against timing-based side-channel attacks, including hiding-oriented approaches. Section III-C then positions the present work with respect to constant-time implementation techniques, while Section III-D reviews approximation-based activation-function implementations for embedded inference. III-A Side-Channel Analysis Attacks on Neural-Network Implementations Side-channel analysis (SCA) attacks on neural-network implementations have received increasing attention in recent years. Prior work has shown that physical leakages such as electromagnetic emanations, power consumption, and timing behavior can reveal information about model architectures, secret parameters, and confidential input data [ 4 , 8 , 27 , 16 , 24 ] . Among the components of neural-network inference, activation functions have been identified as a particularly informative source of leakage. [ 23 ] demonstrated that activation functions exhibit distinct EM emanation patterns and can be distinguished accordingly. [ 4 ] showed that the activation type can be inferred from execution-time behavior. More generally, timing-based side-channel attacks exploit input-dependent execution latency to infer sensitive information about the target system. In the context of machine learning, such attacks have been shown to reveal information about inputs, classes, and model behavior [ 22 , 1 ] . III-B Desynchronization and Hiding-Based Countermeasures Against SCA Attacks Compared with the growing literature on

Read the complete text