Skip to content

Commit

Permalink
[tvla] Enable trace filtering for TVLA-general
Browse files Browse the repository at this point in the history
Tvla has a mechanism for filtering out outlier traces from the
project. At the moment, this filtering is applied only to
aes specific TVLA. This commit enables filtering for general TVLA
as well.
As a result of applied filtering, the expected result of the CI
test test_general_aes_nonleaking_project() has changed. This
commit also updates the expected result of this test, in order
to leave the repository in a working state.

Signed-off-by: Vladimir Rozic <[email protected]>
  • Loading branch information
vrozic committed Oct 6, 2023
1 parent 8a446fc commit f04bbea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
31 changes: 13 additions & 18 deletions cw/tvla.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,28 +483,23 @@ def run_tvla(ctx: typer.Context):
trace_start] + 0.5) * trace_resolution
traces = traces.astype('uint16')

if general_test is False:
# Filter out noisy traces.
log.info("Filtering Traces")
# Filter out noisy traces.
log.info("Filtering Traces")

# Get the mean and standard deviation.
mean = traces.mean(axis=0)
std = traces.std(axis=0)
# Get the mean and standard deviation.
mean = traces.mean(axis=0)
std = traces.std(axis=0)

# Define upper and lower limits.
max_trace = mean + num_sigmas * std
min_trace = mean - num_sigmas * std
# Define upper and lower limits.
max_trace = mean + num_sigmas * std
min_trace = mean - num_sigmas * std

# Filtering of converted traces (len = num_samples). traces_to_use itself can be
# used to index the entire project file (len >= num_samples).
traces_to_use = np.zeros(len(project.waves), dtype=bool)
traces_to_use[trace_start:trace_end + 1] = np.all((traces >= min_trace) &
# Filtering of converted traces (len = num_samples). traces_to_use itself can be
# used to index the entire project file (len >= num_samples).
traces_to_use = np.zeros(len(project.waves), dtype=bool)
traces_to_use[trace_start:trace_end + 1] = np.all((traces >= min_trace) &
(traces <= max_trace), axis=1)
traces = traces[traces_to_use[trace_start:trace_end + 1]]
else:
# For now, don't perform any filtering when doing general fixed-vs-random TVLA.
traces_to_use = np.zeros(len(project.waves), dtype=bool)
traces_to_use[trace_start:trace_end + 1] = True
traces = traces[traces_to_use[trace_start:trace_end + 1]]

if i_step == 0:
# Keep a single trace to create the figures.
Expand Down
4 changes: 2 additions & 2 deletions test/data/tvla_general/ttest-step-golden-aes.npy.npz
Git LFS file not shown

0 comments on commit f04bbea

Please sign in to comment.