aboutsummaryrefslogtreecommitdiffhomepage
path: root/pyecsca
diff options
context:
space:
mode:
authorJ08nY2024-01-31 16:40:28 +0100
committerJ08nY2024-01-31 16:41:58 +0100
commit2c9550e595dd410b69bab9fa686f669d6b52e9cb (patch)
tree90f74e5733045fa179325f1b0674f82e54bce8c8 /pyecsca
parent558ad61a9aba765b2065fbec12e44313c6df206a (diff)
downloadpyecsca-2c9550e595dd410b69bab9fa686f669d6b52e9cb.tar.gz
pyecsca-2c9550e595dd410b69bab9fa686f669d6b52e9cb.tar.zst
pyecsca-2c9550e595dd410b69bab9fa686f669d6b52e9cb.zip
Add comparison for formulas.
Diffstat (limited to 'pyecsca')
-rw-r--r--pyecsca/ec/formula/base.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/pyecsca/ec/formula/base.py b/pyecsca/ec/formula/base.py
index 5cfb425..4b8d27d 100644
--- a/pyecsca/ec/formula/base.py
+++ b/pyecsca/ec/formula/base.py
@@ -276,6 +276,15 @@ class Formula(ABC):
result.append(point)
return action.exit(tuple(result))
+ def __lt__(self, other):
+ if not isinstance(other, Formula):
+ raise TypeError("Cannot compare.")
+ if self.name is None:
+ return True
+ if other.name is None:
+ return False
+ return self.name < other.name
+
def __str__(self):
return f"{self.shortname}[{self.name}]"