Part I Chapter 5

Three masked datasets: ASCADr, ESHARD and CHES_CTF

Contents
  1. Where the datasets come from
  2. Profiling vs attack
  3. What is inside each file
  4. Why ASCADr
  5. A first look

This guide uses three public datasets of side-channel traces from AES-128. All three come from implementations protected with Boolean masking (Chapter 4), and in all three the attack targets the first round. They differ in the chip, what was measured, and how long each trace is:

DatasetChipMeasuredProfiling / attack tracesSamples per trace
ASCADr8-bit AVR (ATmega8515)EM emissions200,000 / 10,0002,000
ESHARD32-bit ARM Cortex-M4EM emissions90,000 / 10,0001,400
CHES_CTF32-bit ARM Cortex-M4power30,000 / 10,00015,000

Where the datasets come from

All three are public benchmarks from the side-channel research community:

  • ASCADr: the variable-key version of ASCAD (ANSSI SCA Database), released by ANSSI, the French cybersecurity agency, as a benchmark for deep-learning side-channel research (github.com/ANSSI-FR/ASCAD (opens in a new tab)).
  • ESHARD: the trimmed public version of ESHARD-AES128, electromagnetic measurements of a masked and shuffled AES-128. The trim keeps the first round, without shuffling.
  • CHES_CTF: traces released for the Capture-the-Flag competition at CHES 2018 (Cryptographic Hardware and Embedded Systems), the field’s main academic conference.

The original recordings run to hundreds of thousands of samples per trace, so the paper works on trimmed, resampled windows around the first AES round. Those are the files used here.

Profiling vs attack

The attack in Chapter 3 needed no training: it assumed the chip leaks the Hamming weight and used that assumption to test every key guess. A profiled attack learns how the chip leaks instead, in two steps:

  1. Profiling, on a copy of the chip whose key the attacker sets. Each trace comes with its plaintext and key, so its label is known, and a model trains on them to predict the label from the trace: the S-box output for ASCADr, its Hamming weight for ESHARD and CHES_CTF.
  2. Attack, on the target. Each trace comes with its plaintext only. For every trace the trained model gives a probability to each possible label: 256 for ASCADr, 9 for the Hamming weight. A key guess g says which label each trace should have, computed from Sbox[p ⊕ g]; adding up the logarithms of the probabilities the model gave those labels scores the guess, and the true key should score highest. Chapter 9 works through this scoring.
Profiling, then attack 1. Profiling, on a copy of the chip: key known 2. Attack, on the target: key unknown train profiling set traces, plaintexts, keys model trace → label attack set traces, plaintexts trained model a probability for each label key ranking summed over traces, best guess first
A profiled attack. The model learns from a chip the attacker controls, then turns each target trace into a probability for each label; adding them up over many traces ranks the key guesses.

Every dataset is split the same way, into a profiling set and an attack set recorded from different encryptions, so the model is tested on traces it has never seen. ASCADr and CHES_CTF draw a new random key for every profiling trace and use one fixed key for the whole attack set, as a real target would. ESHARD uses one fixed key for every trace in both sets, so the model trains on the very key it later attacks; a real attacker couldn’t do that.

The attack set’s key is stored too, because these files were recorded in a lab; that’s what lets us score an attack. No real attacker has it.

What is inside each file

Each dataset is a single .h5 file, in the HDF5 format: a container for large numerical arrays, organized like a filesystem, with groups (folders) holding datasets (arrays). You open it with a library such as h5py:

Inside the ASCADr file ascad-variable_70k-90k_20.h5 (ASCADr) Profiling_traces/ Attack_traces/ traces 200,000 × 2,000 EM measurements metadata plaintext, key, masks per trace traces 10,000 × 2,000 EM measurements metadata plaintext, key, masks per trace

The metadata array is the ground truth: each record holds the values that produced the trace in the same row. From plaintext and key you can compute every trace’s label, as in Chapter 3:

label = sbox[plaintext[byte] ^ key[byte]]   # identity model
hw    = popcount(label)                     # Hamming weight model

Why ASCADr

Most chapters use ASCADr, for four reasons:

  • It’s the benchmark. ASCAD has been the standard target for deep-learning side-channel research since 2018, so results on it compare directly with published ones, including the paper this guide follows, which runs its mask-recovery experiments on ASCADr.
  • Its labels keep the whole byte. ASCADr labels each trace with the S-box output itself, 256 classes (the identity model); ESHARD and CHES_CTF label it with the output’s Hamming weight, 9 classes. The finer label lets later chapters ask which values the network confuses, not only how many bits it tracks.
  • Its metadata include the masks. Every ASCADr record stores the 18 mask bytes of the masking scheme; ESHARD stores 2 and CHES_CTF none. Without them we could still train a model, but not check the claim this guide is built around: that the network recovers mask shares it was never given as labels.
  • It’s the easiest to work with: the largest profiling set (200,000 traces) and the shortest traces (2,000 samples of int8).

ESHARD and CHES_CTF come back near the end, to check which results carry over to other chips. Field-by-field detail and download links are in the appendix.

A first look

The figures below come from the data exploration notebook (opens in a new tab), which also opens a file by hand, reads one metadata record and computes the SNR.

Trace shapes. Chapter 2 showed one trace from each dataset, and they look nothing alike: ESHARD’s are short, CHES_CTF’s long and spiky. The measurement explains most of it. ASCADr and ESHARD record electromagnetic emissions with a probe held near the chip; CHES_CTF records the current the chip draws from its supply. The chips differ too (an 8-bit AVR and two ARM Cortex-M4 boards), and with them the clock speed and the trace length.

Within one dataset the setup is fixed, so traces from different encryptions almost coincide:

Twelve ASCADr traces, overlaid -100 -80 -60 -40 -20 0 20 930 940 950 960 970 980 990 1,000 1,010 time sample ADC units
Twelve ASCADr profiling traces, samples 930 to 1,010, drawn on top of each other. Each encryption had a different plaintext, key and masks, yet the traces differ by only a few units. That small difference is where the data leaks, mixed with noise.

Scale. The three datasets store their samples in different types and ranges:

DatasetStored asMinMaxMeanStd
ASCADrint8−9825−63.025.9
ESHARDfloat32−48530.09.3
CHES_CTFfloat160115.756.88.5

Statistics over the first 20,000 profiling traces (30,000 for CHES_CTF). A network trains best on inputs of similar size, so Chapter 8 standardizes every sample before training.

Within a dataset, traces from different encryptions differ by only a few units, and somewhere in those units is the S-box output. Which samples carry it, and how strongly? Chapter 6 measures it.