magic-wormhole/magic-wormhole.rs

rand >= 0.8 break WASM support

Sky-NiniKo opened this issue · 3 comments

Issue

I tried to make a web application using yew and magic-wormhole.rs and I got this error while trying to upload a file. Logs from the console (F12 -> Console):

panicked at 'Error: getrandom: this target is not supported', /home/niels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rand_core-0.5.1/src/os.rs:63:13

Stack:

getImports/imports.wbg.__wbg_new_abda76e883ba8a5f@http://127.0.0.1:8080/yew-app-21e2076cdb23f7ca.js:402:21
console_error_panic_hook::Error::new::h0d0fabec9486fdef@http://127.0.0.1:8080/yew-app-21e2076cdb23f7ca_bg.wasm:wasm-function[14162]:0x4f80b7
console_error_panic_hook::hook_impl::ha02f1ef761b122b6@http://127.0.0.1:8080/yew-app-21e2076cdb23f7ca_bg.wasm:wasm-function[2713]:0x34b3ba
console_error_panic_hook::hook::h77afd9ec18c650a2@http://127.0.0.1:8080/yew-app-21e2076cdb23f7ca_bg.wasm:wasm-function[16028]:0x511213
core::ops::function::Fn::call::ha887bd5a651c1c2d@http://127.0.0.1:8080/yew-app-21e2076cdb23f7ca_bg.wasm:wasm-function[13452]:0x4ed1a2
std::panicking::rust_panic_with_hook::ha2f7b95083ec77f3@http://127.0.0.1:8080/yew-app-21e2076cdb23f7ca_bg.wasm:wasm-function[5452]:0x40c00c
std::panicking::begin_panic_handler::{{closure}}::h47a7e7226e82fb78@http://127.0.0.1:8080/yew-app-21e2076cdb23f7ca_bg.wasm:wasm-function[6812]:0x449861
std::sys_common::backtrace::__rust_end_short_backtrace::h114c7ac12e473e06@http://127.0.0.1:8080/yew-app-21e2076cdb23f7ca_bg.wasm:wasm-function[18384]:0x525920
rust_begin_unwind@http://127.0.0.1:8080/yew-app-21e2076cdb23f7ca_bg.wasm:wasm-function[11258]:0x4c5140
core::panicking::panic_fmt::hae2225a32154cb21@http://127.0.0.1:8080/yew-app-21e2076cdb23f7ca_bg.wasm:wasm-function[15335]:0x5083f4
<rand_core::os::OsRng as rand_core::RngCore>::fill_bytes::he1c5c8da3ce8e69d@http://127.0.0.1:8080/yew-app-21e2076cdb23f7ca_bg.wasm:wasm-function[3098]:0x36edce
curve25519_dalek::scalar::Scalar::random::h3a482c24f807c76f@http://127.0.0.1:8080/yew-app-21e2076cdb23f7ca_bg.wasm:wasm-function[4271]:0x3c77d7
<spake2::ed25519::Ed25519Group as spake2::group::Group>::random_scalar::h5074f6af435f4cfa@http://127.0.0.1:8080/yew-app-21e2076cdb23f7ca_bg.wasm:wasm-function[15136]:0x5058bc
spake2::Spake2<G>::start_symmetric_with_rng::h9310dbd0fe484fee@http://127.0.0.1:8080/yew-app-21e2076cdb23f7ca_bg.wasm:wasm-function[3682]:0x39df73
spake2::Spake2<G>::start_symmetric::h4a14f98f0ef1f101@http://127.0.0.1:8080/yew
...

I think I understood that curve25519_dalek wants to generate a random number but it can't because rand doesn't support wasm32-unknown-unknown:

How to fix

Simply downgrade the rand crate to 0.7.

Originally posted by @Sky-NiniKo in #2 (comment)

We can't downgrade rand, because xsalsa20poly1305 depends on it >= 0.8. Do you know of any other fixes or workarounds?

Do you know of any other fixes or workarounds?

Unfortunately, no.

At the moment, I don't need this fix and I don't know anyone who does.
So I think it's not very urgent and this issue can remain dormant for the time being.

See How to fix in the first post.