pyecsca.ec.mult.msm.base module

Provides (mostly abstract) base classes for multi-scalar multipliers and the actions used in them.

class MultiScalarMultiplierAction(points, params, scalars)[source]

Bases: ResultAction

A multi-scalar multiplication of points on a curve by scalars.

points: List[Point][source]
params: DomainParameters[source]
scalars: List[int][source]
exit(result)[source]
property result: Any[source]

The result of the action.

inside: bool[source]
class MultiScalarMultiplier(short_circuit=True, **formulas)[source]

Bases: MultiplierBase, ABC

A multi-scalar multiplication algorithm.

A multi-scalar multiplier computes the linear combination of a fixed set of points with a set of scalars, i.e. the sum of the products of each point with its scalar.

Note

The __init__ method of all concrete subclasses needs to have type annotations so that configuration enumeration works.

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

  • formulas (Optional[Formula]) – Formulas this instance will use.

requires: ClassVar[Set[Type]][source]

The set of formula types that the multiplier requires.

optionals: ClassVar[Set[Type]][source]

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

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, points, bits=None)[source]

Initialize the multi-scalar multiplier with params and a list of points.

Warning

The points are not verified to be on the curve represented in the domain parameters.

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

  • points (List[Point]) – The points to initialize the multiplier with.

  • bits (Optional[int]) – The number of bits to use in the multi-scalar multiplication (i.e. no scalar will be larger than 2^bits). The default is the bit length of the full order of the curve (including cofactor).

abstractmethod multiply(scalars)[source]

Compute the multi-scalar product of the points the multiplier was initialized with.

Note

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

Parameters:

scalars (List[int]) – The scalars to use, one per point the multiplier was initialized with.

Return type:

Point

Returns:

The resulting linear combination.