Пример #1
0
def testLcmOfInOut(attempts=10000):
	for i in range(100):
		m = dummy.randomMixnet(3)
		g = lcmOfInOut(m)
		e = lcmn(m[1])
		e2 = e % g
		assert e2 == 0 or (g % e == 0), "Guess lcm does not work for " + str(m) + ", gives " + str(g) + ", expected " + str(e)
Пример #2
0
def guessLargestWithTwoFlushes(attempts=10000):
	for i in range(attempts):
		m = dummy.randomMixnet(3)
		f = dummy.getNFlushes(m, 2)
		l = lcmn(m[1])
		g = gcd(f[0][0], f[1][0])
		ok = f[0][1] in m[1] or l in m[1]
		assert g in m[1] or ok, "Guessed wrong, m: " + str(m) + ", guessed " + str(g) + ", expected x in " + str(m[1]) + " | " + str(f) + " | " + str(l)
Пример #3
0
def floorAss(attempts=10000):
	for i in range(attempts):
		m = dummy.randomMixnet(3)
		f = dummy.getNFlushes(m, 10)
		t123 = m[1][0] * m[1][1] * m[1][2]
		for j in f:
			x0 = j[0]
			x3 = j[1]
			g = math.floor(x0/t123) * t123
			assert g == x3, "Guessed wrong, m: " + str(m) + ", guessed " + str(g) + ", expected " + str(x3) 
Пример #4
0
def findInEqualsOut(attempts=10000):
	for i in range(attempts):
		m = dummy.randomMixnet(3)
		f = getInEqOutFlush(m)
		assert f > 0, "Naha"
Пример #5
0
def testGuessTn(attempts=10000):
	for i in range(100):
		m = dummy.randomMixnet(3)
		g = guessTn(m)
		assert g == m[1][2], "Guess tn does not work for " + str(m) + ", gives " + str(g)