pyecsca.ec.mult.window module

Provides sliding window and fixed window scalar multipliers (including m-ary, for non power-of-2 m).

class SlidingWindowMultiplier(add, dbl, width, scl=None, recoding_direction=ProcessingDirection.LTR, accumulation_order=AccumulationOrder.PeqPR, short_circuit=True)[source]

Bases: AccumulatorMultiplier, ScalarMultiplier

Sliding window scalar multiplier.

Parameters:
  • width (int) – The width of the sliding-window recoding.

  • recoding_direction (ProcessingDirection) – The direction for the sliding-window recoding.

  • accumulation_order (AccumulationOrder) – The order of accumulation of points.

requires: ClassVar[Set[Type]] = {<class 'pyecsca.ec.formula.base.AdditionFormula'>, <class 'pyecsca.ec.formula.base.DoublingFormula'>}[source]

The set of formula types that the multiplier requires.

optionals: ClassVar[Set[Type]] = {<class 'pyecsca.ec.formula.base.ScalingFormula'>}[source]

The optional set of formula types that the multiplier can use.

width: int[source]

The width of the sliding-window recoding.

recoding_direction: ProcessingDirection[source]

The direction for the sliding-window recoding.

init(params, point)[source]

Initialize the scalar multiplier with params and a point.

Warning

The point is not verified to be on the curve represented in the domain parameters.

Parameters:
  • params (DomainParameters) – The domain parameters to initialize the multiplier with.

  • point (Point) – The point to initialize the multiplier with.

multiply(scalar)[source]

Multiply the point with the scalar.

Note

The multiplier needs to be initialized by a call to the init() method.

Parameters:

scalar (int) – The scalar to use.

Return type:

Point

Returns:

The resulting multiple.

accumulation_order: AccumulationOrder[source]

The order of accumulation of points.

short_circuit: bool[source]

Whether the formulas will short-circuit upon input of the point at infinity.

formulas: Mapping[str, Formula][source]

All formulas the multiplier was initialized with.

class FixedWindowLTRMultiplier(add, dbl, m, scl=None, accumulation_order=AccumulationOrder.PeqPR, short_circuit=True)[source]

Bases: AccumulatorMultiplier, ScalarMultiplier

Like LTRMultiplier, but m-ary, not binary.

For m a power-of-2 this is a fixed window multiplier that works on log_2(m) wide windows and uses only doublings to perform the multiplication-by-m between each window addition.

For other m values, this is the m-ary multiplier.

Parameters:
  • m (int) – The arity of the multiplier.

  • accumulation_order (AccumulationOrder) – The order of accumulation of points.

requires: ClassVar[Set[Type]] = {<class 'pyecsca.ec.formula.base.AdditionFormula'>, <class 'pyecsca.ec.formula.base.DoublingFormula'>}[source]

The set of formula types that the multiplier requires.

optionals: ClassVar[Set[Type]] = {<class 'pyecsca.ec.formula.base.ScalingFormula'>}[source]

The optional set of formula types that the multiplier can use.

accumulation_order: AccumulationOrder[source]

The order of accumulation of points.

m: int[source]

The arity of the multiplier.

init(params, point)[source]

Initialize the scalar multiplier with params and a point.

Warning

The point is not verified to be on the curve represented in the domain parameters.

Parameters:
  • params (DomainParameters) – The domain parameters to initialize the multiplier with.

  • point (Point) – The point to initialize the multiplier with.

multiply(scalar)[source]

Multiply the point with the scalar.

Note

The multiplier needs to be initialized by a call to the init() method.

Parameters:

scalar (int) – The scalar to use.

Return type:

Point

Returns:

The resulting multiple.

short_circuit: bool[source]

Whether the formulas will short-circuit upon input of the point at infinity.

formulas: Mapping[str, Formula][source]

All formulas the multiplier was initialized with.

class WindowBoothMultiplier(add, dbl, neg, width, scl=None, accumulation_order=AccumulationOrder.PeqPR, precompute_negation=False, short_circuit=True)[source]

Bases: AccumulatorMultiplier, ScalarMultiplier

Parameters:
  • short_circuit (bool) – Whether the use of formulas will be guarded by short-circuit on inputs of the point at infinity.

  • width (int) – The width of the window.

  • accumulation_order (AccumulationOrder) – The order of accumulation of points.

  • precompute_negation (bool) – Whether to precompute the negation of the precomputed points as well. It is computed on the fly otherwise.

requires: ClassVar[Set[Type]] = {<class 'pyecsca.ec.formula.base.AdditionFormula'>, <class 'pyecsca.ec.formula.base.DoublingFormula'>, <class 'pyecsca.ec.formula.base.NegationFormula'>}[source]

The set of formula types that the multiplier requires.

optionals: ClassVar[Set[Type]] = {<class 'pyecsca.ec.formula.base.ScalingFormula'>}[source]

The optional set of formula types that the multiplier can use.

accumulation_order: AccumulationOrder[source]

The order of accumulation of points.

short_circuit: bool[source]

Whether the formulas will short-circuit upon input of the point at infinity.

formulas: Mapping[str, Formula][source]

All formulas the multiplier was initialized with.

width: int[source]

The width of the window.

precompute_negation: bool = False[source]

Whether to precompute the negation of the precomputed points as well.

init(params, point)[source]

Initialize the scalar multiplier with params and a point.

Warning

The point is not verified to be on the curve represented in the domain parameters.

Parameters:
  • params (DomainParameters) – The domain parameters to initialize the multiplier with.

  • point (Point) – The point to initialize the multiplier with.

multiply(scalar)[source]

Multiply the point with the scalar.

Note

The multiplier needs to be initialized by a call to the init() method.

Parameters:

scalar (int) – The scalar to use.

Return type:

Point

Returns:

The resulting multiple.