Skip to content

Commit

Permalink
Fix issue #14.
Browse files Browse the repository at this point in the history
Not really an issue, the prime in the test did not satisfy the
formula assumption so it should have failed.
  • Loading branch information
J08nY committed Aug 25, 2023
1 parent 4a2e816 commit f86f00a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
4 changes: 1 addition & 3 deletions test/ec/test_mult.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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):
Expand Down
18 changes: 16 additions & 2 deletions test/ec/test_regress.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

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
Expand Down Expand Up @@ -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})
Expand Down

0 comments on commit f86f00a

Please sign in to comment.