aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorJ08nY2020-07-10 18:54:15 +0200
committerJ08nY2020-07-10 18:54:15 +0200
commitfcdea31b2a6efb49357ef8b2e69212ec412feaa0 (patch)
tree3a986c2bb7010bfdb59a9062de3cd78de8dc4b51 /test
parenta10e4c4339c11d5ff6b438569e3af96c1beae3e5 (diff)
downloadpyecsca-fcdea31b2a6efb49357ef8b2e69212ec412feaa0.tar.gz
pyecsca-fcdea31b2a6efb49357ef8b2e69212ec412feaa0.tar.zst
pyecsca-fcdea31b2a6efb49357ef8b2e69212ec412feaa0.zip
Fix modified coords to_model transformation.
Diffstat (limited to 'test')
-rw-r--r--test/ec/test_point.py14
-rw-r--r--test/sca/test_target.py10
2 files changed, 12 insertions, 12 deletions
diff --git a/test/ec/test_point.py b/test/ec/test_point.py
index 936d4e9..2fc4ca4 100644
--- a/test/ec/test_point.py
+++ b/test/ec/test_point.py
@@ -34,11 +34,11 @@ class PointTests(TestCase):
affine = InfinityPoint(self.coords).to_affine()
self.assertIsInstance(affine, InfinityPoint)
- def test_from_affine(self):
+ def test_to_model(self):
affine = Point(self.affine, x=Mod(0xabcd, self.secp128r1.curve.prime),
y=Mod(0xef, self.secp128r1.curve.prime))
projective_model = self.coords
- other = Point.from_affine(projective_model, affine)
+ other = affine.to_model(projective_model, self.secp128r1.curve)
self.assertEqual(other.coordinate_model, projective_model)
self.assertSetEqual(set(other.coords.keys()), set(projective_model.variables))
@@ -46,17 +46,19 @@ class PointTests(TestCase):
self.assertEqual(other.coords["Y"], affine.coords["y"])
self.assertEqual(other.coords["Z"], Mod(1, self.secp128r1.curve.prime))
- with self.assertRaises(NotImplementedError):
- InfinityPoint.from_affine(self.coords, affine)
+ infty = InfinityPoint(AffineCoordinateModel(self.secp128r1.curve.model))
+ other_infty = infty.to_model(self.coords, self.secp128r1.curve)
+ self.assertIsInstance(other_infty, InfinityPoint)
+
with self.assertRaises(ValueError):
- Point.from_affine(self.coords, self.base)
+ self.base.to_model(self.coords, self.secp128r1.curve)
def test_to_from_affine(self):
pt = Point(self.coords,
X=Mod(0x161ff7528b899b2d0c28607ca52c5b86, self.secp128r1.curve.prime),
Y=Mod(0xcf5ac8395bafeb13c02da292dded7a83, self.secp128r1.curve.prime),
Z=Mod(1, self.secp128r1.curve.prime))
- other = Point.from_affine(self.coords, pt.to_affine())
+ other = pt.to_affine().to_model(self.coords, self.secp128r1.curve)
self.assertEqual(pt, other)
def test_equals(self):
diff --git a/test/sca/test_target.py b/test/sca/test_target.py
index 3652309..d31da69 100644
--- a/test/sca/test_target.py
+++ b/test/sca/test_target.py
@@ -207,8 +207,8 @@ class ECTesterTargetTests(TestCase):
privkey = Mod(int.from_bytes(
export_privkey_resp.get_param(KeypairEnum.KEYPAIR_REMOTE, ParameterEnum.S), "big"),
self.secp256r1.curve.prime)
- pubkey_projective = Point.from_affine(self.secp256r1_projective.curve.coordinate_model,
- pubkey)
+ pubkey_projective = pubkey.to_model(self.secp256r1_projective.curve.coordinate_model, self.secp256r1.curve)
+
mult = LTRMultiplier(
self.secp256r1_projective.curve.coordinate_model.formulas["add-2016-rcb"],
self.secp256r1_projective.curve.coordinate_model.formulas["dbl-2016-rcb"])
@@ -257,8 +257,7 @@ class ECTesterTargetTests(TestCase):
ParameterEnum.W)
pubkey_bytes = export_public_resp.get_param(KeypairEnum.KEYPAIR_LOCAL, ParameterEnum.W)
pubkey = self.secp256r1.curve.decode_point(pubkey_bytes)
- pubkey_projective = Point.from_affine(self.secp256r1_projective.curve.coordinate_model,
- pubkey)
+ pubkey_projective = pubkey.to_model(self.secp256r1_projective.curve.coordinate_model, self.secp256r1.curve)
sig = SignatureResult.from_DER(ecdsa_resp.signature)
mult = LTRMultiplier(
@@ -284,8 +283,7 @@ class ECTesterTargetTests(TestCase):
ParameterEnum.W)
pubkey_bytes = export_public_resp.get_param(KeypairEnum.KEYPAIR_LOCAL, ParameterEnum.W)
pubkey = self.secp256r1.curve.decode_point(pubkey_bytes)
- pubkey_projective = Point.from_affine(self.secp256r1_projective.curve.coordinate_model,
- pubkey)
+ pubkey_projective = pubkey.to_model(self.secp256r1_projective.curve.coordinate_model, self.secp256r1.curve)
sig = SignatureResult.from_DER(ecdsa_resp.signature)
mult = LTRMultiplier(