pyecsca.sca.stacked_traces.combine module

class BaseTraceManager(traces)[source]

Bases: object

Base class for trace managers

average()[source]

Average traces, sample-wise.

Parameters:

traces

Return type:

CombinedTrace

Returns:

conditional_average(cond)[source]

Average traces for which the condition is True, sample-wise.

Parameters:
  • traces

  • condition

Return type:

CombinedTrace

Returns:

standard_deviation()[source]

Compute the sample standard-deviation of the traces, sample-wise.

Parameters:

traces

Return type:

CombinedTrace

Returns:

variance()[source]

Compute the sample variance of the traces, sample-wise.

Parameters:

traces

Return type:

CombinedTrace

Returns:

average_and_variance()[source]

Compute the sample average and variance of the traces, sample-wise.

Parameters:

traces

Return type:

List[CombinedTrace]

Returns:

add()[source]

Add traces, sample-wise.

Parameters:

traces

Return type:

CombinedTrace

Returns:

class GPUTraceManager(traces, tpb=128, chunk=False, chunk_size=None, chunk_memory_ratio=None, stream_count=None)[source]

Bases: BaseTraceManager

Manager for operations with stacked traces on GPU

Parameters:
  • traces (StackedTraces) – Stacked traces on which to operate.

  • tpb (Union[int, Tuple[int, ...]]) – Threads per block to use for GPU operations.

  • chunk (bool) – Whether to chunk the traces.

  • chunk_size (Optional[int]) – Number of samples to use for chunking. Chunks will be chunk_size x trace_count.

  • chunk_memory_ratio (Optional[float]) – Part of available memory to use for chunking.

  • stream_count (Optional[int]) – Number of streams to use for chunking.

static chunk_size_from_ratio(chunk_memory_ratio, element_size=None, item_size=None, chunk_item_count=None)[source]
Return type:

int

property traces_shape: Tuple[int, ...][source]
average()[source]

Average traces, sample-wise.

Parameters:

traces

Return type:

CombinedTrace

Returns:

conditional_average(cond)[source]

Average traces for which the condition is True, sample-wise.

Parameters:
  • traces

  • condition

Return type:

CombinedTrace

Returns:

standard_deviation()[source]

Compute the sample standard-deviation of the traces, sample-wise.

Parameters:

traces

Return type:

CombinedTrace

Returns:

variance()[source]

Compute the sample variance of the traces, sample-wise.

Parameters:

traces

Return type:

CombinedTrace

Returns:

average_and_variance()[source]

Compute the sample average and variance of the traces, sample-wise.

Parameters:

traces

Return type:

List[CombinedTrace]

Returns:

add()[source]

Add traces, sample-wise.

Parameters:

traces

Return type:

CombinedTrace

Returns:

pearson_corr(intermediate_values)[source]
Return type:

CombinedTrace

run(func, inputs=None, output_count=1)[source]
Return type:

Union[CombinedTrace, List[CombinedTrace]]

class CPUTraceManager(traces)[source]

Bases: object

Manager for operations on stacked traces on CPU.

traces: StackedTraces[source]
average()[source]

Compute the average of the traces, sample-wise.

Parameters:

traces

Return type:

CombinedTrace

Returns:

conditional_average(condition)[source]

Compute the conditional average of the traces, sample-wise.

Parameters:

traces

Return type:

CombinedTrace

Returns:

standard_deviation()[source]

Compute the sample standard-deviation of the traces, sample-wise.

Parameters:

traces

Return type:

CombinedTrace

Returns:

variance()[source]

Compute the sample variance of the traces, sample-wise.

Parameters:

traces

Return type:

CombinedTrace

Returns:

average_and_variance()[source]

Compute the average and sample variance of the traces, sample-wise.

Parameters:

traces

Return type:

List[CombinedTrace]

Returns:

add()[source]

Add traces, sample-wise.

Parameters:

traces

Return type:

CombinedTrace

Returns:

pearson_corr(intermediate_values)[source]

Calculates the Pearson correlation coefficient between the given samples and intermediate values sample-wise.

The result is equivalent to:

np.corrcoef(self.traces.samples,

intermediate_values, rowvar=False)[-1, :-1]

but a different implementation is used for better time-efficiency, which doesn’t compute the whole correlation matrix.

Parameters:

intermediate_values (npt.NDArray[np.number]) – A 1D array of shape (n,) containing the intermediate values.

Return type:

CombinedTrace