Part IV Chapter 17
ASCADr: the hard case
Contents
ASCADr is the dataset the first half of this guide ran on. Chapter 5 introduced it: electromagnetic measurements of an 8-bit AVR chip running a masked AES, 2,000 samples per trace. It is the field’s most used benchmark, and the paper’s network for it is the one Chapter 7 took apart: six layers of 100 neurons with ELU bends, trained for 100 epochs on the whole S-box output byte, 256 classes. Chapter 9 showed that after 100 epochs it recovers the key byte from 86 traces.
Three things make it harder than ESHARD and CHES_CTF. The label is the whole byte, not its Hamming weight, so there is no high-or-low and no parity to read. An 8-bit chip doesn’t leak a byte’s weight so much as its individual bits, each with its own strength. And ASCAD’s masking uses more than one mask. This chapter follows the paper through the first two, reproduces what can be reproduced with the published checkpoints, and reports one thing that can’t.
Three pairs of shares
ASCADr’s metadata store 18 mask bytes: one for each byte of the AES state, and two more, r_in and r_out, used around the S-box. For key byte 2, three pairs of values come up. The S-box input x = p ⊕ k is handled as the pair r_in and x ⊕ r_in. Its output y = Sbox[x] appears as r_out and y ⊕ r_out, and as r_2 and y ⊕ r_2, with byte 2’s own mask. Each pair XORs back to the value it hides, and each half alone is a uniform random byte.
Since the chip leaks bits, the signal-to-noise ratio of Chapter 6 can be measured for each bit of each share, grouping the attack traces by that bit alone. Here is the highest value along the 2,000 samples:
| share | bit 0 | bit 1 | bit 2 | bit 3 | bit 4 | bit 5 | bit 6 | bit 7 |
|---|---|---|---|---|---|---|---|---|
r_in | 0.10 | 0.30 | 0.04 | 0.12 | 0.04 | 0.04 | 0.04 | 0.05 |
x ⊕ r_in | 0.69 | 0.66 | 0.08 | 0.29 | 0.18 | 0.11 | 0.10 | 0.26 |
r_2 | 0.36 | 0.28 | 0.11 | 0.08 | 0.07 | 0.11 | 0.10 | 0.11 |
y ⊕ r_2 | 0.35 | 0.21 | 0.17 | 0.15 | 0.50 | 0.23 | 0.06 | 0.14 |
r_out | 0.76 | 0.46 | 0.08 | 0.16 | 0.05 | 0.06 | 0.07 | 0.09 |
y ⊕ r_out | 0.09 | 0.11 | 0.13 | 0.10 | 0.11 | 0.13 | 0.13 | 0.13 |
The bits leak very unequally. In most shares bits 0 and 1, the two lowest, leak far more than the rest. The last row is the exception, and it is not because y ⊕ r_out is quiet: grouped by its Hamming weight, as in Chapter 6, it reaches 4.3 near sample 1,195, more than the 3.8 of the masked share Chapter 6 found. It leaks the way the shares on ESHARD and CHES_CTF do, a little through every bit at once, so no single bit stands out. Its partner r_out does the opposite, almost all through bits 0 and 1. The pair with r_2 is the one Chapter 6 showed, the mask near sample 970 and the masked share near 1,526.
Two bits at a time
The paper follows learning with probes, as in Chapter 13, but one per bit: a linear readout of each of the 8 bits of x and each of the 8 bits of y from the network’s last hidden layer. Trained on 10,000 profiling traces and scored on the attack traces, for every published checkpoint:
This is the paper’s finding, reproduced. Before epoch 7 nothing can be read. Between epochs 7 and 13, bit 1 of the input becomes readable, from 0.51 to 0.71, and bit 0 less so, up to 0.59. Between epochs 13 and 22, bits 0 and 1 of the output follow, from about 0.52 to 0.65. The other twelve bits never pass 0.54. After epoch 25 the curves slowly decline, the network overfitting as ESHARD’s did.
Each bit of x is the XOR of the same bit of its two shares, so to know a bit the network has to read it in both shares and combine them: the bitwise version of the parity CHES_CTF learns at its second jump. The table above suggests why these bits and not others. The input bits it learns are the ones where both halves of the pair leak, and bit 1, whose weaker half leaks three times more than bit 0’s, is learned better. For the output, the pair with r_2 is the one where bits 0 and 1 leak in both halves, and they are the only bits above 0.2 in both. The pair with r_out leaks plenty, but never the same bit clearly in both halves.
The table doesn’t explain everything. Bit 3 of the input pair leaks about as well in its weaker half as bit 0, and the network never learns it. A single peak value per bit is a crude summary of how a bit leaks.
Which shares the first layer sharpens
The same kind of probe on the first layer shows which shares the network works on. Here each probe reads bit 0 or bit 1 of one share, using the published masks to train and score it, and the curves average the four probes of each pair:
None of the curves start at 0.5. The first layer of an untrained network is a random mix of the trace’s samples, and a linear probe on it can read some of whatever leaks. What matters is the rise. The input pair sharpens first, from 0.69 at epoch 6 to 0.81 at epoch 12, while the network learns the input bits. The pair with r_2 sharpens next, from 0.70 to 0.81 between epochs 12 and 22, while it learns the output bits. The pair with r_out never moves. The network sharpens the two pairs whose bits it learns, in the order it learns them, and leaves the third alone.
Two runs that disagree
Up to here the published checkpoints tell the paper’s story. One measurement doesn’t. Here is perceived information, from Chapter 10, at every epoch:
The paper’s figure, and the output saved in the authors’ notebook for this network, show perceived information turning positive at epoch 8, +0.71 bits per trace, and rising to 2.92 at epoch 56. The published checkpoints, run here, never get above +0.01. From epoch 8 they fall below zero and keep falling, to −9.4 bits at epoch 100. Before epoch 8 both are near zero, as for any network that hasn’t learned anything, and from there they part.
Negative perceived information on its own isn’t strange. Chapter 10 showed that a network which is too sure of its wrong answers scores below zero even while it recovers the key, and this one does recover it: the average probability it gives the true value rises from 1/256, 0.0039, to 0.0055 at epoch 12 and 0.0101 at epoch 25, in step with the probes. What is strange is that it happens on the traces the network trained on. On 5,000 of its own profiling traces the published checkpoint at epoch 100 scores −9.2 bits; for its first 10,000 profiling traces the authors’ notebook saved +4.67. A network can’t be that wrong about its own training data unless the data it is given differs from the data it trained on.
We looked for the difference and didn’t find it. Standardizing with 20,000, 100,000 or all 200,000 profiling traces, scaling each trace on its own, or not scaling at all: none gives positive values. Labelling the traces with any of the other 15 key bytes, or with the S-box input, the plaintext, or a masked value instead of the S-box output: byte 2’s S-box output fits best, as it should, and still scores below zero. So the published checkpoints learn the paper’s features at the paper’s epochs, but their outputs don’t behave like the run in the notebook. Retraining the network might tell why. We haven’t.
Reading the masks
The paper tries the method of Chapter 14 here too, and reports that it only partly works. In the second layer at epoch 12 it finds the two input shares on two principal components, in a 3 by 3 grid rather than the 4 by 4 that four values of two bits would give: two of the four values of each share leak almost identically and overlap. Pinning those components doesn’t work; pinning a similar pair in the first layer does change the output, measured with probes on the last layer. But the readings sort the traces into two or three groups per share, where there should be four, they leak far more weakly than the true shares, and the readings of the two input shares don’t XOR back to the right label bits.
We haven’t tried to do better here. The readings of Chapter 14 rest on the table of Hamming weights: they sort traces by a score and cut the ranking where the binomial counts say. For bits, the score, the table and the cuts all have to be rebuilt. The check of Chapter 16 would carry over, since the XOR of two exact readings must give the label’s bit, but it needs readings to check first. ASCADr is where the method, as it stands, stops.
What carries over from the other two chips: the network learns in steps, each step is a feature that combines two shares, and the first layer sharpens exactly the shares it combines, in the order it uses them. What doesn’t: the clean geometry that made the masks readable on ESHARD and CHES_CTF. Chapter 18 asks what all this is good for.