Open riptl opened 5 years ago
That's already in progress by the core team as far as I know :)
@paberr already started to split up the code into seperate crates. The easy crates (like primitives, key-derivation and mnemonic) should already be compatible although the miss export annotations.
https://udoprog.github.io/rust/2018-02-19/porting-rust-to-wasm.html
Edit: add article
I did some experiments about 2 weeks ago and especially liked https://rustwasm.github.io/book/ as a resource.
As @Eligioo mentioned, I think the easy crates essentially only miss #[wasm_bindgen]
annotations. :)
Any progress on this? I would really like to use wasm version of public key generation https://github.com/nimiq/core-rs/tree/master/keys
@paberr can you share on how you manage to do it. I'm really no rust expert, i just need a wasm build for the public key generator
@valentinvieriu Nimiq Core JS does ed25519 in WASM: https://github.com/nimiq-network/core/blob/master/src/main/generic/consensus/base/primitive/PrivateKey.js
https://github.com/nimiq-network/core/tree/master/src/main/platform/browser
Thank you @terorie I know this is used there too. I'm looking now on how to extract only the Public key / Nimiq adress generator. (https://github.com/nimiq-network/core/blob/master/src/native/Makefile) At this moment the native project contains more. The way the rust project is structured, has the potential of being able to build those separate. I can see this be beneficial for wallet focused apps, that don't need mining or other functionality that is part of the whole package
@valentinvieriu That's true, the core-js wasm blob is a bit large. But I don't think it'll be any different with core-rs. I need a wasm build of the Nimiq core structures anyways, so I can probably help you with creating a small build: My plan is to rip out the consensus + networking and simplify the crypto package. We can work together on this if you want – my email is on my GitHub profile.
In the meantime, you can just get all the functionality from the official Nimiq lib.
<script type="text/javascript" src="https://cdn.nimiq.com/nimiq.js"></script>
(Nimiq.PublicKey
will be available in scripts)
@terorie that is great! I've added you on Discord.
Question or Feature Request
Nimiq is the web-based currency. Why not compile the Rust core to Wasm then?
Useful resources:
I'll do some research on what's required to compile to the new target.