diff options
| author | J08nY | 2024-07-12 15:11:55 +0200 |
|---|---|---|
| committer | J08nY | 2024-07-12 15:11:55 +0200 |
| commit | 3ed8338d53e7bcfcecfddb55452882dfce34b609 (patch) | |
| tree | 4e72447445947ef949cc22d1b74c963ff624b3b1 /test/ec | |
| parent | ee3f3db5008b982e7a1c12639dee0c9f98abddf5 (diff) | |
| download | pyecsca-3ed8338d53e7bcfcecfddb55452882dfce34b609.tar.gz pyecsca-3ed8338d53e7bcfcecfddb55452882dfce34b609.tar.zst pyecsca-3ed8338d53e7bcfcecfddb55452882dfce34b609.zip | |
Diffstat (limited to 'test/ec')
| -rw-r--r-- | test/ec/test_formula.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/test/ec/test_formula.py b/test/ec/test_formula.py index f8434fd..c066a7f 100644 --- a/test/ec/test_formula.py +++ b/test/ec/test_formula.py @@ -26,7 +26,7 @@ from pyecsca.misc.cfg import TemporaryConfig from pyecsca.ec.error import UnsatisfiedAssumptionError from pyecsca.ec.params import get_params, DomainParameters from pyecsca.ec.point import Point -from pyecsca.ec.model import ShortWeierstrassModel, MontgomeryModel, TwistedEdwardsModel +from pyecsca.ec.model import ShortWeierstrassModel, MontgomeryModel, TwistedEdwardsModel, EdwardsModel from pyecsca.ec.formula.efd import ( AdditionEFDFormula, DoublingEFDFormula, @@ -109,14 +109,23 @@ def test_assumptions(secp128r1, mdbl): assert pt is not None -def test_parameters(): - jac_secp128r1 = get_params("secg", "secp128r1", "jacobian") - jac_dbl = jac_secp128r1.curve.coordinate_model.formulas["dbl-1998-hnm"] +@pytest.mark.parametrize( + "formula,category,curve,coords", + [("dbl-1998-hnm", "secg", "secp128r1", "jacobian"), + ("add-2015-rcb", "secg", "secp128r1", "projective"), + ("dbl-1987-m-2", "other", "Curve25519", "xz"), + ("add-20090311-hwcd", "other", "E-222", "projective")] +) +def test_eval(formula, category, curve, coords): + params = get_params(category, curve, coords) + f = params.curve.coordinate_model.formulas[formula] + + points = [params.curve.affine_random().to_model(params.curve.coordinate_model, params.curve) for _ in range(f.num_inputs)] - res = jac_dbl( - jac_secp128r1.curve.prime, - jac_secp128r1.generator, - **jac_secp128r1.curve.parameters, + res = f( + params.curve.prime, + *points, + **params.curve.parameters, ) assert res is not None |
