Part I Chapter 6
Where the key leaks: signal-to-noise ratio
Contents
A trace has thousands of samples (2,000 in ASCADr), and only a handful depend on the key byte. The attack in Chapter 3 assumed it knew which one to use. This chapter builds the map it was missing: a score for every sample, called the signal-to-noise ratio (SNR), that says how strongly that sample depends on the label.
The label is the value the attack goes after, worked out for each trace from its plaintext and key. In this chapter it’s the Hamming weight of the S-box output, HW(Sbox[p ⊕ k]): how many of the 8 bits the chip computes are set. Working it out takes the key, so the SNR is computed on the profiling set from Chapter 5, where every trace’s key is recorded.
The map serves twice in this guide: to aim an attack, and later to check whether a trained network looks where the leak is. On an unprotected chip it shows one sharp peak. On a masked chip that peak disappears, and two new ones appear where the chip handles the shares.
One sample, many traces
Take a simulated chip whose traces have 60 samples: six clock cycles of ten samples each. Every cycle draws one current pulse, and the pulse is taller when the byte handled in that cycle has more bits set. In the fourth cycle that byte is the S-box output Sbox[p ⊕ k]; in the other five it’s unrelated data.
Now fix one instant and read it in every trace: one number per trace. Here are eight traces, sorted by label, read at two instants:
At sample 32 the values climb with the label, unevenly but clearly. At sample 12 they don’t: a trace with label 1 reads 6.1, one with label 8 reads 3.2. That’s the compare step from Chapter 3 with the roles swapped. There the sample was fixed and 256 key guesses competed; here the key is known, so every label is right, and it’s the samples that compete.
Signal and noise
Eight traces can mislead, so take all 2,000 and group them by label. If the sample depends on the label, each group sits at its own height.
Two numbers describe each panel:
- Signal is how far apart the group averages sit (the red line). It’s what the label does to the sample.
- Noise is the spread inside each group, where the label is fixed. It’s everything else: other operations running at the same time, the measurement setup, thermal noise.
At sample 12 the red line is flat: no signal. At sample 32 it climbs about 0.6 for every extra bit, and each group’s spread is narrower than that climb.
The SNR is the ratio of the two, both measured as variances:
where is the value at sample and is the label. Sample 32 scores 2.97, sample 12 scores 0.004.
The SNR curve
Computing the SNR at every sample gives the SNR curve. Its peak marks where the chip handles the label:
What the SNR predicts for an attack
When the leak follows the label in a straight line, as it does here, the SNR fixes the correlation CPA reaches with the true key [1]:
Chapter 3’s chip leaked the Hamming weight (variance 2) under noise σ = 2, so its SNR was 2/4 = 0.5 and ρ = 0.58, the value that chapter quoted. Sample 32 here gives 0.86. The traces CPA needs grow roughly as , which for small SNR is about 1/SNR: cut the SNR by ten and the attack needs about ten times more traces.
Sample 12’s 0.004 is not a tiny leak. Nothing at sample 12 depends on the label; the score is how far nine group averages scatter by chance when the smallest groups hold fewer than ten traces. That floor shrinks with more traces and grows with more groups, so a real leak has to stand clear of it, not just above zero.
The widget below runs the same chip with the same random draws, so it starts from the numbers above. Two settings are worth trying. At noise σ = 1.5 the peak drops to 0.35 and the correlation at sample 32 to about 0.5, as √(SNR/(1+SNR)) predicts. At 200 traces the flat samples climb to around 0.04: the floor, with ten times fewer traces.
On a masked chip, the peak moves
Before measuring, predict. The SNR only finds samples that depend on the value you group by. On a masked chip (Chapter 4) the S-box output never appears in the circuit: the chip handles the mask m and the masked share Sbox[p ⊕ k] ⊕ m, and each of those, on its own, is a uniform random byte. So grouping by the S-box output should give a flat curve everywhere, and grouping by either share should give a peak where the chip handles it.
The widget’s masked chip tests this on the simulation: it handles the mask in the second cycle and the masked share in the fourth. Scan it grouped by Sbox[p ⊕ k], then by each share.
ASCADr lets us test it on real traces, because its metadata store the mask of every trace. Take 20,000 ASCADr profiling traces and compute the SNR three times, grouping by the Hamming weight of a different value each time:
The prediction holds. Against the unmasked output, the SNR never leaves the noise floor; its maximum is 0.0011. Against the masked share it peaks at 3.8 near sample 1,526, over three thousand times higher. The mask leaks too, at a different moment: 2.0 near sample 970. Each share leaks on its own, at its own sample, and the unmasked value only shows up when the two are combined.
Drawing this figure took the true masks, which only the lab has. An attack has to reach the same combination without them.
All three datasets
The flat half of the story holds in every dataset. Grouped by the Hamming weight of the S-box output, no sample in any of the three rises above 0.0015:
The curves hover a few ten-thousandths above zero, the scatter nine group averages show by chance with this many traces, and a few samples spike to about 0.001. Nothing comes close to the masked share’s 3.8.
That gives the map this guide uses from here on. In ASCADr the leak peaks at two places, sample 970 for the mask and sample 1,526 for the masked share, and nowhere for the S-box output itself. Can a model trained on traces and S-box labels, never shown the masks, learn to combine those two samples on its own? Chapter 7 introduces the network that tries.
References
- S. Mangard, E. Oswald, T. Popp, Power Analysis Attacks: Revealing the Secrets of Smart Cards, Springer 2007 (opens in a new tab). Chapter 4 defines the SNR of a power trace; Chapter 6 relates it to the correlation of a CPA attack and to the number of traces it needs.