Skip to content

Add optional wasm32_unknown_unknown_getrandom feature - #1486

Closed
ghost wants to merge 1 commit into
mainfrom
unknown repository
Closed

ghost wants to merge 1 commit into
mainfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Apr 14, 2022

Copy link
Copy Markdown

(Feel free to merge as-is, but I'm happy to work on other solutions too. This is intended mostly as a starting point for discussing how this could be solved.)

We'd like to compile ring to a custom wasm32-unknown-unknown target. I see that there is already a wasm32_unknown_unknown_js target on the main branch, but our target environment doesn't have a JavaScript interface.

Some of the solutions we considered:

  • Move the ring::rand module behind an optional (enabled by default) rand feature. This would work for us because the functions we call don't need RNG. However, it is not a very general solution, and adding #[cfg(rand)] everywhere would probably be undesirable in a cryptographic library.
  • Optionally allow using getrandom (this PR). getrandom has a custom feature that allows users to register their own getrandom implementation to be used on targets without a default implementation. We have a few other dependencies that depend on getrandom, so we already do this.
  • Borrow getrandom's register_custom_getrandom macro and add it to this crate.
  • Something else?

I used the getrandom approach (behind an opt-in feature) here because I thought it was the simplest solution, but I would love to hear what everyone thinks. Thanks a lot for this crate!

@ghost ghost closed this by deleting the head repository Dec 10, 2022
This pull request was closed.
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.

0 participants