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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

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

let message = b"Hello!";
let _signature = keypair.sign(message);
let _public_key = keypair.public_key();
// Subxt signer compiles (though nothing much works on this particular nostd target...):
Copy link
Member

Choose a reason for hiding this comment

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

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

@@ -0,0 +1,51 @@
#[no_std]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#[no_std]
#![no_std]

Copy link
Member

Choose a reason for hiding this comment

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

which target are we testing this against WASM?

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

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