Part IV Chapter 15
ESHARD: one jump, masks we can check
Contents
Part 3 built a method on a chip where every answer was known. This part runs it on real ones, starting with ESHARD: electromagnetic measurements of an ARM Cortex-M4 running a masked AES, from Chapter 5. It is the right place to start because its traces come with their masks. The method never uses them, but they let us check every reading it makes.
The network is the paper’s, the same one Chapters 8 to 10 attacked with: four layers of 40 neurons with ReLU bends, trained for 100 epochs to predict the Hamming weight of the S-box output, with a checkpoint saved after every epoch. The toy network of Part 3 was built with the same shape. Everything below runs on the 10,000 attack traces.
One jump
Chapter 12 split the network’s information into two coarser questions. On ESHARD:
Nothing until epoch 3. At epoch 4 the jump the paper reports: 0.044 bits per trace at epoch 5, almost all of it about whether the weight is high or low. About even or odd the network learns nothing, at any epoch. That is the paper’s finding too: ESHARD’s network separates high from low and never even from odd. After epoch 12 the information falls, below zero by the end, as the network overfits; Chapter 10 showed that it still recovers the key.
So in the terms of Part 3, ESHARD’s network does the first, easy step and stops. If the explanation from the toy chip holds, it should still be reading the weights of the two shares, roughly.
The plane
As in Chapter 14, we take the first layer’s numbers before the bend at epoch 5, the epoch the paper studies, and look for the two axes using only the labels.
There is one difference from the toy network. There, the two shares filled the first two principal components. Here they don’t: the first component holds 34% of the layer’s variation and has nothing to do with either share (its correlation with each weight is 0.13 at most). So the search tries every pair among the first six components, and every angle, and keeps the one that fits the share-weight table best. It picks the second and third components. The paper did the same by eye: it found the high-low pattern off the diagonals at epoch 5 and turned the components before patching.
On the left is what an attacker sees: the labels sort themselves by diagonals, low in two opposite corners and high in the other two, the pattern of the table. On the right is what only the published masks show: the weight of the mask changes along one axis. The two axes found from the labels follow the published weights of mask and masked share with correlations of 0.88 and 0.87.
Reading the masks
Pinning each axis in turn and ranking the traces by the network’s high-minus-low score, exactly as in Chapter 14, gives two readings per trace. Against the published masks:
The readings correlate 0.82 and 0.84 with the true weights. They are exact for 47% and 50% of the traces, and within one for 94% and 95%. That is far from the toy chip’s 88%, and the reason is the chip: the two shares leak with a signal-to-noise ratio under 0.4 here, against about 8 on the toy. For comparison, probes trained on the same layer with the published masks read the weights exactly 54% of the time. Patching gets most of the way there without the masks.
Where they leak
The first reading leaks around sample 36, the second around sample 840: the same places where the published mask and masked share leak. The mask shows two close peaks, at samples 36 and 43. The mask is handled first, as on the toy chip, and as the paper finds on CHES_CTF. Without the published masks, this figure is how an attacker would know which reading is the mask: by where it leaks.
Which way up
One thing the method can’t settle on ESHARD is orientation. As Chapter 14 showed, the labels can’t tell the pair of weights from its mirror image, 8 − w for both; they can only tell whether the two readings point the same way. On the toy chip the trace settled the rest, because its samples rise with the number of 1 bits. Here they don’t follow one rule: at sample 36 the published mask weight correlates +0.49 with the trace, at sample 840 the masked share’s weight correlates −0.52. An electromagnetic probe picks up changes in the current, and the same weight can push one sample up and another down. Nothing else known leaks strongly enough in this window to calibrate it: the plaintext bytes barely show, with a signal-to-noise ratio of 0.004 at most, nearly a hundred times below the shares. So an attacker gets the two weights up to one global flip. Here the readings came out upside down, and the numbers above are after flipping both, which only the published masks could tell us to do.
Why it stops at high or low
Chapter 12 explained why parity comes second: it needs both weights read exactly, and a mistake of one in either weight flips it. On ESHARD both readings are exact for only 24% of traces at once, and the parity of their sum is right 51% of the time, a coin toss. Even the probes trained with the masks get both weights exact for only 29% of traces, and the parity of their sum right 51% of the time. The first layer doesn’t hold the weights sharply enough for parity to be worth learning, which fits a network that never learns it.
That is an explanation, not a proof: a deeper network, or more traces, might find a sharper reading somewhere else. But it is the same picture as the toy chip’s, and the noise is where the two chips differ most.
Epoch by epoch
Before the jump, patching reads nothing: about 20% exact, the score of guessing in the right proportions. At epoch 4 it jumps with the information, to 43%, and stays around 50% through epoch 10. From then on it slowly declines as the network overfits, and so do the probes, which start from the score of always guessing weight 4, 28%. On ESHARD, the shares are in the first layer exactly when the network starts to know something, and not before.
What this confirms: on a real chip, with only the labels, the network’s first layer holds the weights of mask and masked share along two directions; pinning one makes the output follow the other; and the weights read out this way match the published masks well enough to be useful, at the places in the trace where the masks leak. Chapter 16 tries the same on CHES_CTF, which has two jumps and no published masks.