diff options
| author | J08nY | 2019-03-21 14:55:14 +0100 |
|---|---|---|
| committer | J08nY | 2019-03-21 14:55:14 +0100 |
| commit | 647dfbbec29d9a4cabf1ca132390c837870535fd (patch) | |
| tree | ef2c7148bbe6365916abc6b3e4c5f83ccdaa6c49 /test/ec/test_coordinates.py | |
| parent | 626102a3885d5c9bea88cafcb143fe626685f4b6 (diff) | |
| download | pyecsca-647dfbbec29d9a4cabf1ca132390c837870535fd.tar.gz pyecsca-647dfbbec29d9a4cabf1ca132390c837870535fd.tar.zst pyecsca-647dfbbec29d9a4cabf1ca132390c837870535fd.zip | |
Add conversion to and from affine points.
Diffstat (limited to 'test/ec/test_coordinates.py')
| -rw-r--r-- | test/ec/test_coordinates.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/ec/test_coordinates.py b/test/ec/test_coordinates.py new file mode 100644 index 0000000..7532308 --- /dev/null +++ b/test/ec/test_coordinates.py @@ -0,0 +1,25 @@ +from unittest import TestCase + +from pyecsca.ec.curve import EllipticCurve +from pyecsca.ec.mod import Mod +from pyecsca.ec.model import ShortWeierstrassModel +from pyecsca.ec.point import Point + + +class CoordinateTests(TestCase): + + def setUp(self): + self.p = 0xfffffffdffffffffffffffffffffffff + self.coords = ShortWeierstrassModel().coordinates["projective"] + self.secp128r1 = EllipticCurve(ShortWeierstrassModel(), self.coords, + dict(a=0xfffffffdfffffffffffffffffffffffc, + b=0xe87579c11079f43dd824993c2cee5ed3), + Point(self.coords, X=Mod(0, self.p), Y=Mod(1, self.p), + Z=Mod(0, self.p))) + + def test_affine(self): + pt = Point(self.coords, X=Mod(0x161ff7528b899b2d0c28607ca52c5b86, self.p), + Y=Mod(0xcf5ac8395bafeb13c02da292dded7a83, self.p), + Z=Mod(1, self.p)) + affine_Point = pt.to_affine() + assert pt.equals(affine_Point) |
