aboutsummaryrefslogtreecommitdiff
path: root/pyecsca/ec/formula.py
diff options
context:
space:
mode:
authorJ08nY2020-02-08 23:23:02 +0100
committerJ08nY2020-02-08 23:23:02 +0100
commit2b8f3752505c3a03f617534ebfadd7fb70e09ba2 (patch)
treef1eb76b4eca348ae763e2578ef0e13d2b8a1d74b /pyecsca/ec/formula.py
parent59b09851d4452448ffd9100aca2335f2424885e0 (diff)
downloadpyecsca-2b8f3752505c3a03f617534ebfadd7fb70e09ba2.tar.gz
pyecsca-2b8f3752505c3a03f617534ebfadd7fb70e09ba2.tar.zst
pyecsca-2b8f3752505c3a03f617534ebfadd7fb70e09ba2.zip
Diffstat (limited to 'pyecsca/ec/formula.py')
-rw-r--r--pyecsca/ec/formula.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/pyecsca/ec/formula.py b/pyecsca/ec/formula.py
index 2da6ad5..aeed4a6 100644
--- a/pyecsca/ec/formula.py
+++ b/pyecsca/ec/formula.py
@@ -1,6 +1,6 @@
from ast import parse, Expression, Mult, Add, Sub, Pow, Div
-from typing import List, Set, Any, ClassVar, MutableMapping
from itertools import product
+from typing import List, Set, Any, ClassVar, MutableMapping
from pkg_resources import resource_stream
from public import public
@@ -68,6 +68,7 @@ class Formula(object):
"""Number of additions and subtractions."""
return len(list(filter(lambda op: isinstance(op.operator, (Add, Sub)), self.code)))
+
class EFDFormula(Formula):
def __init__(self, path: str, name: str, coordinate_model: Any):
@@ -116,7 +117,8 @@ class EFDFormula(Formula):
@property
def outputs(self):
return set(var + str(i) for var, i in product(self.coordinate_model.variables,
- range(self.output_index, self.output_index + self.num_outputs)))
+ range(self.output_index,
+ self.output_index + self.num_outputs)))
def __eq__(self, other):
if not isinstance(other, EFDFormula):
@@ -126,6 +128,7 @@ class EFDFormula(Formula):
def __hash__(self):
return hash(self.name) + hash(self.coordinate_model)
+
@public
class AdditionFormula(Formula):
shortname = "add"