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

ECDSA Support in signer #1064

Merged
merged 19 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ jobs:
# Subxt-signer has the "subxt" features enabled in the "check all targets" test. Run it on its own to
# check it without. We can't enable subxt or web features here, so no cargo hack.
- name: Cargo check subxt-signer
run: cargo check -p subxt-signer
run: |
cargo check -p subxt-signer
cargo check -p subxt-signer --no-default-features --features sr25519
cargo check -p subxt-signer --no-default-features --features ecdsa

# We can't enable web features here, so no cargo hack.
- name: Cargo check subxt-lightclient
Expand Down
25 changes: 22 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ bip39 = "2.0.0"
hmac = "0.12.1"
pbkdf2 = { version = "0.12.2", default-features = false }
schnorrkel = "0.10.2"
secp256k1 = "0.27.0"
secrecy = "0.8.0"
sha2 = "0.10.6"
zeroize = { version = "1", default-features = false }
zeroize = { version = "1", default-features = false }
12 changes: 10 additions & 2 deletions signer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ description = "Sign extrinsics to be submitted by Subxt"
keywords = ["parity", "subxt", "extrinsic", "signer"]

[features]
default = []
default = ["sr25519", "ecdsa"]

# Pick the signer implementation(s) you need by enabling the
# corresponding features. Note: I had more difficulties getting
# ecdsa compiling to WASM on my mac; following this comment helped:
# https://github.com/rust-bitcoin/rust-bitcoin/issues/930#issuecomment-1215538699
sr25519 = ["schnorrkel"]
ecdsa = ["secp256k1"]

# Make the keypair algorithms here compatible with Subxt's Signer trait,
# so that they can be used to sign transactions for compatible chains.
Expand All @@ -37,7 +44,8 @@ sha2 = { workspace = true }
hmac = { workspace = true }
zeroize = { workspace = true }
bip39 = { workspace = true }
schnorrkel = { workspace = true }
schnorrkel = { workspace = true, optional = true }
secp256k1 = { workspace = true, features = ["recovery", "global-context"], optional = true }
secrecy = { workspace = true }

# We only pull this in to enable the JS flag for schnorrkel to use.
Expand Down
1 change: 1 addition & 0 deletions signer/src/crypto/seed_from_entropy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use zeroize::Zeroize;
/// This is taken from `substrate-bip39` so that we can keep dependencies in line, and
/// is the same logic that sp-core uses to go from mnemonic entropy to seed. Returns
/// `None` if invalid length.
#[allow(dead_code)]
pub fn seed_from_entropy(entropy: &[u8], password: &str) -> Option<[u8; 64]> {
if entropy.len() < 16 || entropy.len() > 32 || entropy.len() % 4 != 0 {
return None;
Expand Down
Loading