def test(): """ randomly generate a couple prng seeds, then test syncing up with them """ seeds = [random.randint(1,6257-1) for i in range(5)] prngs = [prng(seed=i) for i in seeds] cur_states = [get_state(p) for p in prngs] good_states = [p.state for p in prngs] print("good states: ",good_states) print("recovered states: ",cur_states) if cur_states == good_states: return True else: return False
def test(): """ randomly generate a couple prng seeds, then test syncing up with them """ seeds = [random.randint(1, 6257 - 1) for i in range(5)] prngs = [prng(seed=i) for i in seeds] cur_states = [get_state(p) for p in prngs] good_states = [p.state for p in prngs] print("good states: ", good_states) print("recovered states: ", cur_states) if cur_states == good_states: return True else: return False
def __init__(self, out): """ given the initial output, init out guesser so we can guess all remaining outputs """ prime=331337 F = FiniteField(prime,1) C = EllipticCurve(a=F(1),b=F(1)) e = F(3) #backdoor! we'd have to pre-compute this val = out*out*out + C.a * out + C.b print(time.time(),":","finding points...") points = [Point(C,F(out),F(y)) for y in tonelli_shanks(val.n,prime)] #print("points: ",points) print(time.time(),":","recovering states...") states = [(e.n*T).x.n for T in points] #as both candidates are additive inverses of #one another, they have the same x coordinates print(time.time(),":","making prng") self.p = prng(seed=states[0])
def __init__(self, out): """ given the initial output, init out guesser so we can guess all remaining outputs """ prime = 331337 F = FiniteField(prime, 1) C = EllipticCurve(a=F(1), b=F(1)) e = F(3) #backdoor! we'd have to pre-compute this val = out * out * out + C.a * out + C.b print(time.time(), ":", "finding points...") points = [Point(C, F(out), F(y)) for y in tonelli_shanks(val.n, prime)] #print("points: ",points) print(time.time(), ":", "recovering states...") states = [(e.n * T).x.n for T in points] #as both candidates are additive inverses of #one another, they have the same x coordinates print(time.time(), ":", "making prng") self.p = prng(seed=states[0])