static inline void ed25519_randombytes(unsigned char *x,unsigned long long xlen)
{
int i;
if (ed25519_random_fd == -1) {
for (;;) {
ed25519_random_fd = open("/dev/urandom",O_RDONLY);
if (ed25519_random_fd != -1) break;
sleep(1);
}
}
while (xlen > 0) {
if (xlen < 1048576) i = xlen; else i = 1048576;
i = read(ed25519_random_fd,x,i);
if (i < 1) {
sleep(1);
continue;
}
x += i;
xlen -= i;
}
}
As you can see it uses this fd here. I am really interested how it works when compiled to wasm because this is a sys call ed25519_random_fd = open(“/dev/urandom”,O_RDONLY);
when I compiled it using emcc and executed in inside node or browser, it works, it produces random bytes. But not really sure how.
New contributor
Milos Mirkovic is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.