Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- from unittest import TestCase
- from field import FieldElement
- from point import Point
- class ECCTest(TestCase):
- def test_on_curve(self):
- prime = 223
- valid_points = ((192, 105), (17, 56), (1, 193))
- invalid_points = ((200, 119), (42, 99))
- # TODO 1 - Implement a check if the point is on the curve y^2=x^3-7 over F_223:
- def test_add(self):
- # tests the following additions on curve y^2=x^3-7 over F_223:
- # (192,105) + (17,56)
- # (47,71) + (117,141)
- # (143,98) + (76,66)
- prime = 223
- additions = (
- # (x1, y1, x2, y2, x3, y3)
- (192, 105, 17, 56, 170, 142),
- (47, 71, 117, 141, 60, 139),
- (143, 98, 76, 66, 47, 71),
- )
- # TODO 2 - Implement add on curve y^2=x^3-7 over F_223 with this numbers.
- for x1r, y1r, x2r, y2r, x3r, y3r in additions:
- def test_rmul(self):
- # tests the following scalar multiplications
- # 2*(192,105)
- # 2*(143,98)
- # 2*(47,71)
- # 4*(47,71)
- # 8*(47,71)
- # 21*(47,71)
- prime = 223
- multiplications = (
- # (coefficient, x1, y1, x2, y2)
- (2, 192, 105, 49, 71),
- (2, 143, 98, 64, 168),
- (2, 47, 71, 36, 111),
- (4, 47, 71, 194, 51),
- (8, 47, 71, 116, 55),
- (21, 47, 71, None, None),
- )
- # iterate over the multiplications
- for s, x1_raw, y1_raw, x2_raw, y2_raw in multiplications:
- # TODO 3 - Implement rmul on curve y^2=x^3-7 over F_223 with this numbers.
Advertisement
Add Comment
Please, Sign In to add comment