-
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
Open
jsdw
wants to merge
3
commits into
master
Choose a base branch
from
jsdw-signer-nostd-fix
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. which target are we testing this against WASM? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[package] | ||
name = "nostd-tests" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[dev-dependencies] | ||
wasm-bindgen-test = "0.3.24" | ||
tracing-wasm = "0.2.1" | ||
console_error_panic_hook = "0.1.7" | ||
|
||
# This crate is not a part of the workspace, because we want to | ||
# enable the "web" feature here but don't want it enabled as part | ||
# of workspace builds. Also disable the "subxt" feature here because | ||
# we want to ensure it works in isolation of that. | ||
subxt-signer = { path = "../../", default-features = false, features = [ | ||
"sr25519", | ||
"ecdsa", | ||
"unstable-eth", | ||
] } | ||
|
||
# this shouldn't be needed, it's in workspace.exclude, but still | ||
# I get the complaint unless I add it... | ||
[workspace] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,51 @@ | ||||||
#[no_std] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
use subxt_signer::{ecdsa, eth, sr25519}; | ||||||
|
||||||
// Run the tests by calling: | ||||||
// | ||||||
// ```text | ||||||
// cargo test | ||||||
// ``` | ||||||
// | ||||||
// These are independent of any other package to ensure that nothing | ||||||
// else enabled the same feature flag that subxt-signer needs to work ok | ||||||
// (subxt seems to, for instance). | ||||||
|
||||||
#[test] | ||||||
fn sr25519_signing_works() { | ||||||
let alice = sr25519::dev::alice(); | ||||||
|
||||||
// There's some non-determinism in the signing, so this ensures that | ||||||
// the rand stuff is configured properly to run ok in wasm. | ||||||
let signature = alice.sign(b"Hello there"); | ||||||
assert!(sr25519::verify( | ||||||
&signature, | ||||||
b"Hello there", | ||||||
&alice.public_key() | ||||||
)); | ||||||
} | ||||||
|
||||||
#[test] | ||||||
fn ecdsa_signing_works() { | ||||||
let alice = ecdsa::dev::alice(); | ||||||
|
||||||
// There's some non-determinism in the signing, so this ensures that | ||||||
// the rand stuff is configured properly to run ok in wasm. | ||||||
let signature = alice.sign(b"Hello there"); | ||||||
assert!(ecdsa::verify( | ||||||
&signature, | ||||||
b"Hello there", | ||||||
&alice.public_key() | ||||||
)); | ||||||
} | ||||||
|
||||||
#[test] | ||||||
fn eth_signing_works() { | ||||||
let alice = eth::dev::alith(); | ||||||
|
||||||
// There's some non-determinism in the signing, so this ensures that | ||||||
// the rand stuff is configured properly to run ok in wasm. | ||||||
let signature = alice.sign(b"Hello there"); | ||||||
assert!(eth::verify(&signature, b"Hello there", &alice.public_key())); | ||||||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/target | ||
Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?
https://github.com/paritytech/subxt/pull/1872/files#diff-8b295430b22e1459a5ea2f83b57cde4807b8380eac4528bfc639acb67733254cR84-R85