pyecsca.ec.mult.base module¶
Provides (mostly abstract) base classes for scalar multipliers, enums used to specify their parameters and actions used in them.
- class ProcessingDirection(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum
Scalar processing direction.
- LTR = 'Left-to-right'¶
- RTL = 'Right-to-left'¶
- class AccumulationOrder(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum
Accumulation order (makes a difference for the projective result).
- PeqPR = 'P = P + R'¶
- PeqRP = 'P = R + P'¶
- class ScalarMultiplicationAction(point, scalar)[source]¶
Bases:
ResultAction
A scalar multiplication of a point on a curve by a scalar.
-
scalar:
int
¶
- exit(result)¶
- property result: Any¶
- inside: bool¶
-
scalar:
- class PrecomputationAction(params, point)[source]¶
Bases:
Action
A precomputation of a point in scalar multiplication.
-
params:
DomainParameters
¶
-
inside:
bool
¶
-
params:
- class ScalarMultiplier(short_circuit=True, **formulas)[source]¶
Bases:
ABC
A scalar multiplication algorithm.
Note
The __init__ method of all concrete subclasses needs to have type annotations so that configuration enumeration works.
- Parameters:
-
requires:
ClassVar
[Set
[Type
]]¶ The set of formula types that the multiplier requires.
-
optionals:
ClassVar
[Set
[Type
]]¶ The optional set of formula types that the multiplier can use.
-
short_circuit:
bool
¶ Whether the formulas will short-circuit upon input of the point at infinity.
- init(params, point)[source]¶
Initialize the scalar multiplier with
params
and apoint
.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.
- class AccumulatorMultiplier(*args, accumulation_order=AccumulationOrder.PeqPR, **kwargs)[source]¶
Bases:
ScalarMultiplier
,ABC
A scalar multiplication algorithm mix-in class for a multiplier that accumulates.
- Parameters:
accumulation_order¶ (
AccumulationOrder
) – The order of accumulation of points.
- init(params, point)¶
Initialize the scalar multiplier with
params
and apoint
.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.
- abstract multiply(scalar)¶
Multiply the point with the scalar.
Note
The multiplier needs to be initialized by a call to the
init()
method.
-
requires:
ClassVar
[Set
[Type
]]¶ The set of formula types that the multiplier requires.
-
optionals:
ClassVar
[Set
[Type
]]¶ The optional set of formula types that the multiplier can use.
-
short_circuit:
bool
¶ Whether the formulas will short-circuit upon input of the point at infinity.
-
accumulation_order:
AccumulationOrder
¶ The order of accumulation of points.