Skip to content

Instantly share code, notes, and snippets.

Created February 14, 2019 15:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
from lascar import *
from import sbox
filename = "/home/johndoe/ASCAD_data/ASCAD_databases/ATMega8515_raw_traces.h5"
# poi = Points Of Interest.
# We use the SNRs computed before to extract time samples where both mask and masked sensitive variable are used.
snrs = DictOutputMethod.load('SNR.pickle') # we load the snr results computed at
poi = []
poi = [snrs['SNR4: masked sbox output in linear parts'][5000].argmax()]
poi += [snrs['SNR5: sbox output mask in linear parts'][5000].argmax()]
# Container creation: we take the same file, but set the leakage_section to the computed poi.
container = Hdf5Container(filename,
container.number_of_traces = 500
# Then we make a container that will apply a CenteredProduct to recombine all the points of interest.
container.leakage_processing = CenteredProductProcessing(container)
# Now a classical CPA, targetting the output of the 3rd Sbox:
cpa_engine = CpaEngine("cpa-high-order",
lambda value, guess: hamming(sbox[value['plaintext'][3] ^ guess]),
session = Session(container,
output_steps=10) # the steps at which the results will be computed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment