diff options
| author | J08nY | 2023-08-29 16:39:07 +0200 |
|---|---|---|
| committer | J08nY | 2023-08-29 16:39:07 +0200 |
| commit | 42c52db82f97c56f1c413f68bd31e8b0ae54608e (patch) | |
| tree | ea759d8101eb0f8cfc5923f4dd45e7b502b5c00d | |
| parent | 501d17b11a86d6a3780435db5416830c9d6175e2 (diff) | |
| download | pyecsca-42c52db82f97c56f1c413f68bd31e8b0ae54608e.tar.gz pyecsca-42c52db82f97c56f1c413f68bd31e8b0ae54608e.tar.zst pyecsca-42c52db82f97c56f1c413f68bd31e8b0ae54608e.zip | |
Add better test for ZVP point construction.
| -rw-r--r-- | test/sca/test_zvp.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/test/sca/test_zvp.py b/test/sca/test_zvp.py index 76fb7cb..bcca4e1 100644 --- a/test/sca/test_zvp.py +++ b/test/sca/test_zvp.py @@ -2,10 +2,12 @@ import pytest from pyecsca.sca.re.zvp import unroll_formula, subs_curve_equation, remove_z, eliminate_y, subs_dlog, subs_curve_params, \ zvp_point +from pyecsca.ec.context import local, DefaultContext +from pyecsca.ec.formula import FormulaAction from sympy import symbols, Poly -@pytest.fixture(params=["add-2007-bl", "dbl-2007-bl", "add-2016-rcb"]) +@pytest.fixture(params=["add-2007-bl", "add-2016-rcb"]) def formula(secp128r1, request): return secp128r1.curve.coordinate_model.formulas[request.param] @@ -71,3 +73,13 @@ def test_zvp(secp128r1, formula): poly = unrolled[-2] points = zvp_point(poly, secp128r1.curve, 5) assert isinstance(points, set) + + for point in points: + second_point = secp128r1.curve.affine_multiply(point, 5) + p = point.to_model(formula.coordinate_model, secp128r1.curve) + q = second_point.to_model(formula.coordinate_model, secp128r1.curve) + with local(DefaultContext()) as ctx: + formula(secp128r1.curve.prime, p, q, **secp128r1.curve.parameters) + action = next(iter(ctx.actions.keys())) + results = list(map(lambda o: int(o.value), action.op_results)) + assert 0 in results |
