pyecsca.ec.mult.ladder module

Provides ladder-based scalar multipliers, either using the ladder formula, or (diffadd, dbl) or (add, dbl).

class LadderMultiplier(ladd, dbl=None, scl=None, complete=True, short_circuit=True, full=False)[source]

Bases: ScalarMultiplier

Montgomery ladder multiplier, using a three input, two output ladder formula.

Optionally takes a doubling formula, and if both complete and full is false, it requires one.

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

  • complete (bool) – Whether it starts processing at full order-bit-length.

  • full (bool) – Whether it start processing at top bit of the scalar.

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

The set of formula types that the multiplier requires.

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

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

complete: bool[source]

Whether it starts processing at full order-bit-length.

full: bool[source]

Whether it start processing at top bit of the scalar.

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.

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.

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 SimpleLadderMultiplier(add, dbl, scl=None, complete=True, short_circuit=True)[source]

Bases: ScalarMultiplier

Montgomery ladder multiplier, using addition and doubling formulas.

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

  • complete (bool) – Whether it starts processing at full order-bit-length.

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.

complete: bool[source]

Whether it starts processing at full order-bit-length.

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.

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.

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 DifferentialLadderMultiplier(dadd, dbl, scl=None, complete=True, short_circuit=True, full=False)[source]

Bases: ScalarMultiplier

Montgomery ladder multiplier, using differential addition and doubling formulas.

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

  • complete (bool) – Whether it starts processing at full order-bit-length.

requires: ClassVar[Set[Type]] = {<class 'pyecsca.ec.formula.base.DifferentialAdditionFormula'>, <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.

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.

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.

complete: bool[source]

Whether it starts processing at full order-bit-length.

full: bool[source]

Whether it start processing at top bit of the scalar.

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.