Skip to content
This repository has been archived by the owner on Feb 24, 2023. It is now read-only.

WebAssembly build target #9

Open
riptl opened this issue Feb 9, 2019 · 8 comments
Open

WebAssembly build target #9

riptl opened this issue Feb 9, 2019 · 8 comments
Labels
enhancement New feature or request target:web-assembly WebAssembly Target

Comments

@riptl
Copy link
Contributor

riptl commented Feb 9, 2019

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.

@curdbecker
Copy link
Contributor

That's already in progress by the core team as far as I know :)

@Eligioo
Copy link
Member

Eligioo commented Feb 9, 2019

@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

@paberr
Copy link
Member

paberr commented Feb 9, 2019

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. :)

@paberr paberr added target:web-assembly WebAssembly Target enhancement New feature or request labels Feb 9, 2019
@valentinvieriu
Copy link

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

@riptl
Copy link
Contributor Author

riptl commented Apr 14, 2019

@valentinvieriu
Copy link

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

@riptl
Copy link
Contributor Author

riptl commented Apr 14, 2019

@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)

@valentinvieriu
Copy link

@terorie that is great! I've added you on Discord.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request target:web-assembly WebAssembly Target
Projects
None yet
Development

No branches or pull requests

5 participants