Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Full WASM support (tracking PR) #358

Closed
wants to merge 6 commits into from

Conversation

gnunicorn
Copy link
Contributor

Switching on WASM support for the libp2p-package (rather than -code) to
track, which parts still need to be worked on to get full wasm-support going.
Add fixes to it as we go along.

@gnunicorn gnunicorn mentioned this pull request Jul 23, 2018
@tomaka
Copy link
Member

tomaka commented Jul 23, 2018

There's an open question about platform-specific features. Some elements cannot be used on some platforms, namely Unix sockets on anything else but Unix, and TCP/UDP/etc. on asm.js/wasm.

Therefore:

  • Should we disable these features at compile-time on platforms that don't support it,
  • Should we return an error at runtime instead?

Both options have their advantages and inconvenient.

@gnunicorn
Copy link
Contributor Author

gnunicorn commented Jul 24, 2018

I want to make the point, that I was able to make it compile with wasm32-unknown-unknown last night, including for libp2p-secio and with ring - however, I doubt this actually works, as most ring crypto will only be compiled to linux x86 ASM format at the moment...

@gnunicorn gnunicorn self-assigned this Jul 24, 2018
@gnunicorn
Copy link
Contributor Author

gnunicorn commented Jul 24, 2018

note to self. Parts of ring we actually use at the moment are all in secio. Namely we use:

  • ring::digest::{SHA256, SHA512, Context, digest, Algorithm},
  • ring::agreement::{Algorithm, agree_ephemeral, ECDH_P256, ECDH_P384, EphemeralPrivateKey, agreement}
  • ring::hmac::{SigningKey, VerificationKey, verify, sign, SigningContext}
  • ring::signature::{Ed25519KeyPair, RSAKeyPair, verify, ED25519, RSASigningState, RSA_PKCS1_2048_8192_SHA256, RSA_PKCS1_SHA256}
  • ring::rand::{SecureRandom, SystemRandom}

Though rust-crypto-wasm supports SHA-digest and ED25519, neither this crate nor the RustCrypto project have RSA or ECDH support yet. But there is a RSA crate in the works.

@tomaka
Copy link
Member

tomaka commented Jul 24, 2018

See also openethereum/parity-ethereum#7915

@gnunicorn
Copy link
Contributor Author

There is also the possibility to use WebCrypto in wasm, it supports all the crypto we require for secio. However webcrypto is async and returns promises, while currently ring is sync. But that sounds like a feasible thing to do.

@tomaka
Copy link
Member

tomaka commented Dec 27, 2018

cc-ing #806

@tomaka
Copy link
Member

tomaka commented Dec 27, 2018

The state of wasm after #806 is that the library compiles fine with cargo web build (so wasm32-unknown-unknown). Trying to use emscripten fails because i128 are not supported.

However trying to compile a binary fails because apparently the cc-rs crate erroneously compiles C files for Linux instead of WASM, and thus the linker yells at us.
We have one single piece of C code, which is the clear_on_drop crate (an indirect dependency).

@gnunicorn gnunicorn closed this Feb 11, 2019
@ghost ghost removed the in progress label Feb 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants