def test_mul_windowed():
# Test multiplication by one and two
A = AffineToR1(Gx, Gy)
B = MUL_windowed(1, A)
test.testpt("mul-windowed-*1", B, A)
A2 = DBL(A)
B2 = MUL_windowed(2, A)
test.testpt("mul-windowed-*2", B2, A2)
# Test multiply over several iterations
test_mul("mul-windowed", MUL_windowed)
# Test fixed-based multiply
T = table_windowed(A)
B = MUL_windowed(1, A, table=T)
B2 = MUL_windowed(2, A, table=T)
test.testpt("mul-windowed-fixed-*1", B, A)
test.testpt("mul-windowed-fixed-*2", B2, A2)
failed = 0
for i in range(10):
m = getrandbits(256)
B1 = MUL_windowed(m, A, table=T)
B2 = MUL_windowed(m, A)
if B1 != B2:
failed += 1
if failed == 0:
print "[PASS] mul-windowed-fixed-rand"
else:
print "[FAIL] mul-windowed-fixed-rand"
评论列表
文章目录