def test(): """ UTILITY/TEST FUNCTION """ print("randomly generating/recovering 5 prngs") seeds = [random.randint(1, 104729) for i in range(0, 5)] print("seeds: ", seeds) prngs = [prng(seed=s) for s in seeds] curstates = [get_state(p) for p in prngs] print("recovered states: ", curstates) synced_prngs = [prng(seed=s) for s in curstates] good_output = [p.get_num() for p in prngs] synced_output = [p.get_num() for p in synced_prngs] print("good output: ", good_output) print("test output: ", synced_output) if good_output == synced_output: return True else: return False
def test(): """ UTILITY/TEST FUNCTION """ print("randomly generating/recovering 5 prngs") seeds = [random.randint(1,104729) for i in range(0,5)] print("seeds: ",seeds) prngs = [prng(seed=s) for s in seeds] curstates = [get_state(p) for p in prngs] print("recovered states: ",curstates) synced_prngs = [prng(seed=s) for s in curstates] good_output = [p.get_num() for p in prngs] synced_output = [p.get_num() for p in synced_prngs] print("good output: ",good_output) print("test output: ",synced_output) if good_output == synced_output: return True else: return False
def __init__(self, output): """ given the initial output, init out guesser so we can guess all remaining outputs output: some output from the prng_1 prng """ F = FiniteField(104729,1) #use the same finite field at the prng P = F(7) #same parameters Q = F(2) PQ_inverse = (P*Q).inverse() #the trick! we have multiplicative inverses! T = F(output) oldstate = T*PQ_inverse curstate = oldstate*P*P self.p = prng(seed=curstate.n)
def __init__(self, output): """ given the initial output, init out guesser so we can guess all remaining outputs output: some output from the prng_1 prng """ F = FiniteField(104729, 1) #use the same finite field at the prng P = F(7) #same parameters Q = F(2) PQ_inverse = ( P * Q).inverse() #the trick! we have multiplicative inverses! T = F(output) oldstate = T * PQ_inverse curstate = oldstate * P * P self.p = prng(seed=curstate.n)