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

Fix and test sr25519 signing in nostd #1872

Merged
merged 8 commits into from
Jan 30, 2025
Merged

Fix and test sr25519 signing in nostd #1872

merged 8 commits into from
Jan 30, 2025

Conversation

jsdw
Copy link
Collaborator

@jsdw jsdw commented Nov 19, 2024

We had WASM tests for signing things, but no nostd tests. Adding them shows an issue signing via sr25519 (reported in #1871), for which adding the getrandom feature to schnorrkel seems to fix (pending CI passing here).

I had to remove some code in testing/no-std-tests because signing with sr25519 isn't supported on the thumbv7em-none-eabi target we run the nostd tests on. Previously it would compile OK because we didn't enable the getrandom feature, but I think if we were able to run it, we'd have seen a runtime error instead. Some other nostd targets probably handle this all OK (getrandom has a list here: https://docs.rs/getrandom/latest/getrandom/#unsupported-targets)

@jsdw jsdw requested a review from a team as a code owner November 19, 2024 11:18
@ordian
Copy link
Member

ordian commented Nov 19, 2024

Confirmed this working in wasm

@@ -66,7 +66,7 @@ hmac = { workspace = true }
zeroize = { workspace = true }
bip39 = { workspace = true }
bip32 = { workspace = true, features = ["alloc", "secp256k1"], optional = true }
schnorrkel = { workspace = true, optional = true }
schnorrkel = { workspace = true, optional = true, features = ["getrandom"] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps update the README in the signer crate that "sr25519 needs getrandom" which isn't supported on all platforms

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe so because we have web = ["getrandom/js"] to enable the relevant getrandom feature if compiling for the web.

(There's a separate conversation around whether this should be a thing of whether to make downstream consumers enable said feature flag instead, which is what getrandom suggests IIRC)

Copy link
Member

@niklasad1 niklasad1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool

@jsdw jsdw force-pushed the jsdw-signer-nostd-fix branch from 826410c to 8dd4d1b Compare January 29, 2025 16:22
@jsdw jsdw requested a review from a team as a code owner January 30, 2025 16:38
@jsdw jsdw merged commit 29bf00e into master Jan 30, 2025
13 checks passed
@jsdw jsdw deleted the jsdw-signer-nostd-fix branch January 30, 2025 17:14
@jsdw jsdw mentioned this pull request Feb 5, 2025
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.

4 participants