← Latest papers
💻 computer science

A Constant-Time Implementation Methodology for Activation Functions on Microcontrollers

This paper proposes and validates a constant-time implementation methodology for activation functions on ARM Cortex-M4 microcontrollers that eliminates timing side-channel vulnerabilities through branchless selection, fixed-cost Padé approximations, and cycle alignment, while maintaining high numerical accuracy across multiple function types.

Original authors: Andrii Tyvodar, Andreas Rechberger, Dirmanto Jap, Shivam Bhasin, Bernhard Jungk, Jakub Breier, Xiaolu Hou

Published 2026-05-22
📖 4 min read☕ Coffee break read

Original authors: Andrii Tyvodar, Andreas Rechberger, Dirmanto Jap, Shivam Bhasin, Bernhard Jungk, Jakub Breier, Xiaolu Hou

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you have a smart device, like a fitness tracker or a medical sensor, that uses a "brain" (a neural network) to make decisions. This brain has special switches called activation functions that decide how to process information.

The problem is that these switches are leaking secrets. Just like a person might tap their foot faster when they are excited or slower when they are bored, these software switches take slightly different amounts of time to work depending on the data they are processing. A sneaky hacker standing nearby could listen to these "time taps" and figure out what the device is thinking, or even reverse-engineer the device's brain.

The Old Way: Hiding the Noise

Previously, researchers tried to fix this by adding random noise. Imagine trying to hide a secret code by shouting it out, but then adding random static noise to your voice so no one can hear the pattern. The paper calls this "desynchronization."

The authors tested this and found it didn't work well. Even with the static noise, if a hacker listened long enough and used a clever statistical trick (like a template match), they could still figure out the pattern. It's like trying to hide a fingerprint by smearing it with mud; a skilled detective can still wipe the mud away and find the print.

The New Solution: The "Constant-Time" Factory

The authors propose a completely different approach: Constant-Time Implementation.

Instead of trying to hide the time it takes to do a task, they redesigned the task so it always takes exactly the same amount of time, no matter what the input is.

Think of it like a factory assembly line:

  • The Old Way: If a worker gets a small box, they finish in 2 seconds. If they get a big box, they take 5 seconds. An observer can tell the size of the box just by watching the clock.
  • The New Way: The factory is redesigned so that every worker, regardless of box size, takes exactly 5 seconds.
    • If the box is small, the worker does the job in 2 seconds, then sits still and waits for 3 seconds (doing "dummy" work) to fill the time.
    • If the box is big, they work for the full 5 seconds.
    • Result: To an outside observer, every single task takes exactly 5 seconds. The timing secret is gone.

How They Did It (The Toolkit)

To build this "perfectly timed" factory on tiny computer chips (microcontrollers), the authors used four main tools:

  1. No "If/Then" Branches: Computers often slow down or speed up based on decisions (like "If the number is negative, do X; otherwise, do Y"). The authors removed these decisions. Instead, they calculate both possibilities and use a mathematical "mask" to pick the right one instantly, without pausing to decide.
  2. The "Padé" Shortcut: Calculating complex curves (like Sigmoid or Tanh) is slow and varies in time. The authors replaced these heavy calculations with a clever, fixed-step math shortcut (a rational approximation) that always takes the same number of steps.
  3. Dummy Arithmetic: For the simplest switch (ReLU), which usually takes almost no time, they added "dummy" math steps. This is like the worker sitting still; it ensures the simple switch takes the same long time as the complex ones.
  4. Cycle Alignment: They carefully counted every single "tick" of the computer's clock to ensure that every function finishes at the exact same moment.

The Results

The team tested this on five common activation functions (ReLU, Sigmoid, Tanh, GELU, and Swish) on an ARM Cortex-M4 chip (common in embedded devices).

  • Timing: In the old, unprotected version, the time varied wildly. In the new version, every single input took exactly 108 clock cycles (about 1.3 microseconds). The timing was perfectly flat.
  • Accuracy: They worried that adding dummy steps and shortcuts might make the math wrong. However, they found the errors were tiny—so small that for practical purposes, the device's brain still thinks correctly.
  • Speed: Surprisingly, for the complex functions, the new method was actually faster than the old standard methods because the shortcuts were more efficient, even though they added dummy steps to match the timing.

The Bottom Line

The paper proves that you can build a "time-proof" activation function for small devices. By forcing every calculation to take the exact same amount of time, you stop hackers from listening to the device's "heartbeat" to steal secrets. It's a practical, efficient way to make embedded AI safer without breaking the device's performance.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →