diff options
| author | J08nY | 2023-08-04 14:37:37 +0200 |
|---|---|---|
| committer | J08nY | 2023-08-04 14:37:37 +0200 |
| commit | e54a414a9dd303dac78e435df9d84fe1bcef4676 (patch) | |
| tree | 7d3250777e63f26ce328c756c0d4ac0f64e7280a /test | |
| parent | 1a98db475e5ecd757411b368dd65f8f894665178 (diff) | |
| download | pyecsca-e54a414a9dd303dac78e435df9d84fe1bcef4676.tar.gz pyecsca-e54a414a9dd303dac78e435df9d84fe1bcef4676.tar.zst pyecsca-e54a414a9dd303dac78e435df9d84fe1bcef4676.zip | |
Add .to_coords to domain params and curve objects.
Also adds coordinate assumption validation to ec curve constructor.
Diffstat (limited to 'test')
| -rw-r--r-- | test/ec/test_curve.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ec/test_curve.py b/test/ec/test_curve.py index 345d3de..bc0cdaf 100644 --- a/test/ec/test_curve.py +++ b/test/ec/test_curve.py @@ -3,6 +3,7 @@ from unittest import TestCase from pyecsca.ec.coordinates import AffineCoordinateModel from pyecsca.ec.curve import EllipticCurve +from pyecsca.ec.error import UnsatisfiedAssumptionError from pyecsca.ec.params import get_params from pyecsca.ec.mod import Mod from pyecsca.ec.model import MontgomeryModel @@ -45,6 +46,20 @@ class CurveTests(TestCase): parameters={"a": Mod(1, 5), "b": Mod(2, 5)}, ) + def test_to_coords(self): + affine = self.secp128r1.to_affine() + m1_coords = affine.curve.model.coordinates["projective-1"] + m3_coords = affine.curve.model.coordinates["projective-3"] + with self.assertRaises(UnsatisfiedAssumptionError): + affine.to_coords(m1_coords) + affine.to_coords(m3_coords) + + def test_to_affine(self): + affine = self.secp128r1.to_affine() + model = AffineCoordinateModel(affine.curve.model) + self.assertEqual(affine.curve.coordinate_model, model) + self.assertEqual(affine.generator.coordinate_model, model) + def test_is_neutral(self): self.assertTrue( self.secp128r1.curve.is_neutral( |
