diff options
| author | J08nY | 2021-05-20 23:16:34 +0200 |
|---|---|---|
| committer | J08nY | 2021-05-20 23:16:34 +0200 |
| commit | da1022d678aa6e5e8036d5f0046320a9659cd8ac (patch) | |
| tree | ec61ff805e42d99cf39e886ab611c7bff234c48d | |
| parent | a10c12943d1a27bec481dae9a1d012df6f39c7d9 (diff) | |
| download | pyecsca-da1022d678aa6e5e8036d5f0046320a9659cd8ac.tar.gz pyecsca-da1022d678aa6e5e8036d5f0046320a9659cd8ac.tar.zst pyecsca-da1022d678aa6e5e8036d5f0046320a9659cd8ac.zip | |
Add reproducer for issue #14.
| -rw-r--r-- | pyecsca/ec/formula.py | 3 | ||||
| -rw-r--r-- | test/ec/test_regress.py | 24 | ||||
| -rw-r--r-- | test/sca/test_rpa.py | 3 |
3 files changed, 25 insertions, 5 deletions
diff --git a/pyecsca/ec/formula.py b/pyecsca/ec/formula.py index ef206ab..0188271 100644 --- a/pyecsca/ec/formula.py +++ b/pyecsca/ec/formula.py @@ -200,7 +200,8 @@ class Formula(ABC): break else: raise UnsatisfiedAssumptionError( - f"Unsatisfied assumption in the formula ({assumption_string})." + f"Unsatisfied assumption in the formula ({assumption_string}).\n" + f"'{expr}' has no roots in the base field {k}." ) def __call__(self, field: int, *points: Any, **params: Mod) -> Tuple[Any, ...]: diff --git a/test/ec/test_regress.py b/test/ec/test_regress.py index 9304c9e..4cb5f3c 100644 --- a/test/ec/test_regress.py +++ b/test/ec/test_regress.py @@ -1,15 +1,16 @@ from typing import cast -from unittest import TestCase +from unittest import TestCase, skip from sympy import symbols from pyecsca.ec.coordinates import AffineCoordinateModel from pyecsca.ec.curve import EllipticCurve +from pyecsca.ec.error import UnsatisfiedAssumptionError from pyecsca.ec.formula import AdditionFormula, DoublingFormula, ScalingFormula from pyecsca.ec.mod import Mod, SymbolicMod from pyecsca.ec.model import MontgomeryModel, EdwardsModel from pyecsca.ec.params import get_params from pyecsca.ec.mult import LTRMultiplier -from pyecsca.ec.point import Point +from pyecsca.ec.point import Point, InfinityPoint class RegressionTests(TestCase): @@ -91,3 +92,22 @@ class RegressionTests(TestCase): Q = Point(coords, Y=SymbolicMod(yq, p), Z=SymbolicMod(zq, p)) formula = coords.formulas["dadd-2006-g-2"] formula(p, PmQ, P, Q, c=c, r=r, d=d) + + @skip("Unresolved issue currently.") + def test_issue_14(self): + model = EdwardsModel() + coords = model.coordinates["projective"] + affine = AffineCoordinateModel(model) + formula = coords.formulas["add-2007-bl-4"] + p = 19 + c = Mod(2, p) + d = Mod(10, p) + curve = EllipticCurve(model, coords, p, InfinityPoint(coords), {"c": c, "d": d}) + Paff = Point(affine, x=Mod(0xd, p), y=Mod(0x9, p)) + P = Paff.to_model(coords, curve) + Qaff = Point(affine, x=Mod(0x4, p), y=Mod(0x12, p)) + Q = Qaff.to_model(coords, curve) + PQaff = curve.affine_add(Paff, Qaff) + R = formula(p, P, Q, **curve.parameters)[0] + Raff = R.to_affine() + self.assertEqual(PQaff, Raff) diff --git a/test/sca/test_rpa.py b/test/sca/test_rpa.py index b33915e..1f06e92 100644 --- a/test/sca/test_rpa.py +++ b/test/sca/test_rpa.py @@ -66,10 +66,9 @@ class MultipleContextTests(TestCase): def test_window(self): mult = WindowNAFMultiplier(self.add, self.dbl, self.neg, 3, precompute_negation=True) - with local(MultipleContext()) as ctx: + with local(MultipleContext()): mult.init(self.secp128r1, self.base) mult.multiply(5) - print(ctx.points.values()) def test_ladder(self): curve25519 = get_params("other", "Curve25519", "xz") |
