aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.pre-commit-config.yaml2
-rw-r--r--pyecsca/ec/coordinates.py3
-rw-r--r--pyecsca/ec/curve.py3
-rw-r--r--pyecsca/ec/params.py3
-rw-r--r--pyecsca/ec/point.py5
-rw-r--r--pyecsca/sca/scope/picoscope_sdk.py2
6 files changed, 15 insertions, 3 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 3804976..1969532 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -16,7 +16,7 @@ repos:
- id: mypy
additional_dependencies:
- "types-setuptools"
- args: [--ignore-missing-imports, --show-error-codes, --namespace-packages]
+ args: [--ignore-missing-imports, --show-error-codes, --namespace-packages, --explicit-package-bases, --check-untyped-defs]
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
diff --git a/pyecsca/ec/coordinates.py b/pyecsca/ec/coordinates.py
index c131aca..b258f2d 100644
--- a/pyecsca/ec/coordinates.py
+++ b/pyecsca/ec/coordinates.py
@@ -66,6 +66,9 @@ class AffineCoordinateModel(CoordinateModel):
return False
return self.curve_model == other.curve_model
+ def __hash__(self):
+ return hash(self.curve_model) + hash(self.name)
+
class EFDCoordinateModel(CoordinateModel):
def __init__(self, dir_path: str, name: str, curve_model: Any):
diff --git a/pyecsca/ec/curve.py b/pyecsca/ec/curve.py
index a032e3c..8fc2793 100644
--- a/pyecsca/ec/curve.py
+++ b/pyecsca/ec/curve.py
@@ -276,6 +276,9 @@ class EllipticCurve:
and self.parameters == other.parameters
)
+ def __hash__(self):
+ return hash((self.model, self.coordinate_model, self.prime, self.parameters))
+
def __str__(self):
return "EllipticCurve"
diff --git a/pyecsca/ec/params.py b/pyecsca/ec/params.py
index 1feb61b..8344901 100644
--- a/pyecsca/ec/params.py
+++ b/pyecsca/ec/params.py
@@ -66,6 +66,9 @@ class DomainParameters:
and self.cofactor == other.cofactor
)
+ def __hash__(self):
+ return hash((self.curve, self.generator, self.order, self.cofactor))
+
def __get_name(self):
if self.name and self.category:
return f"{self.category}/{self.name}"
diff --git a/pyecsca/ec/point.py b/pyecsca/ec/point.py
index b28e130..c7f99db 100644
--- a/pyecsca/ec/point.py
+++ b/pyecsca/ec/point.py
@@ -196,7 +196,7 @@ class Point:
return self.coords == other.coords
def __hash__(self):
- return hash((tuple(self.coords.keys()), tuple(self.coords.values()))) + 1
+ return hash((self.coordinate_model.name, tuple(self.coords.keys()), tuple(self.coords.values()))) + 13
def __str__(self):
args = ", ".join([f"{key}={val}" for key, val in self.coords.items()])
@@ -240,6 +240,9 @@ class InfinityPoint(Point):
else:
return self.coordinate_model == other.coordinate_model
+ def __hash__(self):
+ return hash(self.coordinate_model.name) + 13
+
def __str__(self):
return "Infinity"
diff --git a/pyecsca/sca/scope/picoscope_sdk.py b/pyecsca/sca/scope/picoscope_sdk.py
index 05ba34e..b673614 100644
--- a/pyecsca/sca/scope/picoscope_sdk.py
+++ b/pyecsca/sca/scope/picoscope_sdk.py
@@ -526,7 +526,7 @@ else: # pragma: no cover
if isinstance(ps6000, CannotFindPicoSDKError):
@public
- class PS6000Scope(PicoScopeSdk): # pragma: no cover
+ class PS6000Scope(PicoScopeSdk): # noqa, pragma: no cover
"""PicoScope 6000 series oscilloscope is not available (Install `libps6000`)."""
def __init__(self, variant: Optional[str] = None):