News for hackers. Stuff that matters.
Re:Creating randomness Without Math.random by Someone on Sunday July 12, 2020 @06:24PM (#23815270)
“Each Math.random function created for distinct realms must produce a distinct sequence of values from successive calls.”

Nitpick: it would surprise me if any implementation implemented this requirement to the letter.

I think neither of the claims (FTA) “PRNGs are deterministic” and “A PRNG eventually repeats its sequence” are strictly required (for the first you can’t seed Javascript’s Math.Random, so there is no need to be able to regenerate a sequence; for the second, one could generate good pseudo random sequences that never repeat), but the implementations I’m aware of all have those properties, and use fixed-size state.

Given that, the number of PRNGs whose period is at most P is finite. So, one could exhaust that set by creating realms and random number sequences in each of them in a loop (a looooong loop)

The only ways to avoid generating a copy would be to gradually move to generators with more state or to crash.

Re:Creating randomness Without Math.random by bmm6o on Sunday July 12, 2020 @08:29PM (#23815915)
Any prng with a fixed (finite) amount of state will eventually return to a state it has already been in, if run long enough. Determinism then dictates that it will begin repeating outputs. It's odd as a requirement, but it's a natural property of a prng.
Re:Creating randomness Without Math.random by xsmasher on Monday July 13, 2020 @04:46PM (#23825385)
> “Each Math.random function created for distinct realms must produce a distinct sequence of values from successive calls.”

If this were not true, it would have security implications.

Thought experiment: If there was a single state then a web page could pull a bunch of numbers, use that data to derive the seed AND the next number that will be pulled without pulling it.

Then the predictor page can STOP pulling numbers when they know the next number is an auspicious one. The predictor page has now successfully "rigged" the dice roll for another page that shares the same state.

Re:Creating randomness Without Math.random by Someone on Monday July 13, 2020 @06:59PM (#23826614)
I know that an am not disputing it. My claim is that most, if not all, implementations do not satisfy that requirement.

Also, that requirement isn’t sufficient to prevent such attacks, by a long stretch.

An implementation that has only one sequence of random numbers r1, r2, r3, r4…, but drops a single item of the sequence for each subsequent realm (the second instance returns r2, r3, r4…, the third one r3, r4…, etc.) satisfies the requirement, and the individual sequences are as perfectly random as the original one), but still is vulnerable to attacks.

And it can be worse: an implementation that generates a unique r0 for each realm (could even be an easily predictable value) and returns r0, r1, r2, r3, r4…, with r1 and subsequent identical for all instances also satisfies the requirement.

Re:Creating randomness Without Math.random by ZiiS on Monday July 13, 2020 @03:46AM (#23818174)
Sounds to me the standard was trying to say "diffrent domains must use diffrent seeds." without requiring you to use seeds I.e. genuine phisicaly random sources should comply. I don't feel you need to know anything about other domains to implement this requirment.
Re:Creating randomness Without Math.random by 082349872349872 on Monday July 13, 2020 @03:30AM (#23818053)
TIL Hedy Lamarr's frequency-hopping patent https://patents.google.com/patent/US2292387 used a OTP instead of a PRNG.
Re:Creating randomness Without Math.random by lern_too_spel on Sunday July 12, 2020 @07:43PM (#23815697)
Both of the claims apply to PRNGs. Math.random isn't required to be a PRNG.
Re:Creating randomness Without Math.random by dmurray on Sunday July 12, 2020 @08:24PM (#23815896)
> Both of the claims apply to PRNGs.

Why? A reasonable interpretation of "pseudo-random number generator" is a generator that yields a sequence of numbers that looks pretty random, but isn't. Why require it to be repeating?

For an example of a PRNG that doesn't repeat (infinite period), take your favourite periodic PRNG and XOR it with bits from pi or e or the Champernowne constant.

I do think the definition implies it's deterministic, though. Things that are not deterministic are random, so they are not pseudorandom. The fact that you can't seed the state of the Javascript PRNG doesn't mean that it's not deterministic: what matters is that once you know its complete state you can predict its output.

Re:Creating randomness Without Math.random by comex on Sunday July 12, 2020 @10:11PM (#23816520)
Technically, as long as you only have a finite amount of memory, there is only a finite number of states the computer can be in, so the output must repeat eventually. Though "eventually" can be long after the heat death of the universe.
Re:Creating randomness Without Math.random by dmurray on Monday July 13, 2020 @03:33AM (#23818085)
We normally ignore that technicality. Like when we say adding two numbers is constant-time, or that a computer can simulate a Turing machine.
Re:Creating randomness Without Math.random by comex on Monday July 13, 2020 @04:50AM (#23818614)
True, but in this case, xorshift128+ already maximizes its period by going through every possible state once before repeating. It only has 128 bits of state, but still, the difference between "128 bits" and "all of RAM" is only a constant factor. :) And of course, a period of 2^128 is already more than high enough that it will never repeat in practice.
Re:Creating randomness Without Math.random by lern_too_spel on Sunday July 12, 2020 @11:45PM (#23816962)
I was simply clarifying the author's claims, which did not match what GGP said they were.

It turns out both of the author's claims are correct. Sibling comment shows why the repetition claim is correct, and you showed why the deterministic claim is correct (by definition).