Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow omitting the seed to get a "random" start? #32

Open
tabatkins opened this issue Mar 5, 2025 · 1 comment
Open

Allow omitting the seed to get a "random" start? #32

tabatkins opened this issue Mar 5, 2025 · 1 comment

Comments

@tabatkins
Copy link
Collaborator

tabatkins commented Mar 5, 2025

It was pointed out in TG3 review that being seeded and being "not a shitty race-to-the-bottom fast algorithm" are somewhat orthogonal. That is, people might want the qualities of "decent random generator" without necessarily wanting predictable seeded sequences.

Today, they'd have to gather some entropy for themselves, like using a timestamp and some user-specific entropy maybe? It seems tricky. UAs already generate some starting seed for Math.random() that is presumably at least decent for distinguishing users/frames/etc.

So, suggestion is that we allow the seed to be omitted, indicating that the UA should generate a random seed for you, with some guarantee that distinct invocations generate unrelated seeds.

Edit: one concern from TG3 is that their secure subset currently poisons Math.random() (replacing it with a throwing function) to prevent cross-realm communication via sequence observation of Math.random()'s bad RNG. They'd probably have to do the same poisoning to this signature of the constructor, replacing the constructor with a version that throws on an omitted seed and otherwise delegates to the normal constructor. It's a little annoying to do so, but not unreasonable.

@bakkot
Copy link

bakkot commented Mar 5, 2025

I don't really share the concerns about Math.random but I think there's a lot of use cases for a PRNG with serializable state where you don't necessarily care about using a particular seed, so that sounds good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants