diff options
| author | J08nY | 2023-05-20 18:07:11 +0200 |
|---|---|---|
| committer | J08nY | 2023-05-20 18:07:11 +0200 |
| commit | 1b115ca3cb9ef43f163bbb4a8a27b92f87d8f520 (patch) | |
| tree | f3ce536cf16909c7b48a4c2fff4bbb489b55c2eb /pyecsca/ec | |
| parent | 936217417fdace6f714133a2024ccb6c403dd599 (diff) | |
| download | pyecsca-1b115ca3cb9ef43f163bbb4a8a27b92f87d8f520.tar.gz pyecsca-1b115ca3cb9ef43f163bbb4a8a27b92f87d8f520.tar.zst pyecsca-1b115ca3cb9ef43f163bbb4a8a27b92f87d8f520.zip | |
Allow for iter over Point.
Diffstat (limited to 'pyecsca/ec')
| -rw-r--r-- | pyecsca/ec/point.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/pyecsca/ec/point.py b/pyecsca/ec/point.py index c7f99db..c4da538 100644 --- a/pyecsca/ec/point.py +++ b/pyecsca/ec/point.py @@ -182,6 +182,13 @@ class Point: """Test whether this point is equal to `other` irrespective of the coordinate model (in the affine sense).""" return self.equals_affine(other) + def __iter__(self): + for k in sorted(self.coords.keys()): + yield self.coords[k] + + def __len__(self): + return len(self.coords) + def __bytes__(self): res = b"\x04" for k in sorted(self.coords.keys()): @@ -231,6 +238,12 @@ class InfinityPoint(Point): def equals(self, other: "Point") -> bool: return self == other + def __iter__(self): + pass + + def __len__(self): + return 0 + def __bytes__(self): return b"\x00" |
