|
|
|
|
|
by altern
3839 days ago
|
|
Somewhat off-topic I guess, but aren't PRNG, hashing and (symmetric) encryption in some sense all the same thing?
If you have some magic, keyed mixing function that permutes a block of data without leaking information about the key, it seems like you can implement any of the three operations. In oversimplified pseudo-code: def encrypt(data, key):
counter = 0
for block in data:
yield block ^ mix(counter, key)
counter += 1
def generate(key):
counter = 0
while True:
yield mix(counter, key)
counter += 1
def hash(data, key):
state = 0
for block in data:
state = block ^ mix(state, key)
return state
And similarly, if you have any one of those functions you can implement the rest. Xor with an unpredictable stream of numbers is a good encryption method, encrypting a string of zeroes should give you unpredictable random numbers and the hash can be used as the mix function when implementing the others, etc. |
|
More fundamentally it's keyed, and finding a way to make this work for an unkeyed hash is somewhat more complicated. But yes, I'm pretty sure that a secure stream cipher and a secure deterministic CSPRNG are basically the same thing.