aboutsummaryrefslogtreecommitdiff
path: root/test/ec/test_regress.py
diff options
context:
space:
mode:
authorJ08nY2024-07-15 18:15:45 +0200
committerJ08nY2024-07-15 18:15:45 +0200
commit06e005a48af4a704b38f933f500f03a0af2630d3 (patch)
tree1712620fc37c5d5798913af491a7e2b851251fd5 /test/ec/test_regress.py
parentba894fe889d003f2766b7bb90503960fd0429cd5 (diff)
downloadpyecsca-06e005a48af4a704b38f933f500f03a0af2630d3.tar.gz
pyecsca-06e005a48af4a704b38f933f500f03a0af2630d3.tar.zst
pyecsca-06e005a48af4a704b38f933f500f03a0af2630d3.zip
Diffstat (limited to 'test/ec/test_regress.py')
-rw-r--r--test/ec/test_regress.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/test/ec/test_regress.py b/test/ec/test_regress.py
index 8d54e98..cbfb08b 100644
--- a/test/ec/test_regress.py
+++ b/test/ec/test_regress.py
@@ -7,7 +7,7 @@ from pyecsca.ec.coordinates import AffineCoordinateModel
from pyecsca.ec.curve import EllipticCurve
from pyecsca.ec.error import UnsatisfiedAssumptionError
from pyecsca.ec.formula import AdditionFormula, DoublingFormula, ScalingFormula
-from pyecsca.ec.mod import Mod, SymbolicMod
+from pyecsca.ec.mod import Mod, SymbolicMod, mod
from pyecsca.ec.model import MontgomeryModel, EdwardsModel
from pyecsca.ec.params import get_params
from pyecsca.ec.mult import LTRMultiplier
@@ -48,13 +48,13 @@ def test_issue_9():
model = MontgomeryModel()
coords = model.coordinates["xz"]
p = 19
- neutral = Point(coords, X=Mod(1, p), Z=Mod(0, p))
- curve = EllipticCurve(model, coords, p, neutral, {"a": Mod(8, p), "b": Mod(1, p)})
- base = Point(coords, X=Mod(12, p), Z=Mod(1, p))
+ neutral = Point(coords, X=mod(1, p), Z=mod(0, p))
+ curve = EllipticCurve(model, coords, p, neutral, {"a": mod(8, p), "b": mod(1, p)})
+ base = Point(coords, X=mod(12, p), Z=mod(1, p))
formula = coords.formulas["dbl-1987-m-2"]
res = formula(p, base, **curve.parameters)[0]
assert res is not None
- affine_base = Point(AffineCoordinateModel(model), x=Mod(12, p), y=Mod(2, p))
+ affine_base = Point(AffineCoordinateModel(model), x=mod(12, p), y=mod(2, p))
dbase = curve.affine_double(affine_base).to_model(coords, curve)
ladder = coords.formulas["ladd-1987-m-3"]
one, other = ladder(p, base, dbase, base, **curve.parameters)
@@ -67,14 +67,14 @@ def test_issue_10():
coords = model.coordinates["yz"]
coords_sqr = model.coordinates["yzsquared"]
p = 0x1D
- c = Mod(1, p)
- d = Mod(0x1C, p)
+ c = mod(1, p)
+ d = mod(0x1C, p)
r = d.sqrt()
- neutral = Point(coords, Y=c * r, Z=Mod(1, p))
+ neutral = Point(coords, Y=c * r, Z=mod(1, p))
curve = EllipticCurve(model, coords, p, neutral, {"c": c, "d": d, "r": r})
- neutral_affine = Point(AffineCoordinateModel(model), x=Mod(0, p), y=c)
+ neutral_affine = Point(AffineCoordinateModel(model), x=mod(0, p), y=c)
assert neutral == neutral_affine.to_model(coords, curve)
- neutral_sqr = Point(coords_sqr, Y=c ** 2 * r, Z=Mod(1, p))
+ neutral_sqr = Point(coords_sqr, Y=c ** 2 * r, Z=mod(1, p))
assert neutral_sqr == neutral_affine.to_model(coords_sqr, curve)
@@ -103,23 +103,23 @@ def test_issue_14():
with pytest.raises(UnsatisfiedAssumptionError):
# p is 3 mod 4, so there is no square root of -1
p = 19
- c = Mod(2, p)
- d = Mod(10, p)
+ c = mod(2, p)
+ d = mod(10, p)
curve = EllipticCurve(model, coords, p, InfinityPoint(coords), {"c": c, "d": d})
- Paff = Point(affine, x=Mod(0xD, p), y=Mod(0x9, p))
+ Paff = Point(affine, x=mod(0xD, p), y=mod(0x9, p))
P = Paff.to_model(coords, curve)
- Qaff = Point(affine, x=Mod(0x4, p), y=Mod(0x12, p))
+ Qaff = Point(affine, x=mod(0x4, p), y=mod(0x12, p))
Q = Qaff.to_model(coords, curve)
formula(p, P, Q, **curve.parameters)[0]
# p is 1 mod 4, so there is a square root of -1
p = 29
- c = Mod(2, p)
- d = Mod(10, p)
+ c = mod(2, p)
+ d = mod(10, p)
curve = EllipticCurve(model, coords, p, InfinityPoint(coords), {"c": c, "d": d})
- Paff = Point(affine, x=Mod(0xD, p), y=Mod(0x9, p))
+ Paff = Point(affine, x=mod(0xD, p), y=mod(0x9, p))
P = Paff.to_model(coords, curve)
- Qaff = Point(affine, x=Mod(0x4, p), y=Mod(0x12, p))
+ Qaff = Point(affine, x=mod(0x4, p), y=mod(0x12, p))
Q = Qaff.to_model(coords, curve)
PQaff = curve.affine_add(Paff, Qaff)
R = formula(p, P, Q, **curve.parameters)[0]