Part I Chapter 5
Three masked datasets: ASCADr, ESHARD and CHES_CTF
Contents
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:
| Dataset | Chip | Measured | Profiling / attack traces | Samples per trace |
|---|---|---|---|---|
| ASCADr | 8-bit AVR (ATmega8515) | EM emissions | 200,000 / 10,000 | 2,000 |
| ESHARD | 32-bit ARM Cortex-M4 | EM emissions | 90,000 / 10,000 | 1,400 |
| CHES_CTF | 32-bit ARM Cortex-M4 | power | 30,000 / 10,000 | 15,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:
- 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.
- 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
gsays which label each trace should have, computed fromSbox[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.
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:
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:
Scale. The three datasets store their samples in different types and ranges:
| Dataset | Stored as | Min | Max | Mean | Std |
|---|---|---|---|---|---|
| ASCADr | int8 | −98 | 25 | −63.0 | 25.9 |
| ESHARD | float32 | −48 | 53 | 0.0 | 9.3 |
| CHES_CTF | float16 | 0 | 115.75 | 6.8 | 8.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.