diff options
| author | J08nY | 2021-01-06 19:18:08 +0100 |
|---|---|---|
| committer | J08nY | 2021-01-06 19:19:17 +0100 |
| commit | b453b249dc25c008db5c069c55e0a51a91e68229 (patch) | |
| tree | 7ad840492c1309fba9261f6edca9db2448b35562 | |
| parent | 31aaaf5aa0182081a719ed5d9671012c463742bf (diff) | |
| download | pyecsca-b453b249dc25c008db5c069c55e0a51a91e68229.tar.gz pyecsca-b453b249dc25c008db5c069c55e0a51a91e68229.tar.zst pyecsca-b453b249dc25c008db5c069c55e0a51a91e68229.zip | |
Fix Edwards yzsuared to_model. Extend regression test for #10.
| -rw-r--r-- | pyecsca/ec/point.py | 2 | ||||
| -rw-r--r-- | test/ec/test_regress.py | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/pyecsca/ec/point.py b/pyecsca/ec/point.py index a3c388e..88c925b 100644 --- a/pyecsca/ec/point.py +++ b/pyecsca/ec/point.py @@ -109,7 +109,7 @@ class Point(object): elif coordinate_model.name == "yz": result[var] = result[var] * curve.parameters["r"] elif coordinate_model.name == "yzsquared": - result[var] = result[var] * curve.parameters["r"]**2 + result[var] = result[var]**2 * curve.parameters["r"] elif var.startswith("Z"): result[var] = Mod(1, curve.prime) elif var == "T": diff --git a/test/ec/test_regress.py b/test/ec/test_regress.py index 9d0d5a3..fe14eb3 100644 --- a/test/ec/test_regress.py +++ b/test/ec/test_regress.py @@ -59,6 +59,7 @@ class RegressionTests(TestCase): def test_issue_10(self): model = EdwardsModel() coords = model.coordinates["yz"] + coords_sqr = model.coordinates["yzsquared"] p = 0x1d c = Mod(1, p) d = Mod(0x1c, p) @@ -67,3 +68,5 @@ class RegressionTests(TestCase): curve = EllipticCurve(model, coords, p, neutral, {"c": c, "d": d, "r": r}) neutral_affine = Point(AffineCoordinateModel(model), x=Mod(0, p), y=c) self.assertEqual(neutral, neutral_affine.to_model(coords, curve)) + neutral_sqr = Point(coords_sqr, Y=c**2 * r, Z=Mod(1, p)) + self.assertEqual(neutral_sqr, neutral_affine.to_model(coords_sqr, curve)) |
