pyecsca.ec.mult.comb module

Provides Comb-like scalar multipliers, such as BGMW or Lim-Lee.

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

Bases: AccumulatorMultiplier, ScalarMultiplier

Brickell, Gordon, McCurley and Wilson (BGMW) scalar multiplier, or rather, its one parametrization.

Algorithm 3.41 from [GECC]

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

The set of formula types that the multiplier requires.

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

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

direction: ProcessingDirection

Whether it is LTR or RTL.

width: int

Window width.

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

The order of accumulation of points.

short_circuit: bool

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

formulas: Mapping[str, Formula]

All formulas the multiplier was initialized with.

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

Bases: AccumulatorMultiplier, ScalarMultiplier

Comb multiplier.

Algorithm 3.44 from [GECC]

Parameters:
  • width (int) – Window width (number of comb teeth).

  • 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'>}

The set of formula types that the multiplier requires.

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

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

width: int

Window width.

accumulation_order: AccumulationOrder

The order of accumulation of points.

short_circuit: bool

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

formulas: Mapping[str, Formula]

All formulas the multiplier was initialized with.

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.