pyecsca.ec.mult.binary module¶
Provides binary scalar multipliers (LTR and RTL), that process the scalar as-is, bit-by-bit.
- class DoubleAndAddMultiplier(add, dbl, scl=None, always=False, direction=ProcessingDirection.LTR, accumulation_order=AccumulationOrder.PeqPR, complete=True, short_circuit=True)[source]¶
Bases:
AccumulatorMultiplier
,ScalarMultiplier
,ABC
Classic double and add scalar multiplication algorithm.
Note
This is an ABC, you should use the LTRMultiplier and RTLMultiplier classes.
- Parameters:
short_circuit¶ (
bool
) – Whether the use of formulas will be guarded by short-circuit on inputs of the point at infinity.always¶ (
bool
) – Whether the double and add always method is used.direction¶ (
ProcessingDirection
) – Whether it is LTR or RTL.accumulation_order¶ (
AccumulationOrder
) – The order of accumulation of points.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.
-
direction:
ProcessingDirection
[source]¶ Whether it is LTR or RTL.
- multiply(scalar)[source]¶
Multiply the point with the scalar.
Note
The multiplier needs to be initialized by a call to the
init()
method.
- 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 LTRMultiplier(add, dbl, scl=None, always=False, accumulation_order=AccumulationOrder.PeqPR, complete=True, short_circuit=True)[source]¶
Bases:
DoubleAndAddMultiplier
Classic double and add scalar multiplication algorithm, that scans the scalar left-to-right (msb to lsb).
- Parameters:
short_circuit¶ (
bool
) – Whether the use of formulas will be guarded by short-circuit on inputs of the point at infinity.always¶ (
bool
) – Whether the double and add always method is used.accumulation_order¶ (
AccumulationOrder
) – The order of accumulation of points.complete¶ (
bool
) – Whether it starts processing at full order-bit-length.
- 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.
- multiply(scalar)[source]¶
Multiply the point with the scalar.
Note
The multiplier needs to be initialized by a call to the
init()
method.
- optionals: ClassVar[Set[Type]] = {<class 'pyecsca.ec.formula.base.ScalingFormula'>}[source]¶
The optional set of formula types that the multiplier can use.
- 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.
- class RTLMultiplier(add, dbl, scl=None, always=False, accumulation_order=AccumulationOrder.PeqPR, complete=True, short_circuit=True)[source]¶
Bases:
DoubleAndAddMultiplier
Classic double and add scalar multiplication algorithm, that scans the scalar right-to-left (lsb to msb).
- Parameters:
short_circuit¶ (
bool
) – Whether the use of formulas will be guarded by short-circuit on inputs of the point at infinity.always¶ (
bool
) – Whether the double and add always method is used.accumulation_order¶ (
AccumulationOrder
) – The order of accumulation of points.complete¶ (
bool
) – Whether it starts processing at full order-bit-length.
- 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.
- multiply(scalar)[source]¶
Multiply the point with the scalar.
Note
The multiplier needs to be initialized by a call to the
init()
method.
- optionals: ClassVar[Set[Type]] = {<class 'pyecsca.ec.formula.base.ScalingFormula'>}[source]¶
The optional set of formula types that the multiplier can use.
- 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.
- class CoronMultiplier(add, dbl, scl=None, short_circuit=True)[source]¶
Bases:
ScalarMultiplier
Coron’s double and add resistant against SPA.
From [CO2002].
- Parameters:
short_circuit¶ (
bool
) – Whether the use of formulas will be guarded by short-circuit on inputs 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.
- 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.
- short_circuit: bool[source]¶
Whether the formulas will short-circuit upon input of the point at infinity.