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

WASM support for ruma-signatures #22

Closed
stoically opened this issue Jun 3, 2020 · 14 comments
Closed

WASM support for ruma-signatures #22

stoically opened this issue Jun 3, 2020 · 14 comments
Assignees

Comments

@stoically
Copy link
Contributor

Currently rings Ed25519 doesn't work for the WebAssembly target (briansmith/ring#918), hence ruma-signature doesn't work on WASM either.

@stoically
Copy link
Contributor Author

@jplatte
Copy link
Member

jplatte commented Jun 4, 2020

If ed25519-dalek can fully replace ring for our uses, I think I'd be in favor of switching and AFAIK it's also written by trustworthy people.

I don't really know what our current uses of ring even are though and I don't have much time to understand this crate in more detail. We really need an owner for this crate who is not me...

@stoically
Copy link
Contributor Author

Looks like it could fully replace ring, would need some adjustments in the tests. ed25519-dalek seems to be geared for this specific use case, which is nice I think, but ring might be the better candidate if one day different algorithms might be needed. I'll look into putting it behind a feature.

@jplatte
Copy link
Member

jplatte commented Jun 4, 2020

While we could support both behind feature flags, I'm not sure what that achieves. Are you interested in maintaining ruma-signatures? If not, maybe the best path forward for now is to have your own fork using ed25519-dalek and rely on that. There's no dependencies on ruma-signatures in any of the other ruma crates, so no compatibility concerns.

@jplatte jplatte transferred this issue from another repository Jun 5, 2020
@iinuwa iinuwa changed the title WASM support WASM support for ruma-signatures Aug 11, 2020
@iinuwa
Copy link
Member

iinuwa commented Aug 11, 2020

changed the title on this to be specific to the crate now that it's been moved to the monorepo.

@jplatte jplatte self-assigned this Oct 9, 2020
@jplatte
Copy link
Member

jplatte commented Oct 9, 2020

ed25519-dalek 1.0 is out, I'll look into switching away from ring

I'd welcome a PR switching from ring to ed25519-dalek.

@jplatte jplatte removed their assignment Jan 2, 2021
@jplatte jplatte removed the feature label Apr 8, 2021
@ShadowJonathan
Copy link
Member

/command @iinuwa assign to @ShadowJonathan

@ShadowJonathan
Copy link
Member

ruma-signatures has two spots which uses ring for other uses;

use ring::digest::{digest, SHA256};

let document = RingEd25519KeyPair::generate_pkcs8(&ring::rand::SystemRandom::new())

These would also need replacement candidates.

@ShadowJonathan
Copy link
Member

ShadowJonathan commented May 10, 2021

Suggestions from @poljar are;

  • Use rand with getrandom (which "works everywhere")

  • Use sha2 crate, which is pure rust.

@jplatte
Copy link
Member

jplatte commented May 10, 2021

The ed25519-dalek crate uses rand's traits in its interface so we should use that for keypair generation (probably fine to use thread_rng, we could then later possibly allow a custom RNG).

@ShadowJonathan
Copy link
Member

I opened this issue because it doesn't seem ed25519-dalek supports PKCS8 to support generating/creating Ed25519KeyPair from them.

@ShadowJonathan
Copy link
Member

Going deeper down the rabbit hole, I discovered that the pkcs8 crate doesn't support PKCS8 v2 documents (as described here), ring::signature::Ed25519KeyPair::as_ref() produces PKCS8 v2 documents, so I made some noise to have it be supported (possibly): RustCrypto/utils#419

@ShadowJonathan
Copy link
Member

@stoically now that #589 has merged into next, could you verify that compiling to WASM works?

@jplatte
Copy link
Member

jplatte commented Aug 30, 2021

Closing under the assumption that this now works, if it doesn't please open an issue with details on how it fails.

@jplatte jplatte closed this as completed Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants