diff options
| author | J08nY | 2018-12-18 20:42:57 +0100 |
|---|---|---|
| committer | J08nY | 2019-03-21 11:00:14 +0100 |
| commit | fe1d8873331109342348d7ab58c3415c65aec57c (patch) | |
| tree | a433f020bc3611ccb523e354cbd05cc9d6be5571 /test/ec | |
| parent | f4c73c9cc111d8975a7bac6a8ca3cd5d1c49804b (diff) | |
| download | pyecsca-fe1d8873331109342348d7ab58c3415c65aec57c.tar.gz pyecsca-fe1d8873331109342348d7ab58c3415c65aec57c.tar.zst pyecsca-fe1d8873331109342348d7ab58c3415c65aec57c.zip | |
Fix ladder multipliers.
Diffstat (limited to 'test/ec')
| -rw-r--r-- | test/ec/test_mult.py | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/test/ec/test_mult.py b/test/ec/test_mult.py index 258a525..cda9f76 100644 --- a/test/ec/test_mult.py +++ b/test/ec/test_mult.py @@ -3,7 +3,7 @@ from unittest import TestCase from pyecsca.ec.curve import EllipticCurve from pyecsca.ec.mod import Mod from pyecsca.ec.model import ShortWeierstrassModel, MontgomeryModel -from pyecsca.ec.mult import LTRMultiplier, RTLMultiplier, LadderMultiplier, BinaryNAFMultiplier, WindowNAFMultiplier +from pyecsca.ec.mult import LTRMultiplier, RTLMultiplier, LadderMultiplier, BinaryNAFMultiplier, WindowNAFMultiplier, SimpleLadderMultiplier from pyecsca.ec.point import Point @@ -30,7 +30,7 @@ class ScalarMultiplierTests(TestCase): Point(self.coords25519, X=Mod(0, self.p25519), Z=Mod(1, self.p25519))) - def test_rtl_simple(self): + def test_rtl(self): mult = RTLMultiplier(self.secp128r1, self.coords.formulas["add-1998-cmo"], self.coords.formulas["dbl-1998-cmo"], self.coords.formulas["z"]) res = mult.multiply(10, self.base) @@ -38,7 +38,7 @@ class ScalarMultiplierTests(TestCase): other = mult.multiply(2, other) self.assertEqual(res, other) - def test_ltr_simple(self): + def test_ltr(self): mult = LTRMultiplier(self.secp128r1, self.coords.formulas["add-1998-cmo"], self.coords.formulas["dbl-1998-cmo"], self.coords.formulas["z"]) res = mult.multiply(10, self.base) @@ -46,7 +46,7 @@ class ScalarMultiplierTests(TestCase): other = mult.multiply(2, other) self.assertEqual(res, other) - def test_ladder_simple(self): + def test_ladder(self): mult = LadderMultiplier(self.curve25519, self.coords25519.formulas["ladd-1987-m"], self.coords25519.formulas["scale"]) res = mult.multiply(15, self.base25519) @@ -54,7 +54,15 @@ class ScalarMultiplierTests(TestCase): other = mult.multiply(5, other) self.assertEqual(res, other) - def test_binary_naf_simple(self): + def test_simple_ladder(self): + mult = SimpleLadderMultiplier(self.secp128r1, self.coords.formulas["add-1998-cmo"], + self.coords.formulas["dbl-1998-cmo"], self.coords.formulas["z"]) + res = mult.multiply(10, self.base) + other = mult.multiply(5, self.base) + other = mult.multiply(2, other) + self.assertEqual(res, other) + + def test_binary_naf(self): mult = BinaryNAFMultiplier(self.secp128r1, self.coords.formulas["add-1998-cmo"], self.coords.formulas["dbl-1998-cmo"], self.coords.formulas["neg"], self.coords.formulas["z"]) @@ -63,7 +71,7 @@ class ScalarMultiplierTests(TestCase): other = mult.multiply(2, other) self.assertEqual(res, other) - def test_window_naf_simple(self): + def test_window_naf(self): mult = WindowNAFMultiplier(self.secp128r1, self.coords.formulas["add-1998-cmo"], self.coords.formulas["dbl-1998-cmo"], self.coords.formulas["neg"], 3, self.coords.formulas["z"]) @@ -103,3 +111,8 @@ class ScalarMultiplierTests(TestCase): self.coords.formulas["neg"], 3, self.coords.formulas["z"]) res_wnaf = wnaf.multiply(10, self.base) self.assertEqual(res_wnaf, res_ltr) + + ladder = SimpleLadderMultiplier(self.secp128r1, self.coords.formulas["add-1998-cmo"], + self.coords.formulas["dbl-1998-cmo"], self.coords.formulas["z"]) + res_ladder = ladder.multiply(10, self.base) + self.assertEqual(res_ladder, res_ltr)
\ No newline at end of file |
