-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[analysis] Fix num_traces in TVLA plot #334
Conversation
Previously, when number_of_steps > 1, the TVLA plot only contained the number of traces used for a step, but not the total number of traces processed. This PR fixes the issue, now the total number of used traces is printed in the figure. Signed-off-by: Pascal Nasahl <[email protected]>
@@ -457,6 +457,9 @@ def run_tvla(ctx: typer.Context): | |||
else: | |||
sample_step_hist = 5 | |||
|
|||
# Number of traces after filtering over all steps. | |||
num_traces_used_total = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that this value should always be zero.
The condition of this if branch is:
if (cfg["input_histogram_file"] is None or cfg["output_histogram_file"] is not None) \
and cfg["ttest_step_file"] is None:
so it is possible that cfg["input_histogram_file"] is not None
(e.g. when we specify both input and output histogram files),
so the initial value for num_traces_used_total
should be the number of traces used in the input histogram file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, thanks! However, do we actually read the number of traces of the histogram when cfg["input_histogram_file"]
is provided? Should this be done here:
Line 328 in 6bbb5ac
if cfg["input_histogram_file"] is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're both somewhat right here. The histograms are defined as follows:
# For every time sample we make two histograms, one for Hamming weight of the
# sensitive variable = 0 (fixed set) and one for Hamming weight > 0 (random set).
# histograms has dimensions [num_rnds, num_bytes, 2, num_samples, trace_resolution]
# The value stored in histograms[v][w][x][y][z] shows how many traces have value z
# at sample y, given that HW(state byte w in AES round v) = 0 (fixed set, x = 0) or
# > 0 (random set, x = 1).
When an input histograms file is used, the number of traces used can be computed as sum(histograms[:][:][:][:][0][:]).
Since we already didn't set num_traces_used_total
correctly when loading histograms before this PR. I suggest to create a new issue for tracking and merge this on as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this can be merged as is.
I've added an item to issue #72 to track this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks to both of you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I suggest to create an issue for tracking the handling of the histogram loading feature.
Previously, when number_of_steps > 1, the TVLA plot only contained the number of traces used for a step, but not the total number of traces processed. This PR fixes the issue, now the total number of used traces is printed in the figure.