Part IV Chapter 15

ESHARD: one jump, masks we can check

Contents
  1. One jump
  2. The plane
  3. Reading the masks
  4. Where they leak
  5. Which way up
  6. Why it stops at high or low
  7. Epoch by epoch

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:

ESHARD learns high or low, never even or oddjump-0.3-0.2-0.100.1120406080100epochbits per attack traceallhigh or loweven or odd
Information the paper’s ESHARD network has per attack trace, at each of its 100 epochs. Dashed: perceived information about the full label, from Chapter 10. Blue: about whether the weight is high (5 to 8) or low (0 to 3). Red: about whether it is even or odd. Shaded: the jump.

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.

The plane the labels pick out, epoch 5average labelblue: lower than 4, red: higheraverage published mask weightblue: weight below 4, red: above
The first layer of the ESHARD network at epoch 5, before its ReLU, for the 10,000 attack traces, on the plane chosen from the labels: its second and third principal components, turned to fit the share-weight table. The plane is cut into 14 by 14 cells, and cells with fewer than 15 traces are left out. Left: the average label of each cell, which is all an attacker can draw. Right: the average weight of the published mask.

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:

Share weights read by patching, against the truththe reading that leaks firstweight read by patchingtrue HW(m)012345678012345678exact for 47% of tracesthe reading that leaks secondweight read by patchingtrue HW(s)012345678012345678exact for 50% of traces
Weights of the two shares read out of the ESHARD network at epoch 5 by patching, against the weights of the published masks, for the 10,000 attack traces. Each row is one true weight, and its shade shows how the traces with that weight were read. Both readings are shown after one global flip, which the published masks call for (see below).

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

Where the readings leak, and where the true shares leak00.10.20.30.40200400600800100012001400SNRsample of the ESHARD tracefirst readingsecond reading
Signal-to-noise ratio along the 1,400 samples of the ESHARD attack traces. Solid: the two weights read by patching at epoch 5. Dashed, underneath: the weights of the published mask (blue) and masked share (red).

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

Reading the ESHARD masks, epoch by epochjump00.250.50.75120406080100epochshare weights read exactlypatchingprobe, with masks
Share of ESHARD attack traces whose two share weights are read exactly, average of the two shares, at every epoch, up to one global flip. Blue: patching, which uses only the labels. Dashed: linear probes on the first layer, trained on 10,000 profiling traces with the published masks. Shaded: the jump.

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.