diff options
| author | J08nY | 2023-10-04 16:40:31 +0200 |
|---|---|---|
| committer | J08nY | 2023-10-04 16:40:31 +0200 |
| commit | bff6dc1e9777000d9a1867ce3f0863cbb3900896 (patch) | |
| tree | 75c3c972853b94ddf3a19536c899e26ca4b63479 /pyecsca/ec/mult/window.py | |
| parent | 1c25c3fa1b752c170092d0fff34e1a14f363c602 (diff) | |
| download | pyecsca-bff6dc1e9777000d9a1867ce3f0863cbb3900896.tar.gz pyecsca-bff6dc1e9777000d9a1867ce3f0863cbb3900896.tar.zst pyecsca-bff6dc1e9777000d9a1867ce3f0863cbb3900896.zip | |
Diffstat (limited to 'pyecsca/ec/mult/window.py')
| -rw-r--r-- | pyecsca/ec/mult/window.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/pyecsca/ec/mult/window.py b/pyecsca/ec/mult/window.py index 8b1ae2c..3ee8c50 100644 --- a/pyecsca/ec/mult/window.py +++ b/pyecsca/ec/mult/window.py @@ -1,3 +1,4 @@ +"""Provides sliding window and fixed window scalar multipliers (including m-ary, for non power-of-2 m).""" from copy import copy from typing import Optional, MutableMapping from public import public @@ -49,6 +50,9 @@ class SlidingWindowMultiplier(AccumulatorMultiplier, ScalarMultiplier): return False return self.formulas == other.formulas and self.short_circuit == other.short_circuit and self.width == other.width and self.recoding_direction == other.recoding_direction and self.accumulation_order == other.accumulation_order + def __repr__(self): + return f"{self.__class__.__name__}({tuple(self.formulas.values())}, short_circuit={self.short_circuit}, width={self.width}, recoding_direction={self.recoding_direction}, accumulation_order={self.accumulation_order})" + def init(self, params: DomainParameters, point: Point): with PrecomputationAction(params, point): super().init(params, point) @@ -81,7 +85,15 @@ class SlidingWindowMultiplier(AccumulatorMultiplier, ScalarMultiplier): @public class FixedWindowLTRMultiplier(AccumulatorMultiplier, ScalarMultiplier): - """Like LTRMultiplier, but not binary, but m-ary.""" + """ + Like LTRMultiplier, but m-ary, not binary. + + For `m` a power-of-2 this is a fixed window multiplier + that works on `log_2(m)` wide windows and uses only doublings + to perform the multiplication-by-m between each window addition. + + For other `m` values, this is the m-ary multiplier. + """ requires = {AdditionFormula, DoublingFormula} optionals = {ScalingFormula} @@ -114,6 +126,9 @@ class FixedWindowLTRMultiplier(AccumulatorMultiplier, ScalarMultiplier): return False return self.formulas == other.formulas and self.short_circuit == other.short_circuit and self.m == other.m and self.accumulation_order == other.accumulation_order + def __repr__(self): + return f"{self.__class__.__name__}({tuple(self.formulas.values())}, short_circuit={self.short_circuit}, m={self.m}, accumulation_order={self.accumulation_order})" + def init(self, params: DomainParameters, point: Point): with PrecomputationAction(params, point): super().init(params, point) |
