pyecsca.ec.mult.naf module

Provides scalar multipliers based on the Non Adjacent Form (NAF) recoding.

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

Bases: AccumulatorMultiplier, ScalarMultiplier

Binary NAF (Non Adjacent Form) multiplier.

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

  • direction (ProcessingDirection) – Whether it is LTR or RTL.

  • 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'>, <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.

direction: ProcessingDirection[source]
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 WindowNAFMultiplier(add, dbl, neg, width, scl=None, accumulation_order=AccumulationOrder.PeqPR, precompute_negation=False, short_circuit=True)[source]

Bases: AccumulatorMultiplier, ScalarMultiplier

Window NAF (Non Adjacent Form) multiplier, left-to-right.

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.

width: int[source]

The width of the window.

precompute_negation: bool = False[source]

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

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.

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.