Part II Chapter 10
Perceived information
Contents
Chapter 9 recovered key bytes by adding up the network’s votes over many traces, and measured the attack by how many traces it needs. That number takes hundreds of traces and 40 random draws to estimate, and it says nothing about a single trace. This chapter measures what one trace is worth to the network, in bits, and follows that amount through training. The measure is called perceived information, and it is the one the paper uses to watch its networks learn.
Bits
A bit of information is what it takes to cut the possibilities in half. If a byte can be any of its 256 values with equal chance, learning it exactly takes 8 bits: 256 halved eight times is 1. Each answer to a yes-or-no question about the byte, asked well, is worth one bit.
When the possibilities aren’t equally likely, the average number of bits needed to pin the value down is its entropy. For a value that takes each outcome with frequency f, it is the average of −log₂ f. The Hamming weight of a random byte is a good example. Weight 4 covers 70 of the 256 byte values, 27%, while weights 0 and 8 cover one value each:
Hamming weight 0 1 2 3 4 5 6 7 8
byte values 1 8 28 56 70 56 28 8 1
frequency 0.4% 3.1% 10.9% 21.9% 27.3% 21.9% 10.9% 3.1% 0.4%
Its entropy is 2.54 bits. That is everything there is to know about the label of a Hamming-weight network: a network that read the weight off every trace perfectly would gain 2.54 bits per trace. A network with identity labels, like the ASCADr one, has 8 bits to gain.
How much one trace tells the network
Chapter 8 measured a network by its loss: minus the logarithm of the probability it gave the true label, averaged over traces. Taken in base 2 instead of the natural logarithm, the same average is in bits: it is how many bits the network is still missing about the label after seeing the trace. The natural logarithm divided by ln 2 = 0.693 gives the base-2 one.
Perceived information (PI) is what the network gained: the bits it had to learn minus the bits it is still missing.
PI = entropy of the label − loss in bits
The guessing line of Chapter 8 is where the two are equal. A network that knows only how often each label occurs scores a loss of 1.76, about 2.54 bits: the entropy itself, so its PI is 0. Below the guessing line, PI is positive; at a perfect network it reaches 2.54. Here is ESHARD’s best epoch from Chapter 8, read this way:
loss on attack traces, epoch 12 1.726 = 2.490 bits
entropy of the label 2.545 bits
perceived information 0.055 bits per trace
PI is the loss turned over, with two things gained: its zero means “learned nothing from the trace”, and its unit, the bit, means the same for every dataset and every labelling. The repo’s information function computes it exactly this way.
It is called perceived because it is the information as the network perceives it. The trace may carry more; PI only counts what this network has extracted, and only as much as the network’s probabilities admit to.
Confidence isn’t knowledge
PI can go below zero. That happens when the network does worse than guessing by frequency, and the usual reason isn’t that it knows nothing. It is that it is too sure of itself. A network that gives 0.99 to a wrong label and 0.003 to the true one is charged 8.4 bits for that trace, and a few such traces outweigh many good ones.
The widget takes the toy network trained in Chapter 8 on the simulated chip and changes only how sure it is. Before the softmax, its scores are multiplied by a factor: below 1 the probabilities flatten toward each other, above 1 they sharpen toward its favourite. The order of the nine labels never changes. The left panel follows one test trace; the right one shows PI over the 500 test traces as the factor changes.
As trained, each test trace tells the network 1.36 of the 2.51 bits it would take to know the Hamming weight for sure (this test set’s entropy). Make it timid and PI drops, because the true label gets less probability than it deserves. Make it more confident and PI rises a little, peaks near ×1.25 at 1.38 bits, then falls, and goes below zero past about ×5.4. At ×6 the traces it gets right cost only 0.06 bits each on average, against 0.48 as trained; the ones it gets wrong cost 2.70, against 0.68. Switch the left panel to the trace it gets wrong to see why: as trained it gives the true weight 0.23; at ×6, 0.003.
Through all of this the accuracy stays at 69% and the key byte ranks first for good after 5 traces. Neither depends on how sure the network is, only on which labels it prefers and by how much relative to each other. Multiplying every score by the same factor stretches every gap between the 256 key guesses’ evidence by that factor, and a ranking doesn’t change when all its gaps are stretched equally.
This is what Chapter 9 found on ESHARD. Measured in bits, its attack loss gives a PI of +0.016 at epoch 4, the epoch the paper reports as the start of learning, and a best of 0.055 at epoch 12. After epoch 27 PI turns negative and ends at −0.29 bits at epoch 100. Yet at epoch 100 the attack recovers the key with 633 traces. The network kept its preferences and became overconfident about them. Negative PI says the probabilities shouldn’t be taken at face value. It doesn’t say the network learned nothing.
Perceived information over training
Because PI is cheap to compute, one pass over the traces per checkpoint, it can be measured at every epoch. Here is the paper’s CHES_CTF network, the one that needed only 14 traces in Chapter 9, at each of its 200 epochs, on 10,000 of its training traces and on the attack traces:
After its first epoch the network is below zero, −0.11 bits on attack traces: its probabilities are still more confident than what it knows. Over the first 40 epochs it creeps up to about 0.08 bits, and then nothing much happens for nearly 40 epochs. Then, between epochs 77 and 85, PI rises from 0.14 to 0.70 bits. The attack follows: at epoch 76 it needs 115 traces to recover the key byte, at epoch 85 it needs 11. For the rest of training PI stays mostly between 0.6 and 0.95 bits.
The training curve has the same shape, slightly above, so whatever happened at epoch 80 isn’t memorization: it holds on traces the network never saw.
The dips along the way are of two kinds, and PI alone can’t tell them apart. At epoch 106 PI falls to 0.45 bits, but the attack still needs 11 traces, as at epoch 85: the network has become overconfident for an epoch. At epoch 166 PI falls to 0.16 bits and the attack needs 97 traces instead of 8: that time the network really lost something, and got it back within a few epochs.
What perceived information can’t tell
PI is a lower bound. It counts what one network extracted. The chip may leak more, and a better network, or the same one trained longer, could find it. A low PI says this network hasn’t found much; it doesn’t say the chip is safe.
PI also depends on the label chosen. The CHES_CTF network is graded against the Hamming weight of Sbox[p ⊕ k]. On a masked chip that value never appears alone in the trace, so whatever the network found, it found by combining pieces it had to discover itself. PI says when the outputs started to know something about the label. It doesn’t say what changed inside the network to make that happen.
Learning in jumps
The CHES_CTF curve isn’t the steady improvement of the toy network in Chapter 8. It has a long stretch where almost nothing happens and a sudden rise over a few epochs. Why a network on a masked chip learns this way, and what appears inside it at the moment of the jump, is the subject of the third part of this guide.