diff options
| author | J08nY | 2018-12-13 17:50:16 +0100 |
|---|---|---|
| committer | J08nY | 2019-03-21 11:00:14 +0100 |
| commit | 1943d7e8fc0e1e6b578e9be04fac0690e888ed88 (patch) | |
| tree | f376a7c152526454439145217c21df75c006b455 /test | |
| parent | 70a37f8134f177e02d23a402cb47344229ce4df5 (diff) | |
| download | pyecsca-1943d7e8fc0e1e6b578e9be04fac0690e888ed88.tar.gz pyecsca-1943d7e8fc0e1e6b578e9be04fac0690e888ed88.tar.zst pyecsca-1943d7e8fc0e1e6b578e9be04fac0690e888ed88.zip | |
Setup EC models, curves, formulas from efd.
Diffstat (limited to 'test')
| -rw-r--r-- | test/ec/__init__.py | 0 | ||||
| -rw-r--r-- | test/ec/test_model.py | 13 | ||||
| -rw-r--r-- | test/ec/test_mult.py | 22 |
3 files changed, 35 insertions, 0 deletions
diff --git a/test/ec/__init__.py b/test/ec/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/ec/__init__.py diff --git a/test/ec/test_model.py b/test/ec/test_model.py new file mode 100644 index 0000000..6effa45 --- /dev/null +++ b/test/ec/test_model.py @@ -0,0 +1,13 @@ +from unittest import TestCase + +from pyecsca.ec.model import (ShortWeierstrassModel, MontgomeryModel, EdwardsModel, + TwistedEdwardsModel) + + +class CurveModelTests(TestCase): + + def test_load(self): + self.assertGreater(len(ShortWeierstrassModel.coordinates), 0) + self.assertGreater(len(MontgomeryModel.coordinates), 0) + self.assertGreater(len(EdwardsModel.coordinates), 0) + self.assertGreater(len(TwistedEdwardsModel.coordinates), 0) diff --git a/test/ec/test_mult.py b/test/ec/test_mult.py new file mode 100644 index 0000000..021a6a3 --- /dev/null +++ b/test/ec/test_mult.py @@ -0,0 +1,22 @@ +from unittest import TestCase + +from pyecsca.ec.context import Context +from pyecsca.ec.curve import EllipticCurve +from pyecsca.ec.mod import Mod +from pyecsca.ec.model import ShortWeierstrassModel +from pyecsca.ec.mult import RTLMultiplier +from pyecsca.ec.point import Point + + +class ScalarMultiplierTests(TestCase): + + def test_rtl_simple(self): + p = 11 + coords = ShortWeierstrassModel.coordinates["projective"] + curve = EllipticCurve(ShortWeierstrassModel, coords, dict(a=5, b=7), + Point(coords, X=Mod(0, p), Y=Mod(0, p), Z=Mod(1, p))) + with Context() as ctx: + mult = RTLMultiplier(curve, coords.formulas["add-2002-bj"], + coords.formulas["dbl-2007-bl"], ctx=ctx) + result = mult.multiply(10, Point(coords, X=Mod(4, p), Y=Mod(3, p), Z=Mod(1, p))) + print(ctx.intermediates) |
