Autocorrelation of a trace


I was reading rhme3 writeup by cloakware-ctf and there is interesting autocorrelation visualization of a trace. I can’t understand how function of one variable can produce plot like that. I would expect something which is also function of one variable, and that indeed is only thing popping up when googling for autocorrelation.

Does anybody know how to reproduce it?

Here you can check my attempts it: gist


Hi adamws and all,

I guess by now you must have a) found the answer, b) stop looking for it, but I found it quite intriguing and after some research I got what I think is the answer, so I am posting it here in case it helps anybody else who finds this post.

There is an explanation in Efficient multivariate statistical
techniques for extracting secrets from electronic devices (Choudary 2015), sections 3.3.5 and 6.1.1, but put simply, you got almost there - this shows the correlation between each pair of samples in the traces, for all the traces. The name according to the book is “sample correlation”, which sounds more accurate than “autocorrelation”.

The simplest way I have found to do it is just with numpy.corrcoef(traces) (note yo may need to transpose them, and make sure it is a native numpy array) or it will be slow as hell). All put together:
np.corrcoef( np.transpose( np.array(traces) ) )



To add to my previous response, Fault-assisted side-channel analysis of masked implementations (Yao 2018) also contains a brief explanation of how to get this diagram, and a very good description of how to interpret it and use it to reverse engineer the parts of the algorithm (in the context of masked crypto algorithms, also in combination with the use of the standard deviation to identify the generation of randomness for the masks).


1 Like