diff options
| author | J08nY | 2024-01-19 19:49:36 +0100 |
|---|---|---|
| committer | J08nY | 2024-01-19 19:49:36 +0100 |
| commit | f26ec844f8582c8e4861c0bc8005d22fdae934f2 (patch) | |
| tree | cd4f86208171c54d8676cc4022d9087d3b367eb9 /pyecsca/ec/mult | |
| parent | e586e5604a953ab53fefc7efea804e9fb43b28b3 (diff) | |
| download | pyecsca-f26ec844f8582c8e4861c0bc8005d22fdae934f2.tar.gz pyecsca-f26ec844f8582c8e4861c0bc8005d22fdae934f2.tar.zst pyecsca-f26ec844f8582c8e4861c0bc8005d22fdae934f2.zip | |
Add more utilities for working with maps and trees.
Diffstat (limited to 'pyecsca/ec/mult')
| -rw-r--r-- | pyecsca/ec/mult/comb.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/pyecsca/ec/mult/comb.py b/pyecsca/ec/mult/comb.py index 252abd7..860dab7 100644 --- a/pyecsca/ec/mult/comb.py +++ b/pyecsca/ec/mult/comb.py @@ -60,6 +60,14 @@ class BGMWMultiplier(AccumulatorMultiplier, ScalarMultiplier): self.direction = direction self.width = width + def __hash__(self): + return id(self) + + def __eq__(self, other): + if not isinstance(other, BGMWMultiplier): + return False + return self.formulas == other.formulas and self.short_circuit == other.short_circuit and self.width == other.width and self.direction == other.direction and self.accumulation_order == other.accumulation_order + def __repr__(self): return f"{self.__class__.__name__}({', '.join(map(str, self.formulas.values()))}, short_circuit={self.short_circuit}, width={self.width}, direction={self.direction.name}, accumulation_order={self.accumulation_order.name})" @@ -138,6 +146,14 @@ class CombMultiplier(AccumulatorMultiplier, ScalarMultiplier): ) self.width = width + def __hash__(self): + return id(self) + + def __eq__(self, other): + if not isinstance(other, CombMultiplier): + return False + return self.formulas == other.formulas and self.short_circuit == other.short_circuit and self.width == other.width and self.accumulation_order == other.accumulation_order + def __repr__(self): return f"{self.__class__.__name__}({', '.join(map(str, self.formulas.values()))}, short_circuit={self.short_circuit}, width={self.width}, accumulation_order={self.accumulation_order.name})" |
