-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.m
79 lines (58 loc) · 2.92 KB
/
main.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
% main file of the Soft Analytical Side Channel Attack
% author: Kostas Papagiannopoulos - [email protected] - kpcrypto.net
% CAROLINE DELETED...GOODBYE CAROLINE
clear all;
close all;
% the global variable spec is the SASCA experiment specifications provided
% by the user
global spec
% the global variable fg contains the factor graph, with the
% variable/factor nodes (fg.Nodes) and the messages passed on their edges
% (fg.Edges)
global fg
% matlab execution path
spec.path = 'C:\Users\nxf51168\Desktop\projects\sasca_new';
% add also the necessary subfolders to the path
addpath(genpath(spec.path));
addpath(genpath(strcat(spec.path, '\core')));
addpath(genpath(strcat(spec.path, '\profiles')));
addpath(genpath(strcat(spec.path, '\cipher')));
% start the SASCA experiment and factor graph
start_sasca();
%run SASCA for several simulated experiments
result_table_prob = cell(spec.NoAttackTraceTrials, spec.NoSimulatedExperiments);
result_table_found = zeros(spec.NoAttackTraceTrials, spec.NoSimulatedExperiments);
result_table_rank = zeros(spec.NoAttackTraceTrials, spec.NoSimulatedExperiments);
for experiment_index = 1:spec.NoSimulatedExperiments
% simulate the attack values for the variables of current experiment
specify_attack_values();
% update the factor graph with the attack values and generate attack
% traces from the attack values
generate_attack_traces();
% the fg.Node fields .AttackValues and .AttackTraces are updated
% run SASCA on the same dataset and output the attack results different number of attack traces
attack_trace_index = 1;
for current_no_attack_traces = spec.AttackTracesVector
sprintf('Computing BP experiment %d with %d attack traces', experiment_index, current_no_attack_traces)
% run belief propagation algorithm on the factor graph
[probability_of_secret, secret_found, secret_rank] = belief_propagation(current_no_attack_traces);
% store the results for all experiments and all indexes of attack
% traces
result_table_prob{attack_trace_index, experiment_index} = probability_of_secret;
result_table_found(attack_trace_index, experiment_index) = secret_found;
result_table_rank(attack_trace_index, experiment_index) = secret_rank;
attack_trace_index = attack_trace_index + 1;
end
end
% compute the average success rate of SASCA across experiments
average_success_rate = mean(result_table_found, 2);
std_success_rate = std(result_table_found, 0, 2);
% compute the average rank of SASCA across experiments (max rank is 1)
average_rank = mean(result_table_rank, 2);
std_rank = std(result_table_rank, 0, 2);
% plot the results
plot_results(average_rank, average_success_rate, std_rank, std_success_rate);
% the program has ended
hello = 'banana_co'
we = 'really_love_you'
and = 'we_need_you'