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

The first two times of call crypto.getRandomValues returns 0 #202

Open
jlucaso1 opened this issue Sep 28, 2024 · 1 comment
Open

The first two times of call crypto.getRandomValues returns 0 #202

jlucaso1 opened this issue Sep 28, 2024 · 1 comment

Comments

@jlucaso1
Copy link

This behavior always occurs

Welcome to Porffor (0.47.3) running on Node (22.9.0)
using opt -O1, parser acorn, valtype f64

> crypto.getRandomValues(new Uint8Array(1));
Uint8Array(1) [ 0 ] 
> crypto.getRandomValues(new Uint8Array(1));
Uint8Array(1) [ 0 ] 
> crypto.getRandomValues(new Uint8Array(1));
Uint8Array(1) [ 229 ] 
> crypto.getRandomValues(new Uint8Array(1));
Uint8Array(1) [ 252 ] 
>
@Rob23oba
Copy link

Yeah, I've noticed that one before. I believe that is because a 64-bit random number generator is used but only 32-bit seeds. Another problem is that after compilation, the series of random numbers is deterministic (this behavior is a bit harder to observe due to the lack of run-wasm)

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