diff options
| -rw-r--r-- | pyecsca/ec/formula/fake.py | 6 | ||||
| -rw-r--r-- | pyecsca/ec/point.py | 6 | ||||
| -rw-r--r-- | test/sca/test_regress.py | 18 |
3 files changed, 28 insertions, 2 deletions
diff --git a/pyecsca/ec/formula/fake.py b/pyecsca/ec/formula/fake.py index 9ea7934..d9e8545 100644 --- a/pyecsca/ec/formula/fake.py +++ b/pyecsca/ec/formula/fake.py @@ -104,3 +104,9 @@ class FakePoint(Point): def __hash__(self): return id(self) + + def __copy__(self): + return self + + def __deepcopy__(self, memo): + return self diff --git a/pyecsca/ec/point.py b/pyecsca/ec/point.py index 5a486bc..5d5fbef 100644 --- a/pyecsca/ec/point.py +++ b/pyecsca/ec/point.py @@ -144,7 +144,7 @@ class Point: lmbd = Mod.random(curve.prime) for var, value in result.items(): weight = coordinate_model.homogweights[var] - lpow = lmbd ** weight + lpow = lmbd**weight result[var] = value * lpow return action.exit(Point(coordinate_model, **result)) @@ -231,7 +231,9 @@ class Point: f"Equality checking does not support {weight} weight." ) else: - lambdas = set(filter(lambda candidate: candidate ** weight == val, lambdas)) + lambdas = set( + filter(lambda candidate: candidate**weight == val, lambdas) + ) if not lambdas: return False return True diff --git a/test/sca/test_regress.py b/test/sca/test_regress.py new file mode 100644 index 0000000..067ea87 --- /dev/null +++ b/test/sca/test_regress.py @@ -0,0 +1,18 @@ +from functools import partial + +from pyecsca.ec.countermeasures import BrumleyTuveri +from pyecsca.ec.mult import LTRMultiplier +from pyecsca.ec.params import get_params +from pyecsca.sca.re.rpa import multiples_computed + + +def test_multiples_computed(): + params = get_params("secg", "secp256r1", "projective") + scalar = ( + 178351107805817428630633067540716126328949183057477388943177779766598408516705 + ) + mult_class = LTRMultiplier + mult_factory = partial(LTRMultiplier, always=False, complete=True) + full_factory = lambda *args, **kwargs: BrumleyTuveri(mult_factory(*args, **kwargs)) # noqa: E731 + r = multiples_computed(scalar, params, mult_class, full_factory) + assert r |
