aboutsummaryrefslogtreecommitdiff
path: root/test/ec
diff options
context:
space:
mode:
Diffstat (limited to 'test/ec')
-rw-r--r--test/ec/test_mult.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/test/ec/test_mult.py b/test/ec/test_mult.py
index cda9f76..100e53d 100644
--- a/test/ec/test_mult.py
+++ b/test/ec/test_mult.py
@@ -3,7 +3,8 @@ 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, SimpleLadderMultiplier
+from pyecsca.ec.mult import (LTRMultiplier, RTLMultiplier, LadderMultiplier, BinaryNAFMultiplier,
+ WindowNAFMultiplier, SimpleLadderMultiplier, CoronMultiplier)
from pyecsca.ec.point import Point
@@ -46,6 +47,14 @@ class ScalarMultiplierTests(TestCase):
other = mult.multiply(2, other)
self.assertEqual(res, other)
+ def test_coron(self):
+ mult = CoronMultiplier(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_ladder(self):
mult = LadderMultiplier(self.curve25519, self.coords25519.formulas["ladd-1987-m"],
self.coords25519.formulas["scale"])
@@ -56,7 +65,8 @@ class ScalarMultiplierTests(TestCase):
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"])
+ 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)
@@ -113,6 +123,13 @@ class ScalarMultiplierTests(TestCase):
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"])
+ 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
+ self.assertEqual(res_ladder, res_ltr)
+
+ coron = CoronMultiplier(self.secp128r1, self.coords.formulas["add-1998-cmo"],
+ self.coords.formulas["dbl-1998-cmo"],
+ self.coords.formulas["z"])
+ res_coron = coron.multiply(10, self.base)
+ self.assertEqual(res_coron, res_ltr)