-
Notifications
You must be signed in to change notification settings - Fork 254
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
base: master
Are you sure you want to change the base?
Conversation
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...): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a link to https://docs.rs/getrandom/latest/getrandom/#supported-targets here
@@ -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"] } |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we remove the getrandom feature flag now below?
@@ -0,0 +1,51 @@ | |||
#[no_std] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[no_std] | |
#![no_std] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool
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 thethumbv7em-none-eabi
target we run the nostd tests on. Previously it would compile OK because we didn't enable thegetrandom
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)