Please provide MATLAB code of measurementm AND correct key T
Please provide MATLAB code of measurement.m AND correct key.. Thank you
This lab will introduce you to the basics of the DPA (Differential Power Analysis) - a technique that exploits the dependency of the processed data on the power trace of the device to extract some secret information that would not be otherwise available. The goal is to learn how to process the power trace of the implementation of the AES encryption algorithm using an algebraic system (in our case Matlab) and create the power hypothesis to extract the secret information (secret key of the AES). The entire lab can be found at https://rozvoi.fit.cvut.cz/Lisbon/AnalysisSolution
Matlab code example - loading the data
%%%%%%%%%%%%%%%%%%%%
% LOADING the DATA %
%%%%%%%%%%%%%%%%%%%%
% modify following variables so they correspond
% your measurement setup
numberOfTraces = 200;
traceSize = 350000;
% modify the following variables to speed-up the measurement
% (this can be done later after analysing the power trace)
offset = 0;
segmentLength = 350000; % for the beginning the segmentLength = traceSize
% columns and rows variables are used as inputs
% to the function loading the plaintext/ciphertext
columns = 16;
rows = numberOfTraces;
%%%%%%%%%%%%%%%%%%%%%%%%%
% Calling the functions %
%%%%%%%%%%%%%%%%%%%%%%%%%
% function myload processes the binary file containing the measured traces and
% stores the data in the output matrix so the traces (or their reduced parts)
% can be used for the key recovery process.
% Inputs:
% \'file\' - name of the file containing the measured traces
% traceSize - number of samples in each trace
% offset - used to define different beginning of the power trace
% segmentLength - used to define different/reduced length of the power trace
% numberOfTraces - number of traces to be loaded
%
% To reduce the size of the trace (e.g., to speed-up the computation process)
% modify the offset and segmentLength inputs so the loaded parts of the
% traces correspond to the trace segment you are using for the recovery.
traces = myload(\'traces.bin\', traceSize, offset, segmentLength, numberOfTraces);
% function myin is used to load the plaintext and ciphertext
% to the corresponding matrices.
% Inputs:
% \'file\' - name of the file containing the plaintext or ciphertext
% columns - number of columns (e.g., size of the AES data block)
% rows - number of rows (e.g., number of measurements)
plaintext = myin(\'plaintext.txt\', columns, rows);
ciphertext = myin(\'ciphertext.txt\', columns, rows);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EXERCISE 1 -- Plotting the power trace(s): %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Plot one trace (or plot the mean value of traces) and check that it is complete
% and then select the appropriate part of the traces (e.g., containing the first round).
% --> create the plots here <--
Matlab code example - using the correlation coeficients
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EXERCISE 2 -- Key recovery: %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Create the power hypothesis for each byte of the key and then correlate
% the hypothesis with the power traces to extract the key.
% Task consists of the following parts:
% - create the power hypothesis
% - extract the key using the results of the mycorr function
% variables declaration
byteStart = 1;
byteEnd = 16;
keyCandidateStart = 0;
keyCandidateStop = 255;
% for every byte in the key do:
for BYTE=byteStart:byteEnd
% Create the power hypothesis matrix (dimensions:
% rows = numberOfTraces, columns = 256).
% The number 256 represents all possible bytes (e.g., 0x00..0xFF).
powerHypothesis = zeros(numberOfTraces,256);
for K = keyCandidateStart:keyCandidateStop
% --> create the power hypothesis here <--
end;
% function mycorr returns the correlation coeficients matrix calculated
% from the power consumption hypothesis matrix powerHypothesis and the
% measured power traces. The resulting correlation coeficients stored in
% the matrix CC are later used to extract the correct key.
CC = mycorr(powerHypothesis, traces);
% --> do some operations here to find the correct byte of the key <--
end;

