From 817171e51bfc0faee0ea53ce28342a89a1307d16 Mon Sep 17 00:00:00 2001 From: J08nY Date: Wed, 13 Mar 2019 23:34:48 +0100 Subject: Fix ladder scalar multiplier. --- pyecsca/ec/mult.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'pyecsca') 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: -- cgit v1.2.3-70-g09d2