aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/ec
diff options
context:
space:
mode:
authorJ08nY2021-01-20 02:33:45 +0100
committerJ08nY2021-01-20 02:33:45 +0100
commitadc3cd52147f35e0a7cc9008ac96619dd89cda48 (patch)
tree5d192ca410c844642c4e6583da64b0189dcfb5cb /test/ec
parent7b9d67964807df4a7dd5de9e63f8ebf21a93850f (diff)
downloadpyecsca-adc3cd52147f35e0a7cc9008ac96619dd89cda48.tar.gz
pyecsca-adc3cd52147f35e0a7cc9008ac96619dd89cda48.tar.zst
pyecsca-adc3cd52147f35e0a7cc9008ac96619dd89cda48.zip
Fix codestyle and typing issues in tests.
Diffstat (limited to 'test/ec')
-rw-r--r--test/ec/test_curve.py1
-rw-r--r--test/ec/test_mod.py2
-rw-r--r--test/ec/test_mult.py6
-rw-r--r--test/ec/test_op.py3
-rw-r--r--test/ec/test_point.py2
-rw-r--r--test/ec/utils.py4
6 files changed, 10 insertions, 8 deletions
diff --git a/test/ec/test_curve.py b/test/ec/test_curve.py
index cbc1d14..c358c68 100644
--- a/test/ec/test_curve.py
+++ b/test/ec/test_curve.py
@@ -134,4 +134,3 @@ class CurveTests(TestCase):
affine_curve.decode_point(unhexlify("7a161ff7528b899b2d0c28607ca52c5b86"))
with self.assertRaises(ValueError):
affine_curve.decode_point(unhexlify("03161ff7528b899b2d0c28607ca52c5b88"))
-
diff --git a/test/ec/test_mod.py b/test/ec/test_mod.py
index d21238b..4c0c483 100644
--- a/test/ec/test_mod.py
+++ b/test/ec/test_mod.py
@@ -74,7 +74,7 @@ class ModTests(TestCase):
a = Mod(5, 7)
self.assertEqual(a**(-1), a.inverse())
self.assertEqual(a**0, Mod(1, 7))
- self.assertEqual(a**(-2),a.inverse()**2)
+ self.assertEqual(a**(-2), a.inverse()**2)
def test_wrong_mod(self):
a = Mod(5, 7)
diff --git a/test/ec/test_mult.py b/test/ec/test_mult.py
index a1c6725..19db2b2 100644
--- a/test/ec/test_mult.py
+++ b/test/ec/test_mult.py
@@ -136,7 +136,7 @@ class ScalarMultiplierTests(TestCase):
formulas = self.get_formulas(self.coords, add, dbl, neg, scale)
mult = WindowNAFMultiplier(*formulas[:3], width, *formulas[3:])
mult.init(self.secp128r1, self.base)
- res = mult.multiply(157*789)
+ res = mult.multiply(157 * 789)
other = mult.multiply(157)
mult.init(self.secp128r1, other)
other = mult.multiply(789)
@@ -147,14 +147,14 @@ class ScalarMultiplierTests(TestCase):
mult = WindowNAFMultiplier(*formulas[:3], width, *formulas[3:],
precompute_negation=True)
mult.init(self.secp128r1, self.base)
- res_precompute = mult.multiply(157*789)
+ res_precompute = mult.multiply(157 * 789)
self.assertPointEquality(res_precompute, res, scale)
@parameterized.expand(cartesian([
("10", 10),
("2355498743", 2355498743),
("325385790209017329644351321912443757746", 325385790209017329644351321912443757746)
- ],[
+ ], [
("add-1998-cmo", "dbl-1998-cmo"),
("add-2016-rcb", "dbl-2016-rcb")
]))
diff --git a/test/ec/test_op.py b/test/ec/test_op.py
index 9471148..019e0e8 100644
--- a/test/ec/test_op.py
+++ b/test/ec/test_op.py
@@ -38,9 +38,10 @@ class OpTests(TestCase):
res = op(**locals)
self.assertEqual(res, result)
+
class OpResultTests(TestCase):
def test_str(self):
for op, char in zip((ast.Add(), ast.Sub(), ast.Mult(), ast.Div()), "+-*/"):
res = OpResult("X1", Mod(0, 5), op, Mod(2, 5), Mod(3, 5))
- self.assertEqual(str(res), "X1") \ No newline at end of file
+ self.assertEqual(str(res), "X1")
diff --git a/test/ec/test_point.py b/test/ec/test_point.py
index 0fabbf1..9bff800 100644
--- a/test/ec/test_point.py
+++ b/test/ec/test_point.py
@@ -48,7 +48,7 @@ class PointTests(TestCase):
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):
self.base.to_model(self.coords, self.secp128r1.curve)
diff --git a/test/ec/utils.py b/test/ec/utils.py
index e1812b3..67a9cc0 100644
--- a/test/ec/utils.py
+++ b/test/ec/utils.py
@@ -1,10 +1,12 @@
from itertools import product
from functools import reduce
+
def slow(func):
func.slow = 1
return func
+
def cartesian(*items):
for cart in product(*items):
- yield reduce(lambda x, y: x + y, cart) \ No newline at end of file
+ yield reduce(lambda x, y: x + y, cart)