Using sources of randomness in WASM #738
piotr-roslaniec
started this conversation in
Show and tell
Replies: 1 comment 5 replies
-
In my experience In which case I used this workaround: const getRandomValues = crypto.getRandomValues;
crypto.getRandomValues = function (buffer) {
const array = new Uint8Array(buffer);
const value = getRandomValues.call(crypto, array);
buffer.set(value);
return buffer;
}; It can be fiddly to get the https://github.com/LavaMoat/tss-snap/blob/main/INSTALL.md#getrandom |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello. I've been working on some snaps that depend on Rust libraries, specifically ones using random number generators. Despite using known techniques I found it challenging to make them work in snaps.
I've come up with a workaround - In short, it relies on manually accessing the source of randomness from inside the snap and passing it into Rust libraries as an RNG seed. You can find a complete description of the problem and a workaround here.
I decided to share this in case there exists a more elegant solution, or in case someone stumbles upon a similar issue.
Beta Was this translation helpful? Give feedback.
All reactions