Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Screaming Channel Attack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Ferreol Axel
Screaming Channel Attack
Commits
a23592c4
Commit
a23592c4
authored
2 years ago
by
Ferreol Axel
Browse files
Options
Downloads
Patches
Plain Diff
Add preprocess file
parent
cd76d5f3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
preprocess.py
+43
-0
43 additions, 0 deletions
preprocess.py
preprocess_2.py
+43
-0
43 additions, 0 deletions
preprocess_2.py
with
86 additions
and
0 deletions
preprocess.py
0 → 100644
+
43
−
0
View file @
a23592c4
from
re
import
TEMPLATE
from
os
import
path
import
numpy
as
np
from
matplotlib
import
pyplot
as
plt
from
scipy
import
signal
def
shift_trace
(
trace
,
shift
):
length
=
len
(
trace
)
trace_aligned
=
np
.
zeros
((
length
),
dtype
=
np
.
float32
)
if
shift
<
0
:
shift
=
length
+
shift
trace_aligned
[:
length
-
shift
]
=
trace
[
shift
:]
trace_aligned
[
length
-
shift
:]
=
trace
[:
shift
]
return
trace_aligned
num_points
=
25000
#number of traces
precision
=
100
#interval of prints
open_path
=
""
#path to the traces
save_path
=
""
#path to save preprocessed traces
template_path
=
""
#path to save the template
for
index
in
range
(
num_points
):
trace
=
np
.
load
(
path
.
join
(
open_path
,
"
avg__{}.npy
"
.
format
(
index
)))
if
index
<
1
:
template
=
trace
np
.
save
(
path
.
join
(
save_path
,
"
avg__{}.npy
"
.
format
(
index
)),
trace
)
continue
else
:
correlation
=
signal
.
correlate
(
trace
**
2
,
template
**
2
)
shift
=
np
.
argmax
(
correlation
)
-
(
len
(
trace
)
-
1
)
trace
=
shift_trace
(
trace
,
shift
)
np
.
save
(
path
.
join
(
save_path
,
"
avg__{}.npy
"
.
format
(
index
)),
trace
)
template
=
(
trace
+
(
float
(
index
))
*
template
)
/
(
float
(
index
+
1
))
if
index
%
precision
==
0
:
print
(
"
Nb processed={}
"
.
format
(
index
))
np
.
save
(
template_path
,
template
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
preprocess_2.py
0 → 100644
+
43
−
0
View file @
a23592c4
import
sys
import
os
from
os
import
path
,
system
import
numpy
as
np
from
matplotlib
import
pyplot
as
plt
from
scipy
import
signal
def
shift_trace
(
trace
,
shift
):
length
=
len
(
trace
)
trace_aligned
=
np
.
zeros
((
length
),
dtype
=
np
.
float32
)
if
shift
<
0
:
shift
=
length
+
shift
trace_aligned
[:
length
-
shift
]
=
trace
[
shift
:]
trace_aligned
[
length
-
shift
:]
=
trace
[:
shift
]
return
trace_aligned
profile_traces_path
=
""
# repertoire des 25 000 traces pour le profile
open_path
=
""
#repertoire des 2 500 traces collectees pour l attaque
save_path
=
""
#repertoire de sauvegarde des 2 500 traces pour l attaque
num_points_profile
=
50000
traces
=
[]
for
index
in
range
(
num_points_profile
):
traces
.
append
(
np
.
load
(
path
.
join
(
profile_traces_path
,
'
avg__%d.npy
'
%
(
index
)
)
)
)
template
=
np
.
average
(
traces
,
axis
=
0
)
num_points_attack
=
25000
for
index
in
range
(
num_points_attack
):
if
index
%
500
==
0
:
print
"
Nb processed= %d
"
%
index
trace
=
np
.
load
(
path
.
join
(
open_path
,
'
avg__%d.npy
'
%
(
index
)
)
)
correlation
=
signal
.
correlate
(
trace
**
2
,
template
**
2
)
shift
=
np
.
argmax
(
correlation
)
-
(
len
(
template
)
-
1
)
trace
=
shift_trace
(
trace
,
shift
)
np
.
save
(
path
.
join
(
save_path
,
'
avg__%d.npy
'
%
(
index
)
),
trace
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment