aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/ec
diff options
context:
space:
mode:
Diffstat (limited to 'test/ec')
-rw-r--r--test/ec/test_configuration.py41
-rw-r--r--test/ec/utils.py3
2 files changed, 29 insertions, 15 deletions
diff --git a/test/ec/test_configuration.py b/test/ec/test_configuration.py
index 560074b..e184ca3 100644
--- a/test/ec/test_configuration.py
+++ b/test/ec/test_configuration.py
@@ -4,11 +4,20 @@ from pyecsca.ec.configuration import (all_configurations, HashType, RandomMod, M
Squaring, Reduction)
from pyecsca.ec.model import ShortWeierstrassModel
from pyecsca.ec.mult import LTRMultiplier
-from test.sca.utils import slow
+from .utils import slow
class ConfigurationTests(TestCase):
+ def base_independents(self):
+ return {
+ "hash_type": HashType.SHA1,
+ "mod_rand": RandomMod.SAMPLE,
+ "mult": Multiplication.BASE,
+ "sqr": Squaring.BASE,
+ "red": Reduction.BASE
+ }
+
@slow
def test_all(self):
j = 0
@@ -16,18 +25,18 @@ class ConfigurationTests(TestCase):
j += 1
print(j)
+ def test_weierstrass_projective(self):
+ model = ShortWeierstrassModel()
+ coords = model.coordinates["projective"]
+ configs = list(all_configurations(model=model, coords=coords, **self.base_independents()))
+ self.assertEqual(len(configs), 1344)
+
def test_mult_class(self):
model = ShortWeierstrassModel()
coords = model.coordinates["projective"]
scalarmult = LTRMultiplier
- hash_type = HashType.SHA1
- mod_rand = RandomMod.SAMPLE
- mult = Multiplication.BASE
- sqr = Squaring.BASE
- red = Reduction.BASE
configs = list(all_configurations(model=model, coords=coords, scalarmult=scalarmult,
- hash_type=hash_type, mod_rand=mod_rand, mult=mult,
- sqr=sqr, red=red))
+ **self.base_independents()))
self.assertEqual(len(configs), 384)
def test_one(self):
@@ -42,12 +51,14 @@ class ConfigurationTests(TestCase):
"complete": False,
"short_circuit": True
}
- hash_type = HashType.SHA1
- mod_rand = RandomMod.SAMPLE
- mult = Multiplication.BASE
- sqr = Squaring.BASE
- red = Reduction.BASE
configs = list(all_configurations(model=model, coords=coords, scalarmult=scalarmult,
- hash_type=hash_type, mod_rand=mod_rand, mult=mult,
- sqr=sqr, red=red))
+ **self.base_independents()))
+ self.assertEqual(len(configs), 1)
+ scalarmult = LTRMultiplier(coords.formulas["add-1998-cmo"], coords.formulas["dbl-1998-cmo"],
+ None, True, False, True)
+ configs = list(all_configurations(model=model, coords=coords, scalarmult=scalarmult,
+ **self.base_independents()))
+ self.assertEqual(len(configs), 1)
+ configs = list(all_configurations(model=model, scalarmult=scalarmult,
+ **self.base_independents()))
self.assertEqual(len(configs), 1)
diff --git a/test/ec/utils.py b/test/ec/utils.py
new file mode 100644
index 0000000..bedfed2
--- /dev/null
+++ b/test/ec/utils.py
@@ -0,0 +1,3 @@
+def slow(func):
+ func.slow = 1
+ return func