def getInEqOutFlush(m): i = 0 flushes = [] while i < 10000: out, m = dummy.sendMessage(m) i += 1 if out == i: return i print("Cant find in=out for " + str(m)) return 1
def evaluateStateReachable(ts, states, maxruns=1000): "Run a mixnet for a long time to see if a buffer-state is possible" # Create the mixnet m = (len(ts), ts, [0] * len(ts)) c = 0 for i in range(0, maxruns): out, m = dummy.sendMessage(m) c += 1 if m[2] == states: return True, c return False
def guessLCM(m, attempts=100): "Guess lcm of a given mixnet" g = -1 for i in range(1, attempts): out, m = dummy.sendMessage(m) if out > 0 : # print("Output on", i,":", out) if (g < 0 or out < g): g = out # print("New guess:", out) if(g >= 0): print("My guess is " + str(g) + " is (divisible by) tn") else : print("I have no guess for t0") return g
def guessT0(m, attempts=100): "Guess t0 of a given mixnet" g = -1 i0 = 0 for i in range(1, attempts): out, m = dummy.sendMessage(m) if out > 0 : print("Output on", i,":", out) if (g < 0 or (i - i0) < g): g = (i - i0) print("New guess:", g) i0 = i if(g >= 0): print("My guess is " + str(g) + " is (divisible by) t0") else : print("I have no guess for t0")