aboutsummaryrefslogtreecommitdiff
path: root/frozen_deps/ecdsa/test_ellipticcurve.py
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2024-08-23 03:14:03 +0000
committerDeterminant <[email protected]>2024-08-22 20:34:57 -0700
commit8d1c76ec7caf247d5675e14260d20fc508977ffb (patch)
tree8fa7c8ce3b7e3f4ece150a6da5922b5eb2dc7772 /frozen_deps/ecdsa/test_ellipticcurve.py
parent258780284151d49cba1d9c0d2ce33f9a19bb058b (diff)
release v0.1.8
Diffstat (limited to 'frozen_deps/ecdsa/test_ellipticcurve.py')
-rw-r--r--frozen_deps/ecdsa/test_ellipticcurve.py63
1 files changed, 60 insertions, 3 deletions
diff --git a/frozen_deps/ecdsa/test_ellipticcurve.py b/frozen_deps/ecdsa/test_ellipticcurve.py
index 85faef4..9bf0951 100644
--- a/frozen_deps/ecdsa/test_ellipticcurve.py
+++ b/frozen_deps/ecdsa/test_ellipticcurve.py
@@ -14,7 +14,7 @@ try:
except ImportError: # pragma: no cover
HC_PRESENT = False
from .numbertheory import inverse_mod
-from .ellipticcurve import CurveFp, INFINITY, Point
+from .ellipticcurve import CurveFp, INFINITY, Point, CurveEdTw
HYP_SETTINGS = {}
@@ -40,11 +40,11 @@ g_23 = Point(c_23, 13, 7, 7)
HYP_SLOW_SETTINGS = dict(HYP_SETTINGS)
-HYP_SLOW_SETTINGS["max_examples"] = 10
+HYP_SLOW_SETTINGS["max_examples"] = 2
@settings(**HYP_SLOW_SETTINGS)
-@given(st.integers(min_value=1, max_value=r + 1))
+@given(st.integers(min_value=1, max_value=r - 1))
def test_p192_mult_tests(multiple):
inv_m = inverse_mod(multiple, r)
@@ -97,6 +97,32 @@ class TestCurve(unittest.TestCase):
self.assertDictEqual({c_23: None}, {eq1: None})
self.assertIn(eq2, {eq3: None})
+ def test___str__(self):
+ self.assertEqual(str(self.c_23), "CurveFp(p=23, a=1, b=1)")
+
+ def test___str___with_cofactor(self):
+ c = CurveFp(23, 1, 1, 4)
+ self.assertEqual(str(c), "CurveFp(p=23, a=1, b=1, h=4)")
+
+
+class TestCurveEdTw(unittest.TestCase):
+ @classmethod
+ def setUpClass(cls):
+ cls.c_23 = CurveEdTw(23, 1, 1)
+
+ def test___str__(self):
+ self.assertEqual(str(self.c_23), "CurveEdTw(p=23, a=1, d=1)")
+
+ def test___str___with_cofactor(self):
+ c = CurveEdTw(23, 1, 1, 4)
+ self.assertEqual(str(c), "CurveEdTw(p=23, a=1, d=1, h=4)")
+
+ def test_usability_in_a_hashed_collection_curves(self):
+ {self.c_23: None}
+
+ def test_hashability_curves(self):
+ hash(self.c_23)
+
class TestPoint(unittest.TestCase):
@classmethod
@@ -197,3 +223,34 @@ class TestPoint(unittest.TestCase):
def test_inequality_points_diff_types(self):
c = CurveFp(100, -3, 100)
self.assertNotEqual(self.g_23, c)
+
+ def test_to_bytes_from_bytes(self):
+ p = Point(self.c_23, 3, 10)
+
+ self.assertEqual(p, Point.from_bytes(self.c_23, p.to_bytes()))
+
+ def test_add_to_neg_self(self):
+ p = Point(self.c_23, 3, 10)
+
+ self.assertEqual(INFINITY, p + (-p))
+
+ def test_add_to_infinity(self):
+ p = Point(self.c_23, 3, 10)
+
+ self.assertIs(p, p + INFINITY)
+
+ def test_mul_infinity_by_scalar(self):
+ self.assertIs(INFINITY, INFINITY * 10)
+
+ def test_mul_by_negative(self):
+ p = Point(self.c_23, 3, 10)
+
+ self.assertEqual(p * -5, (-p) * 5)
+
+ def test_str_infinity(self):
+ self.assertEqual(str(INFINITY), "infinity")
+
+ def test_str_point(self):
+ p = Point(self.c_23, 3, 10)
+
+ self.assertEqual(str(p), "(3,10)")