diff options
| author | J08nY | 2023-08-25 18:51:28 +0200 |
|---|---|---|
| committer | J08nY | 2023-08-25 18:51:28 +0200 |
| commit | f86f00abae6a105f3db78d52dc1257ca79906257 (patch) | |
| tree | 34f9520916e87e0c4dba8468df2d1cead0b0edd4 | |
| parent | 4a2e8161c526d9eb2b892e89cdfeae14f8398457 (diff) | |
| download | pyecsca-f86f00abae6a105f3db78d52dc1257ca79906257.tar.gz pyecsca-f86f00abae6a105f3db78d52dc1257ca79906257.tar.zst pyecsca-f86f00abae6a105f3db78d52dc1257ca79906257.zip | |
Fix issue #14.
Not really an issue, the prime in the test did not satisfy the
formula assumption so it should have failed.
| -rw-r--r-- | test/ec/test_mult.py | 4 | ||||
| -rw-r--r-- | test/ec/test_regress.py | 18 |
2 files changed, 17 insertions, 5 deletions
diff --git a/test/ec/test_mult.py b/test/ec/test_mult.py index 24306ad..5e0b514 100644 --- a/test/ec/test_mult.py +++ b/test/ec/test_mult.py @@ -292,8 +292,7 @@ def test_basic_multipliers(secp128r1, num, add, dbl): ladder_options = {"complete": (True, False)} ladders = [SimpleLadderMultiplier(add, dbl, scale, **dict(zip(ladder_options.keys(), combination))) for combination in product(*ladder_options.values())] fixed_options = {"m": (5, 8)} - fixeds = [FixedWindowLTRMultiplier(add, dbl, scl=scale, **dict(zip(fixed_options.keys(), combination))) for - combination in product(*fixed_options.values())] + fixeds = [FixedWindowLTRMultiplier(add, dbl, scl=scale, **dict(zip(fixed_options.keys(), combination))) for combination in product(*fixed_options.values())] mults: Sequence[ScalarMultiplier] = ltrs + rtls + bnafs + wnafs + [CoronMultiplier(add, dbl, scale)] + ladders + fixeds results = [] @@ -303,7 +302,6 @@ def test_basic_multipliers(secp128r1, num, add, dbl): if results: assert res == results[-1], f"Points not equal {res} != {results[-1]} for mult = {mult}" results.append(res) - print(len(results)) def test_init_fail(curve25519, secp128r1): diff --git a/test/ec/test_regress.py b/test/ec/test_regress.py index f032de2..886d7cc 100644 --- a/test/ec/test_regress.py +++ b/test/ec/test_regress.py @@ -6,6 +6,7 @@ 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 @@ -94,13 +95,26 @@ def test_issue_13(): formula(p, PmQ, P, Q, c=c, r=r, d=d) -@pytest.mark.xfail(reason="Unresolved issue currently.") def test_issue_14(): model = EdwardsModel() coords = model.coordinates["projective"] affine = AffineCoordinateModel(model) formula = coords.formulas["add-2007-bl-4"] - p = 19 + + with pytest.raises(UnsatisfiedAssumptionError): + # p is 3 mod 4, so there is no square root of -1 + 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) + formula(p, P, Q, **curve.parameters)[0] + + # p is 1 mod 4, so there is a square root of -1 + p = 29 c = Mod(2, p) d = Mod(10, p) curve = EllipticCurve(model, coords, p, InfinityPoint(coords), {"c": c, "d": d}) |
