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

Maikel Kerkhof, Lichao Wu, Guilherme Perin, Stjepan Picek

Introduction

Side-Channel Analysis (SCA) has evolved from simple statistical attacks to sophisticated Deep Learning (DL) methodologies capable of bypassing hardware countermeasures like masking and noise. While DL is now the "gold standard" for extracting cryptographic keys from physical leakages (e.g., power consumption), the choice of loss function remains a critical bottleneck.

Standard functions like Categorical Cross-Entropy (CCE) suffer from two primary issues in the SCA context:

  1. The "Easy Sample" Problem: Models often become dominated by easy-to-classify samples that provide little information about the underlying hardware leakage, leading to suboptimal convergence and overfitting.
  2. Class Imbalance: Leakage models, such as the Hamming Weight model, are naturally imbalanced. Rare but highly informative states are often ignored by the model in favor of more frequent states.

To address these challenges, researchers from Delft University of Technology have introduced Focal Loss Ratio (FLR), a loss function specifically optimized for the unique constraints of side-channel attacks.

The Focal Loss Ratio (FLR) Methodology

FLR is a hybrid approach that combines the strengths of Focal Loss with ratio-based optimization. It introduces a "modulating factor," $(1 - \hat{y})^\gamma$, which effectively down-weights the loss from easy, well-classified samples. This forces the neural network to "focus" its learning capacity on "hard" samples—those where the model is currently uncertain but which often contain the most critical leakage information.

Comparison of loss functions showing how FLR (purple) and others scale loss values relative to prediction probability.

Beyond focusing, FLR incorporates a ratio-based denominator inspired by Cross-Entropy Ratio (CER). By calculating the loss for incorrect labels, the function encourages the model to maximize the distance between the correct key candidate and all incorrect alternatives. To maintain computational efficiency, the authors optimized the denominator to use only three incorrect sets ($n=3$), ensuring that FLR remains nearly as fast as standard CCE while providing superior separation.

Experimental Evaluation

The effectiveness of FLR was tested against industry-standard benchmarks, including ASCAD (fixed and variable keys) and the highly challenging CHES_CTF dataset. The latter is particularly notable for its high noise levels and masked AES implementation on a 32-bit microcontroller.

Key Results and Performance

The empirical results demonstrate that FLR significantly lowers the barrier for successful attacks:

  • Trace Reduction: In Hamming Weight leakage models, FLR consistently halved the number of traces required to reach a Guessing Entropy (GE) of 1 compared to standard CCE or basic Focal Loss.
  • Efficiency: Unlike previous ratio-based losses that could double training time, FLR with $n=3$ introduces negligible computational overhead.
  • Robustness: On the CHES_CTF dataset, FLR-based Convolutional Neural Networks (CNNs) were among the few models capable of successfully retrieving the secret key, proving its resilience against masking countermeasures.
Guessing entropy and success rate for the CHES_CTF dataset, demonstrating the convergence of various FLR configurations.

Conclusion and Future Work

Focal Loss Ratio represents a significant advancement in DL-based SCA by prioritizing informative "hard" samples and maximizing class separation without sacrificing training speed. While the introduction of hyperparameters $\alpha$ and $\gamma$ requires some tuning, the authors' random search strategies provide a reliable path to peak performance. Future research will focus on applying FLR to even more complex countermeasures, such as advanced shuffling and higher-order masking, where identifying the most informative leakage samples becomes increasingly difficult.

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