diff options
Diffstat (limited to 'test/ec')
| -rw-r--r-- | test/ec/test_divpoly.py | 4 | ||||
| -rw-r--r-- | test/ec/test_params.py | 32 |
2 files changed, 22 insertions, 14 deletions
diff --git a/test/ec/test_divpoly.py b/test/ec/test_divpoly.py index 9773624..f09fdf0 100644 --- a/test/ec/test_divpoly.py +++ b/test/ec/test_divpoly.py @@ -1,6 +1,8 @@ from unittest import TestCase import json +from importlib.resources import files +import test.data.divpoly from sympy import FF from pyecsca.ec.divpoly import a_invariants, b_invariants, divpoly0, divpoly, mult_by_n from pyecsca.ec.model import ShortWeierstrassModel @@ -172,7 +174,7 @@ class DivpolyTests(TestCase): def test_mult_by_n_large(self): K = FF(self.secp128r1.curve.prime) mx, my = mult_by_n(self.secp128r1.curve, 21) - with open("test/data/divpoly/mult_21.json") as f: + with files(test.data.divpoly).joinpath("mult_21.json").open("r") as f: sage_data = json.load(f) sage_data["mx"][0] = {eval(key): K(val) for key, val in sage_data["mx"][0].items()} sage_data["mx"][1] = {eval(key): K(val) for key, val in sage_data["mx"][1].items()} diff --git a/test/ec/test_params.py b/test/ec/test_params.py index 23cac3f..9f18ded 100644 --- a/test/ec/test_params.py +++ b/test/ec/test_params.py @@ -1,7 +1,9 @@ from unittest import TestCase from parameterized import parameterized +from importlib.resources import files, as_file +import test.data.ec from pyecsca.ec.mod import Mod from pyecsca.ec.point import Point, InfinityPoint from pyecsca.misc.cfg import TemporaryConfig @@ -57,25 +59,29 @@ class DomainParameterTests(TestCase): get_category(name, coords) def test_load_params(self): - params = load_params("test/data/curve.json", "projective") - try: - assert params.curve.is_on_curve(params.generator) - except NotImplementedError: - pass + with as_file(files(test.data.ec).joinpath("curve.json")) as path: + params = load_params(path, "projective") + try: + assert params.curve.is_on_curve(params.generator) + except NotImplementedError: + pass def test_load_params_ectester(self): - params = load_params_ectester("test/data/ectester_secp128r1.csv", "projective") - assert params.curve.is_on_curve(params.generator) - self.assertEqual(params, self.secp128r1) + with as_file(files(test.data.ec).joinpath("ectester_secp128r1.csv")) as path: + params = load_params_ectester(path, "projective") + assert params.curve.is_on_curve(params.generator) + self.assertEqual(params, self.secp128r1) def test_load_params_ecgen(self): - params = load_params_ecgen("test/data/ecgen_secp128r1.json", "projective") - assert params.curve.is_on_curve(params.generator) - self.assertEqual(params, self.secp128r1) + with as_file(files(test.data.ec).joinpath("ecgen_secp128r1.json")) as path: + params = load_params_ecgen(path, "projective") + assert params.curve.is_on_curve(params.generator) + self.assertEqual(params, self.secp128r1) def test_load_category(self): - category = load_category("test/data/curves.json", "yz") - self.assertEqual(len(category), 1) + with as_file(files(test.data.ec).joinpath("curves.json")) as path: + category = load_category(path, "yz") + self.assertEqual(len(category), 1) @parameterized.expand( [ |
