pyecsca.sca.align module

This module provides functions for aligning traces in a trace set to a reference trace within it.

pyecsca.sca.align.align_correlation(reference, *traces, reference_offset, reference_length, max_offset, min_correlation=0.5)[source]

Align traces to the reference trace. Using the cross-correlation of a part of the reference trace starting at reference_offset with reference_length and try to match it to a part of the trace being matched that is at most max_offset mis-aligned from the reference, pick the alignment offset with the largest cross-correlation. If the maximum cross-correlation of the trace parts being matched is below min_correlation, do not include the trace.

Parameters:
  • reference (Trace) –
  • traces (Trace) –
  • reference_offset (int) –
  • reference_length (int) –
  • max_offset (int) –
  • min_correlation (float) –
Return type:

List[Trace]

Returns:

pyecsca.sca.align.align_peaks(reference, *traces, reference_offset, reference_length, max_offset)[source]

Align traces to the reference trace so that the maximum value within the reference trace window from reference_offset of reference_length aligns with the maximum value of the trace being aligned within max_offset of the reference window.

Parameters:
  • reference (Trace) –
  • traces (Trace) –
  • reference_offset (int) –
  • reference_length (int) –
  • max_offset (int) –
Return type:

List[Trace]

Returns:

pyecsca.sca.align.align_offset(reference, *traces, reference_offset, reference_length, max_offset, dist_func, max_dist=inf)[source]

Align traces to the reference trace so that the value of the dist_func is minimized between the reference trace window from reference_offset of reference_length and the trace being aligned within max_offset of the reference window.

Parameters:
  • reference (Trace) –
  • traces (Trace) –
  • reference_offset (int) –
  • reference_length (int) –
  • max_offset (int) –
  • dist_func (Callable[[ndarray, ndarray], float]) –
Return type:

List[Trace]

Returns:

pyecsca.sca.align.align_sad(reference, *traces, reference_offset, reference_length, max_offset)[source]

Align traces to the reference trace so that the Sum Of Absolute Differences between the reference trace window from reference_offset of reference_length and the trace being aligned within max_offset of the reference window is maximized.

Parameters:
  • reference (Trace) –
  • traces (Trace) –
  • reference_offset (int) –
  • reference_length (int) –
  • max_offset (int) –
Return type:

List[Trace]

Returns:

pyecsca.sca.align.align_dtw_scale(reference, *traces, radius=1, fast=True)[source]

Align traces to the reference trace. Using fastdtw (Dynamic Time Warping) with scaling as per:

Jasper G. J. van Woudenberg, Marc F. Witteman, Bram Bakker: Improving Differential Power Analysis by Elastic Alignment

https://pdfs.semanticscholar.org/aceb/7c307098a414d7c384d6189226e4375cf02d.pdf

Parameters:
  • reference (Trace) –
  • traces (Trace) –
  • radius (int) –
  • fast (bool) –
Return type:

List[Trace]

Returns:

pyecsca.sca.align.align_dtw(reference, *traces, radius=1, fast=True)[source]

Align traces to the reference trace. Using fastdtw (Dynamic Time Warping) as per:

Stan Salvador, Philip Chan: FastDTW: Toward Accurate Dynamic Time Warping in Linear Time and Space

https://cs.fit.edu/~pkc/papers/tdm04.pdf

Parameters:
  • reference (Trace) –
  • traces (Trace) –
  • radius (int) –
  • fast (bool) –
Return type:

List[Trace]

Returns: