Appendix
Datasets guide
This appendix is a reference for the files behind every chapter: what each one holds, how its fields are laid out, and how to load it. Chapter 5 describes the chips and why each dataset is in the guide.
All three datasets and the trained networks come from the paper’s Zenodo record (opens in a new tab). Our fork of the authors’ code (opens in a new tab) downloads and unpacks them with scripts/download_files.sh into data/ and models/, which git ignores.
File inventory
| File | Size | Traces (profiling / attack) | Samples per trace | Trace type |
|---|---|---|---|---|
eshard.h5 | 563 MB | 90,000 / 10,000 | 1,400 | float32 |
ASCADr/ascad-variable_70k-90k_20.h5 | 504 MB | 200,000 / 10,000 | 2,000 | int8 |
ches_ctf/ches_ctf_nopoi_window_20.h5 | 1.2 GB | 30,000 / 10,000 | 15,000 | float16 |
The three files share one HDF5 layout, two groups with the same two arrays:
<file>.h5
├── Profiling_traces/
│ ├── traces (N_profiling × n_samples)
│ └── metadata (N_profiling,) one record per trace
└── Attack_traces/
├── traces (N_attack × n_samples)
└── metadata (N_attack,) one record per trace
Each row of traces is one measurement: axis 0 is the trace, axis 1 the time sample. Each element of metadata is a record with the values the chip worked on for that trace.
ESHARD
Profiling_traces/
traces (90000, 1400) float32
metadata (90000,) plaintext u1[16], key u1[16], masks u1[2]
Attack_traces/
traces (10000, 1400) float32
metadata (10000,) plaintext u1[16], key u1[16], masks u1[2]
| Field | Type | Contents |
|---|---|---|
plaintext | uint8[16] | the 16 plaintext bytes |
key | uint8[16] | the 16 key bytes, the same in every trace of both sets |
masks | uint8[2] | two random mask bytes per trace |
The loader builds the two shares of Chapter 15 from the second mask byte: the mask itself, and the S-box output Sbox[p ⊕ k] XORed with it. Class: ReadEshard in src/feature_emergence/datasets/load_eshard.py.
ASCADr
Profiling_traces/
traces (200000, 2000) int8
metadata (200000,) plaintext f8[16], key f8[16], masks f8[18]
Attack_traces/
traces (10000, 2000) int8
metadata (10000,) plaintext f8[16], key f8[16], masks f8[18]
| Field | Type | Contents |
|---|---|---|
plaintext | float64[16] | the 16 plaintext bytes, stored as floats |
key | float64[16] | the 16 key bytes: a new random key for every profiling trace, one fixed key for the attack set |
masks | float64[18] | one mask byte per byte of the AES state, then r_in (index 16) and r_out (index 17), used around the S-box |
Chapter 17 uses all three kinds of mask. The traces are raw signed bytes; the loader’s rescale standardizes them by default before training. Class: ReadASCADr in src/feature_emergence/datasets/load_ascadr.py.
CHES_CTF
Profiling_traces/
traces (30000, 15000) float16
metadata (30000,) plaintext f8[16], ciphertext f8[16], key f8[16]
Attack_traces/
traces (10000, 15000) float16
metadata (10000,) plaintext u1[16], ciphertext u1[16], key u1[16]
| Field | Type | Contents |
|---|---|---|
plaintext | float64 / uint8[16] | the 16 plaintext bytes |
ciphertext | float64 / uint8[16] | the 16 ciphertext bytes |
key | float64 / uint8[16] | a new random key for every profiling trace, one fixed key for the attack set |
There is no masks field: the chip is masked, but the masks weren’t published, which is why Chapter 16 checks its readings without them. The two groups store their bytes with different types, floats for profiling and bytes for attack; the loader converts both. Class: ReadCHESCTF in src/feature_emergence/datasets/load_chesctf.py.
Keys
| Dataset | Attack key (hex) | Target byte |
|---|---|---|
| ESHARD | 077bda0fab1e5501ead0150ab1e020fe | 2 |
| ASCADr | 00112233445566778899aabbccddeeff | 2 |
| CHES_CTF | 175cf2997a8583413c77dfac7e6c59d8 | 2 |
ESHARD uses the same key for profiling too. Every attack in the guide targets byte 2, as the paper does.
Loading in code
Through the package, which finds the files under data/:
from feature_emergence.utils import load_dataset
ds = load_dataset("eshard", traces_dim=1400, leakage_model="HW")
ds = load_dataset("ascad-variable", traces_dim=2000, leakage_model="ID")
ds = load_dataset("ches_ctf", traces_dim=15000, leakage_model="HW")
ds.x_profiling, ds.profiling_labels # traces and labels
ds.profiling_keys, ds.profiling_plaintexts, ds.profiling_masks
leakage_model picks the label: "ID" is the byte Sbox[p ⊕ k] itself, 256 classes; "HW" is its Hamming weight, 9 classes.
Directly with h5py:
import h5py
f = h5py.File("data/ASCADr/ascad-variable_70k-90k_20.h5", "r")
traces = f["Profiling_traces/traces"][:]
meta = f["Profiling_traces/metadata"][:]
keys, plaintexts, masks = meta["key"], meta["plaintext"], meta["masks"]
Model checkpoints
The same record holds model_checkpoints.tar, the trained networks saved after every epoch. Loading checkpoint k gives the network exactly as it stood after epoch k, which is how the chapters on real chips, from Chapter 8 on, look back in time without retraining.
| Files | Network | Dataset | Checkpoints |
|---|---|---|---|
mlp_ascadr_*.weights.h5 | MLP | ASCADr | 100 |
cnn_ascadr_*.weights.h5 | CNN | ASCADr | 100 |
mlp_eshard__*.weights.h5 | MLP | ESHARD | 100 |
cnn_eshard_*.weights.h5 | CNN | ESHARD | 100 |
mlp_ches_ctf_*.weights.h5 | MLP | CHES_CTF | 200 |
Two quirks of the archive: the ESHARD MLP files have a double underscore (mlp_eshard__01.weights.h5), and the archive also holds a copy of its epoch-100 checkpoint under a single-underscore name, for 601 files in all.