def testB163DH(self): n = 163 poly = (1<<163)^(1<<7)^(1<<6)^(1<<3)^1 A = 1 B = 2982236234343851336267446656627785008148015875581 GX = 5759917430716753942228907521556834309477856722486 GY = 1216722771297916786238928618659324865903148082417 G = [GX, GY, 1] a = random.randint(1, n) b = random.randint(1, n) bG = tp4.double_and_add(n, poly, A, B, G, b) aG = tp4.double_and_add(n, poly, A, B, G, a) abG = tp4.double_and_add(n, poly, A, B, bG, a) baG = tp4.double_and_add(n, poly, A, B, aG, b) self.assertEquals(abG, baG)
def testDoubleAndAdd(self): self.assertEquals(tp4.double_and_add(3, (1<<3)^(1<<1)^1, (1<<1), 1, [1, 4, 1], 1), [1, 4, 1]) self.assertEquals(tp4.double_and_add(3, (1<<3)^(1<<1)^1, (1<<1), 1, [1, 4, 1], 2), [0, 1, 1]) self.assertEquals(tp4.double_and_add(3, (1<<3)^(1<<1)^1, (1<<1), 1, [1, 4, 1], 3), [1, 5, 1]) self.assertEquals(tp4.double_and_add(3, (1<<3)^(1<<1)^1, (1<<1), 1, [1, 4, 1], 4)[2], 0) self.assertEquals(tp4.double_and_add(3, (1<<3)^(1<<1)^1, (1<<1), 1, [1, 4, 1], 5), [1, 4, 1])