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 | |
| parent | a9b7c026b0714bfa0aacf504e6b9dde65fccc2aa (diff) | |
| download | pyecsca-817171e51bfc0faee0ea53ce28342a89a1307d16.tar.gz pyecsca-817171e51bfc0faee0ea53ce28342a89a1307d16.tar.zst pyecsca-817171e51bfc0faee0ea53ce28342a89a1307d16.zip | |
| -rw-r--r-- | docs/index.rst | 2 | ||||
| -rw-r--r-- | pyecsca/ec/mult.py | 10 | ||||
| -rw-r--r-- | test/ec/test_mult.py | 2 |
3 files changed, 8 insertions, 6 deletions
diff --git a/docs/index.rst b/docs/index.rst index a1a7e33..405c2e2 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -48,7 +48,7 @@ License MIT License - Copyright (c) 2018 + Copyright (c) 2018-2019 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal 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: diff --git a/test/ec/test_mult.py b/test/ec/test_mult.py index 2914916..82ed9eb 100644 --- a/test/ec/test_mult.py +++ b/test/ec/test_mult.py @@ -57,6 +57,7 @@ class ScalarMultiplierTests(TestCase): def test_ladder(self): mult = LadderMultiplier(self.curve25519, self.coords25519.formulas["ladd-1987-m"], + self.coords25519.formulas["dbl-1987-m"], self.coords25519.formulas["scale"]) res = mult.multiply(15, self.base25519) other = mult.multiply(5, self.base25519) @@ -74,6 +75,7 @@ class ScalarMultiplierTests(TestCase): def test_ladder_differential(self): ladder = LadderMultiplier(self.curve25519, self.coords25519.formulas["ladd-1987-m"], + self.coords25519.formulas["dbl-1987-m"], self.coords25519.formulas["scale"]) # TODO: fix this differential = SimpleLadderMultiplier(self.curve25519, |
