# ################### # START SOLUTION # ##########guessed_byte######### import numpy as np mean_diffs = np.zeros(256) one_list = [] zero_list = [] guessed_byte = 0 numtraces = 1000 for trace_index in range(numtraces): #Get a hypothetical leakage list - use aes_internal(guess, input_byte) hypothetical_leakage = textin_array[trace_index][guessed_byte] #Mask off the lowest bit - is it 0 or 1? Depending on that add trace to array if hypothetical_leakage & 0x80: one_list.append(trace_array[trace_index]) else: zero_list.append(trace_array[trace_index]) one_avg = np.asarray(one_list).mean(axis=0) zero_avg = np.asarray(zero_list).mean(axis=0) difference = np.subtract(one_avg,zero_avg) #Plot the difference! %matplotlib notebook import matplotlib.pylab as plt plt.figure() #plt.plot(one_avg) #plt.plot(zero_avg) plt.plot(difference) plt.xlabel("Time") plt.ylabel("Values") plt.title("Traces") plt.legend() plt.show() # ################### # END SOLUTION # ###################