Analysis base classes

Base analysis classes provides elements to build attack or reverse analysis process.

class scared.analysis.base.BaseAttack(selection_function, model, discriminant, precision='float32', convergence_step=None)[source]

Base class for all attack analysis processing objects.

This class must be subclassed and combined with a mixin inheriting from DistinguisherMixin. It provides the common processing method for a side-channel statistical analysis.

The base class:
  • initialize the state before processing any traces

  • provides method, either to process traces and compute results manually, either to run a complete processing of a Container instance

  • manage results attributes: distinguisher method output (results), scores and convergence_traces

results

array containing the latest results obtained from the distinguisher computing.

Type:

numpy.ndarray

scores

array containing the latest scores obtained by processing results with discriminant.

Type:

numpy.ndarray

convergence_step

number of traces to process before each computation of results. If convergence_step is provided, all intermediate scores computed are kept in convergence_traces

Type:

int, default=None

convergences_traces

array containing the scores values at each convergence step defined by convergence_step.

Type:

numpy.ndarray

Examples

First, you have to use either one the distinguisher mixin available, all create one which inherit from DistinguisherMixin:

class MyDistinguisherMixin(DistinguisherMixin): # implements the needed method.

Create a new class by inheriting from :class:BaseAttack class and the distinguisher mixin:

class MyAttack(BaseAttack, MyDistinguisherMixin):

pass

Create your analysis object and run it on a container:

analysis = MyAttack(…) analysis.run(container)

__init__(selection_function, model, discriminant, precision='float32', convergence_step=None)[source]

Initialize attack.

Parameters:
  • selection_function (SelectionFunction) – selection function to compute intermediate values. Must inherit from SelectionFunction.

  • model (Model) – model instance to compute leakage intermediate values. Must inherit from Model.

  • discriminant (function) – a function to compute scores from a distinguisher results array. Must be decorated with scared.discriminants.discriminant().

  • precision (numpy.dtype, default=`float32`) – precision which will be used for computations.

  • convergence_step (int, default=None) – if provided, run method will compute and stores scores each time convergence_step traces are processed.

compute_results()[source]

Compute results for the current state.

This method is used internally by run, but can also be used to have a finer control on the process.

class scared.analysis.base.BaseReverse(selection_function, model, precision='float32')[source]

Base class for all reverse analysis processing objects.

This class must be subclassed and combined with a mixin inheriting from DistinguisherMixin. It provides the common processing method for a side-channel statistical analysis.

The base class:
  • initialize the state before processing any traces

  • provides method, either to process traces and compute results manually, either to run a complete processing of a Container instance

  • manage results attributes: distinguisher method output (results)

results

array containing the latest results obtained from the distinguisher computing.

Type:

numpy.ndarray

class scared.analysis.base.BasePartitionedReverse(partitions=None, *args, **kwargs)[source]
__init__(partitions=None, *args, **kwargs)[source]

Initialize analysis.

Parameters:
  • selection_function (SelectionFunction) – selection function to compute intermediate values. Must inherit from SelectionFunction.

  • model (Model) – model instance to compute leakage intermediate values. Must inherit from Model.

  • precision (numpy.dtype, default=`float32`) – precision which will be used for computations.

class scared.analysis.base.BasePartitionedAttack(partitions=None, *args, **kwargs)[source]
__init__(partitions=None, *args, **kwargs)[source]

Initialize attack.

Parameters:
  • selection_function (SelectionFunction) – selection function to compute intermediate values. Must inherit from SelectionFunction.

  • model (Model) – model instance to compute leakage intermediate values. Must inherit from Model.

  • discriminant (function) – a function to compute scores from a distinguisher results array. Must be decorated with scared.discriminants.discriminant().

  • precision (numpy.dtype, default=`float32`) – precision which will be used for computations.

  • convergence_step (int, default=None) – if provided, run method will compute and stores scores each time convergence_step traces are processed.