Appendix

Datasets guide

Contents
  1. File inventory
  2. ESHARD
  3. ASCADr
  4. CHES_CTF
  5. Keys
  6. Loading in code
  7. Model checkpoints

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

FileSizeTraces (profiling / attack)Samples per traceTrace type
eshard.h5563 MB90,000 / 10,0001,400float32
ASCADr/ascad-variable_70k-90k_20.h5504 MB200,000 / 10,0002,000int8
ches_ctf/ches_ctf_nopoi_window_20.h51.2 GB30,000 / 10,00015,000float16

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]
FieldTypeContents
plaintextuint8[16]the 16 plaintext bytes
keyuint8[16]the 16 key bytes, the same in every trace of both sets
masksuint8[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]
FieldTypeContents
plaintextfloat64[16]the 16 plaintext bytes, stored as floats
keyfloat64[16]the 16 key bytes: a new random key for every profiling trace, one fixed key for the attack set
masksfloat64[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]
FieldTypeContents
plaintextfloat64 / uint8[16]the 16 plaintext bytes
ciphertextfloat64 / uint8[16]the 16 ciphertext bytes
keyfloat64 / 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

DatasetAttack key (hex)Target byte
ESHARD077bda0fab1e5501ead0150ab1e020fe2
ASCADr00112233445566778899aabbccddeeff2
CHES_CTF175cf2997a8583413c77dfac7e6c59d82

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.

FilesNetworkDatasetCheckpoints
mlp_ascadr_*.weights.h5MLPASCADr100
cnn_ascadr_*.weights.h5CNNASCADr100
mlp_eshard__*.weights.h5MLPESHARD100
cnn_eshard_*.weights.h5CNNESHARD100
mlp_ches_ctf_*.weights.h5MLPCHES_CTF200

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.