pyecsca.sca.stacked_traces.combine module¶
- class BaseTraceManager(traces)[source]¶
Bases:
object
Base class for trace managers
- conditional_average(cond)[source]¶
Average
traces
for which thecondition
isTrue
, sample-wise.- Parameters:
- Return type:
- Returns:
- standard_deviation()[source]¶
Compute the sample standard-deviation of the
traces
, sample-wise.- Parameters:
traces¶ –
- Return type:
- Returns:
- variance()[source]¶
Compute the sample variance of the
traces
, sample-wise.- Parameters:
traces¶ –
- Return type:
- Returns:
- average_and_variance()[source]¶
Compute the sample average and variance of the
traces
, sample-wise.- Parameters:
traces¶ –
- Return type:
List
[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, ...]¶
- conditional_average(cond)[source]¶
Average
traces
for which thecondition
isTrue
, sample-wise.- Parameters:
- Return type:
- Returns:
- standard_deviation()[source]¶
Compute the sample standard-deviation of the
traces
, sample-wise.- Parameters:
traces¶ –
- Return type:
- Returns:
- variance()[source]¶
Compute the sample variance of the
traces
, sample-wise.- Parameters:
traces¶ –
- Return type:
- Returns:
- average_and_variance()[source]¶
Compute the sample average and variance of the
traces
, sample-wise.- Parameters:
traces¶ –
- Return type:
List
[CombinedTrace
]- Returns:
- 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
¶
- average()[source]¶
Compute the average of the
traces
, sample-wise.- Parameters:
traces¶ –
- Return type:
- Returns:
- conditional_average(condition)[source]¶
Compute the conditional average of the
traces
, sample-wise.- Parameters:
traces¶ –
- Return type:
- Returns:
- standard_deviation()[source]¶
Compute the sample standard-deviation of the
traces
, sample-wise.- Parameters:
traces¶ –
- Return type:
- Returns:
- variance()[source]¶
Compute the sample variance of the
traces
, sample-wise.- Parameters:
traces¶ –
- Return type:
- Returns:
- average_and_variance()[source]¶
Compute the average and sample variance of the
traces
, sample-wise.- Parameters:
traces¶ –
- Return type:
List
[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:
-
traces: