aboutsummaryrefslogtreecommitdiff
path: root/pyecsca/ec
diff options
context:
space:
mode:
authorJ08nY2025-03-31 10:56:03 +0200
committerJ08nY2025-03-31 10:56:03 +0200
commit6a1b165c7ec1d27633c0d4ed1a840357b834e127 (patch)
treef092a41170e0e40b4b8d4882f796205ff4f33e12 /pyecsca/ec
parentebddd1ad1f031f653dff49e38b4d298f8b52bebd (diff)
downloadpyecsca-6a1b165c7ec1d27633c0d4ed1a840357b834e127.tar.gz
pyecsca-6a1b165c7ec1d27633c0d4ed1a840357b834e127.tar.zst
pyecsca-6a1b165c7ec1d27633c0d4ed1a840357b834e127.zip
Diffstat (limited to 'pyecsca/ec')
-rw-r--r--pyecsca/ec/curve.py6
-rw-r--r--pyecsca/ec/point.py8
2 files changed, 11 insertions, 3 deletions
diff --git a/pyecsca/ec/curve.py b/pyecsca/ec/curve.py
index 2e08abb..18d7e65 100644
--- a/pyecsca/ec/curve.py
+++ b/pyecsca/ec/curve.py
@@ -257,7 +257,11 @@ class EllipticCurve:
:param point: The point to test.
:return: Whether it is the neutral point.
"""
- return self.neutral == point
+ # Neutral is either InfinityPoint or Point in either affine or some other coord system.
+ if isinstance(point.coordinate_model, AffineCoordinateModel):
+ return self.neutral_is_affine and self.affine_neutral == point
+ else:
+ return self.neutral.equals_homog(point)
def is_on_curve(self, point: Point) -> bool:
"""
diff --git a/pyecsca/ec/point.py b/pyecsca/ec/point.py
index 1833f46..5a486bc 100644
--- a/pyecsca/ec/point.py
+++ b/pyecsca/ec/point.py
@@ -169,7 +169,9 @@ class Point:
if not isinstance(other, Point) or isinstance(other, InfinityPoint):
return False
if self.coordinate_model.curve_model != other.coordinate_model.curve_model:
- return False
+ raise ValueError("Can only compare points with the same curve model.")
+ if self.coordinate_model != other.coordinate_model:
+ raise ValueError("Can only compare points with the same coordinate model.")
if "z" in self.coordinate_model.formulas:
formula = self.coordinate_model.formulas["z"]
self_mapped = formula(self.field, self)
@@ -188,7 +190,9 @@ class Point:
if not isinstance(other, Point) or isinstance(other, InfinityPoint):
return False
if self.coordinate_model.curve_model != other.coordinate_model.curve_model:
- return False
+ raise ValueError("Can only compare points with the same curve model.")
+ if self.coordinate_model != other.coordinate_model:
+ raise ValueError("Can only compare points with the same coordinate model.")
weights = sorted(self.coordinate_model.homogweights.items(), key=itemgetter(1))
lambdas: Set[Mod] = set()
for var, weight in weights: