def test_core():
TEST_LOOPS = 1000
# Test doubling
A = (Gx, Gy, GFp2.one)
for i in range(TEST_LOOPS):
A = DBL(A)[:3]
doubleP = ((0x2C3FD8822C82270FC9099C54855859D6, 0x4DA5B9E83AA7A1B2A7B3F6E2043E8E68),
(0x2001EB3A576883963EE089F0EB49AA14, 0x0FFDB0D761421F501FEE5617A7E954CD))
test.testpt("double", A, doubleP)
# Test that the neutral element is neutral
G = AffineToR1(Gx, Gy)
O = AffineToR1(Ox, Oy)
PP = ADD(G, R1toR2(O))
test.testpt("neutral-r", PP, G)
PP = ADD(O, R1toR2(G))
test.testpt("neutral-l", PP, G)
# Test point doubling by addition
P = G
for i in range(TEST_LOOPS):
Q = R1toR2(P)
P = ADD(P, Q)
test.testpt("double-add", P, doubleP)
# Test repeated addition of the same point
P = G
Q = R1toR2(P)
P = DBL(P[:3])
for i in range(TEST_LOOPS):
P = ADD(P, Q)
P1000 = ((0x3E243958590C4D906480B1EF0A151DB0, 0x5327AF7D84238CD0AA270F644A65D473),
(0x3EF69A49CB7E02375E06003D73C43EB1, 0x293EB1E26DD23B4E4E752648AC2EF0AB))
test.testpt("addition", P, P1000)
评论列表
文章目录