diff options
| author | J08nY | 2019-03-13 23:34:48 +0100 |
|---|---|---|
| committer | J08nY | 2019-03-21 11:00:14 +0100 |
| commit | 817171e51bfc0faee0ea53ce28342a89a1307d16 (patch) | |
| tree | a877a091a53a1014ada49346e7545417b43063f4 /pyecsca | |
| parent | a9b7c026b0714bfa0aacf504e6b9dde65fccc2aa (diff) | |
| download | pyecsca-817171e51bfc0faee0ea53ce28342a89a1307d16.tar.gz pyecsca-817171e51bfc0faee0ea53ce28342a89a1307d16.tar.zst pyecsca-817171e51bfc0faee0ea53ce28342a89a1307d16.zip | |
Fix ladder scalar multiplier.
Diffstat (limited to 'pyecsca')
| -rw-r--r-- | pyecsca/ec/mult.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/pyecsca/ec/mult.py b/pyecsca/ec/mult.py index 4ccbabf..36d3896 100644 --- a/pyecsca/ec/mult.py +++ b/pyecsca/ec/mult.py @@ -180,17 +180,17 @@ class LadderMultiplier(ScalarMultiplier): Montgomery ladder multiplier, using a three input, two output ladder formula. """ - def __init__(self, curve: EllipticCurve, ladd: LadderFormula, scl: ScalingFormula = None, + def __init__(self, curve: EllipticCurve, ladd: LadderFormula, dbl: DoublingFormula, scl: ScalingFormula = None, ctx: Context = None): - super().__init__(curve, ctx, ladd=ladd, scl=scl) + super().__init__(curve, ctx, ladd=ladd, dbl=dbl, scl=scl) def multiply(self, scalar: int, point: Optional[Point] = None) -> Point: if scalar == 0: return copy(self.curve.neutral) q = self._init_multiply(point) - p0 = copy(self.curve.neutral) - p1 = copy(q) - for i in range(scalar.bit_length() - 1, -1, -1): + p0 = copy(q) + p1 = self._dbl(q) + for i in range(scalar.bit_length() - 2, -1, -1): if scalar & (1 << i) == 0: p0, p1 = self._ladd(q, p0, p1) else: |
