diff options
| author | J08nY | 2021-01-16 03:20:52 +0100 |
|---|---|---|
| committer | J08nY | 2021-01-16 03:20:52 +0100 |
| commit | cb397341f7e7b0647157ca8225d9dbeda14c7d2b (patch) | |
| tree | baba28dbdf860aa6a43ca9ccc91823cb7662a889 /pyecsca/ec | |
| parent | b453b249dc25c008db5c069c55e0a51a91e68229 (diff) | |
| download | pyecsca-cb397341f7e7b0647157ca8225d9dbeda14c7d2b.tar.gz pyecsca-cb397341f7e7b0647157ca8225d9dbeda14c7d2b.tar.zst pyecsca-cb397341f7e7b0647157ca8225d9dbeda14c7d2b.zip | |
Add Context for tracing multiples, usable for RPA.
Diffstat (limited to 'pyecsca/ec')
| -rw-r--r-- | pyecsca/ec/mod.py | 9 | ||||
| -rw-r--r-- | pyecsca/ec/point.py | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/pyecsca/ec/mod.py b/pyecsca/ec/mod.py index 8a4b66a..1ada79b 100644 --- a/pyecsca/ec/mod.py +++ b/pyecsca/ec/mod.py @@ -316,6 +316,9 @@ class RawMod(Mod): def __repr__(self): return str(self.x) + def __hash__(self): + return hash(("RawMod", self.x, self.n)) + def __pow__(self, n): if type(n) is not int: raise TypeError @@ -409,6 +412,9 @@ class Undefined(Mod): def __repr__(self): return "Undefined" + def __hash__(self): + return hash("Undefined") + 1 + def __pow__(self, n): raise NotImplementedError @@ -515,6 +521,9 @@ if has_gmp: def __repr__(self): return str(int(self.x)) + def __hash__(self): + return hash(("GMPMod", self.x, self.n)) + def __pow__(self, n): if type(n) not in (int, gmpy2.mpz): raise TypeError diff --git a/pyecsca/ec/point.py b/pyecsca/ec/point.py index 88c925b..df9e054 100644 --- a/pyecsca/ec/point.py +++ b/pyecsca/ec/point.py @@ -165,7 +165,7 @@ class Point(object): return self.coords == other.coords def __hash__(self): - return hash(self.coords) + 1 + return hash((tuple(self.coords.keys()), tuple(self.coords.values()))) + 1 def __str__(self): args = ", ".join([f"{key}={val}" for key, val in self.coords.items()]) |
