Skip to content

signer: add SwSigner::from_seed_with_network - #196

Merged
nitramiz merged 3 commits into
Blockstream:masterfrom
SatoshiPortal:master
Dec 3, 2026
Merged

nitramiz merged 3 commits into
Blockstream:masterfrom
SatoshiPortal:master

Conversation

@ethicnology

@ethicnology ethicnology commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

SwSigner::new_with_network only parses English mnemonics and always uses an empty passphrase. from_xprv_with_network keeps no seed, so the SLIP77 master blinding key and BIP85 are unavailable.

from_seed_with_network(seed: &[u8; 64], network) lets the caller compute the BIP39 seed itself (any wordlist, any passphrase) and keeps it, so seed(), SLIP77 and BIP85 work; mnemonic() returns None.

  • new_with_network now goes through the new constructor; the seed is stored and zeroized on drop.
  • derive_bip85_mnemonic() only requires the seed, which it already used.
  • No new error variant, no binding changes.

Two commits: the change, then its test (equivalence with the mnemonic signer and the BIP39 "TREZOR" passphrase vector).

cargo test -p lwk_signer, cargo clippy -p lwk_signer --all-targets -- -D warnings and cargo fmt --check pass on base 23bef2a7f.

@ethicnology

Copy link
Copy Markdown
Contributor Author

Updated to follow the contribution guidelines: from_seed_with_network now takes &[u8; 64], so no variant is added to NewError. The seed is kept in Zeroizing, and the tests are reduced to one table-driven test pinning the public contract (official BIP39 vectors, including a passphrase and a Japanese one, and equivalence with new_with_network). The goal is unchanged: let callers pass the BIP39 seed so they can support passphrases and mnemonics in every BIP39 wordlist.

@LeoComandini

Copy link
Copy Markdown
Contributor

please tidy up the commits and make the PR more minimal

`new_with_network` only parses English mnemonics and always uses an
empty passphrase, while `from_xprv_with_network` keeps no seed, so the
SLIP77 master blinding key and BIP85 are unavailable.

- Let the caller compute the BIP39 seed itself (any wordlist, any
  passphrase) and build a signer that keeps it.
- Store the seed (zeroized on drop) and route `new_with_network`
  through the new constructor.
- BIP85 only needs the seed, not the mnemonic.
- A signer built from the seed of a mnemonic matches the mnemonic
  signer (xpub, SLIP77 key, BIP85) and keeps the seed.
- The BIP39 vector with passphrase "TREZOR" pins the master key.
@ethicnology

Copy link
Copy Markdown
Contributor Author

Tidied up: two commits on current master (change + test), lwk_signer only.

Comment thread lwk_signer/CHANGELOG.md Resolved
@LeoComandini

Copy link
Copy Markdown
Contributor

lgtm with comment

Co-authored-by: LeoComandini <26792912+LeoComandini@users.noreply.github.com>
@LeoComandini

Copy link
Copy Markdown
Contributor

utACK f0275fb, code review

@nitramiz
nitramiz merged commit b080616 into Blockstream:master Dec 3, 2026
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.

3 participants