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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
from unittest import TestCase
from pyecsca.ec.configuration import (
all_configurations,
HashType,
RandomMod,
Multiplication,
Squaring,
Reduction,
Inversion,
)
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,
"inv": Inversion.GCD,
}
@slow
def test_all(self):
j = 0
for _ in all_configurations(model=ShortWeierstrassModel()):
j += 1
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), 1960)
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), 560)
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)
|