Focus is Key to Success: A Focal Loss Function for Deep Learning-Based Side-Channel Analysis

Maikel Kerkhof, Lichao Wu, Guilherme Perin, Stjepan Picek

TL;DR

Researchers from Delft University of Technology have introduced Focal Loss Ratio (FLR), a new loss function specifically optimized for deep learning-based Side-Channel Analysis (SCA). By combining the "focusing" power of Focal Loss with a ratio-based approach to maximize class separation, FLR significantly outperforms traditional loss functions, often halving the number of traces required to break a target while maintaining high training efficiency.

What Problem Does This Paper Address?

Side-Channel Analysis (SCA) is a technique where attackers exploit physical leakages—like power consumption or electromagnetic emissions—to steal cryptographic keys from hardware. Recently, Deep Learning (DL) has become the "gold standard" for these attacks because it can bypass hardware countermeasures like masking or noise without manual feature engineering.

However, most DL-based SCA still relies on standard loss functions like Categorical Cross-Entropy (CCE). CCE has two major flaws in this context:

  1. The "Easy Sample" Problem: In many datasets, most samples are "easy" to classify, but they don't help the model learn the subtle nuances of the hardware leakage. These easy samples dominate the loss, leading to overfitting.
  2. Class Imbalance: Leakage models (like Hamming Weight) are naturally imbalanced; some states occur much more frequently than others, causing the model to ignore the rarer, more informative states.

While SCA-specific losses like Cross-Entropy Ratio (CER) exist, they are often computationally expensive, significantly slowing down the training process.

Methods

The authors propose Focal Loss Ratio (FLR). This novel function merges two powerful ideas:

  • Focal Loss: It introduces a "modulating factor" $(1 - \hat{y})^\gamma$ that down-weights the loss contributed by easy, well-classified samples. This forces the model to "focus" its learning effort on "hard" samples that are currently misclassified.
  • Ratio-based Optimization: Inspired by CER, FLR uses a denominator that calculates the loss for incorrect labels. By minimizing the ratio, the model doesn't just try to get the right answer; it tries to maximize the "distance" between the correct key candidate and all the wrong ones.

Crucially, the authors found that using only three incorrect sets ($n=3$) in the denominator provides the best balance between attack performance and training speed, making it much faster than previous ratio-based losses.

Datasets

The study evaluates FLR across three industry-standard benchmarks:

  • ASCAD_fixed: A dataset based on a masked AES-128 implementation with a fixed key.
  • ASCAD_variable: A more challenging version of ASCAD using random keys during the profiling phase.
  • CHES_CTF: A dataset from the 2018 CHES Challenge featuring masked AES on a 32-bit STM microcontroller, known for its high noise and difficulty.

Key Insights and Ideas

  • Hard Samples are the Key: The "aha moment" here is that in SCA, the samples the model finds difficult are often the most informative about the underlying hardware leakage. By prioritizing these "hard" samples, the model develops a more robust understanding of the device's behavior.
  • Efficiency Matters: Previous SCA-specific losses (like CER) were powerful but slow. FLR achieves similar or better results while being nearly as fast as standard CCE.
  • Robustness to Countermeasures: FLR proved to be more resilient than CCE when attacking devices protected by masking. It effectively "sees through" the noise by focusing on the samples where the leakage is most prominent.
  • Hyperparameter Flexibility: The paper explores three tuning strategies: fixed values, random search, and class re-balancing. While random search (FLR_optimized) often yields the best results, even the "default" settings ($\alpha=0.25, \gamma=2.0$) consistently beat standard methods.

Key Results

  • Trace Reduction: In the Hamming Weight leakage model, FLR halved the number of traces required to reach a Guessing Entropy (GE) of 1 compared to CCE or standard Focal Loss.
  • Superior Performance: On the difficult CHES_CTF dataset, FLR-based models were among the only ones to successfully retrieve the secret key when using Convolutional Neural Networks (CNNs).
  • Training Speed: While the CER loss function doubled training time (with $n=10$), FLR (with $n=3$) showed negligible computational overhead compared to standard CCE.
  • Consistency: FLR outperformed or matched the state-of-the-art CER loss in three out of four primary test scenarios on the ASCAD_fixed dataset.

Limitations and Future Work

The primary limitation acknowledged is the hyperparameter space. FLR introduces two new parameters ($\alpha$ and $\gamma$), which require tuning to reach peak performance. While the authors provide a successful random search strategy, finding the "perfect" settings for a brand-new dataset still requires some trial and error.

For future work, the authors plan to explore how FLR performs against even more complex countermeasures, such as advanced shuffling or higher-order masking, where the "hard samples" are even harder to find.

Summary updated

BibTeX
@inproceedings{kerkhof2022focus,
  author = {Maikel Kerkhof and Lichao Wu and Guilherme Perin and Stjepan Picek},
  title = {{Focus is Key to Success: A Focal Loss Function for Deep Learning-Based Side-Channel Analysis}},
  booktitle = {COSADE},
  year = {2022},
  doi = {10.1007/978-3-030-99766-3\_2},
}
Figure