aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/ec/test_point.py
diff options
context:
space:
mode:
authorJ08nY2019-04-22 18:04:44 +0200
committerJ08nY2019-04-22 18:04:44 +0200
commit24b9b3958a54bdf7f18df62ae14199749934e3c2 (patch)
treea758d0289337f6aee7540dca4a94ea31ced69217 /test/ec/test_point.py
parent037194fd8cfe50aa2367c2f3c7fae5b41e7b46f9 (diff)
downloadpyecsca-24b9b3958a54bdf7f18df62ae14199749934e3c2.tar.gz
pyecsca-24b9b3958a54bdf7f18df62ae14199749934e3c2.tar.zst
pyecsca-24b9b3958a54bdf7f18df62ae14199749934e3c2.zip
Add ECDH and ECDSA simulation.
Diffstat (limited to 'test/ec/test_point.py')
-rw-r--r--test/ec/test_point.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ec/test_point.py b/test/ec/test_point.py
index a59204b..f6f53c8 100644
--- a/test/ec/test_point.py
+++ b/test/ec/test_point.py
@@ -25,6 +25,7 @@ class PointTests(TestCase):
self.assertSetEqual(set(affine.coords.keys()), set(self.affine.variables))
self.assertEqual(affine.coords["x"], pt.coords["X"])
self.assertEqual(affine.coords["y"], pt.coords["Y"])
+ self.assertEqual(affine.to_affine(), affine)
affine = InfinityPoint(self.coords).to_affine()
self.assertIsInstance(affine, InfinityPoint)
@@ -41,6 +42,9 @@ 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)
+
def test_to_from_affine(self):
pt = Point(self.coords,
X=Mod(0x161ff7528b899b2d0c28607ca52c5b86, self.secp128r1.curve.prime),
@@ -60,3 +64,19 @@ class PointTests(TestCase):
Z=Mod(1, self.secp128r1.curve.prime))
assert pt.equals(other)
self.assertNotEquals(pt, other)
+ assert not pt.equals(2)
+ self.assertNotEquals(pt, 2)
+
+ infty_one = InfinityPoint(self.coords)
+ infty_other = InfinityPoint(self.coords)
+ assert infty_one.equals(infty_other)
+ self.assertEquals(infty_one, infty_other)
+
+ def test_repr(self):
+ self.assertEqual(str(self.base),
+ "[X=29408993404948928992877151431649155974, Y=275621562871047521857442314737465260675, Z=1]")
+ self.assertEqual(repr(self.base),
+ "Point([[X=29408993404948928992877151431649155974, Y=275621562871047521857442314737465260675, Z=1]] in EFDCoordinateModel(\"projective\" on short Weierstrass curves))")
+ self.assertEqual(str(InfinityPoint(self.coords)), "Infinity")
+ self.assertEqual(repr(InfinityPoint(self.coords)),
+ "InfinityPoint(EFDCoordinateModel(\"projective\" on short Weierstrass curves))")