1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
from unittest import TestCase
from pyecsca.ec.configuration import (all_configurations, HashType, RandomMod, Multiplication,
Squaring, Reduction)
from pyecsca.ec.model import ShortWeierstrassModel
from pyecsca.ec.mult import LTRMultiplier
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
for _ in all_configurations(model=ShortWeierstrassModel()):
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
configs = list(all_configurations(model=model, coords=coords, scalarmult=scalarmult,
**self.base_independents()))
self.assertEqual(len(configs), 384)
def test_one(self):
model = ShortWeierstrassModel()
coords = model.coordinates["projective"]
scalarmult = {
"cls": LTRMultiplier,
"add": coords.formulas["add-1998-cmo"],
"dbl": coords.formulas["dbl-1998-cmo"],
"scl": None,
"always": True,
"complete": False,
"short_circuit": True
}
configs = list(all_configurations(model=model, coords=coords, scalarmult=scalarmult,
**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)
|