Skip to content

signer: take a fixed-size seed in from_seed - #2

Merged
ethicnology merged 2 commits into
SatoshiPortal:masterfrom
ethicnology-agent:fix/signer-from-seed-array
Nov 5, 2026
Merged

ethicnology merged 2 commits into
SatoshiPortal:masterfrom
ethicnology-agent:fix/signer-from-seed-array

Conversation

@ethicnology-agent

Copy link
Copy Markdown

Summary

Follow-up to #1, aligning SwSigner::from_seed_with_network with the LWK contribution guidelines before it is reviewed upstream in Blockstream#196 (opened from this repository's master, so it picks up this change once merged).

The goal is unchanged: allow building a software signer from a BIP39 seed, so that callers can support BIP39 passphrases and mnemonics in every BIP39 wordlist. Today new_with_network forces an empty passphrase (to_seed("")) and only parses the wordlists compiled into the bip39 crate; callers that compute the seed as specified by BIP39 (PBKDF2-HMAC-SHA512 over the NFKD sentence, salt "mnemonic" + passphrase) can pass it directly.

Changes

  • from_seed_with_network(seed: &[u8; 64], network): a BIP39 seed is always 64 bytes, so the type enforces the length and the InvalidSeedLength variant added to NewError in signer: add SwSigner::from_seed_with_network #1 is removed. Adding a variant to a non-#[non_exhaustive] public enum is a breaking change; with this follow-up the feature is purely additive.
  • The seed is kept in Zeroizing, which also wipes clones; the manual wiping code is gone.
  • Doc comments state the purpose (passphrases and every BIP39 wordlist) and no longer refer to "the signer's mnemonic".
  • Tests follow the repository guideline of fewer, contract-pinning tests: one table-driven test checks the root keys of three official vectors (English "abandon … about", the BIP39 "TREZOR" passphrase vector, the first Japanese vector from bip32JP) and, for English words without passphrase, that the xpub, SLIP77 key and BIP85 output equal those of new_with_network. The length tests are removed since the type rules out other lengths.
  • Changelog entry updated.

Review guide

Commit Kind Lines
5bb3cfb0 signer: take a fixed-size seed in from_seed source + its inline test module (#[cfg(test)] in the same file) +52/−92
16c8de56 docs: describe the seed signer in the changelog docs +1/−2

Verified locally on the branch head: cargo test -p lwk_signer --lib (11 passed), cargo clippy --all-targets -- -D warnings, cargo fmt --check and rustdoc with -D warnings --cfg docsrs.

- Take `&[u8; 64]`: a BIP39 seed is always 64 bytes, the type
  enforces it, and no error variant is added to `NewError`, so
  the change is not breaking.
- Keep the seed in `Zeroizing`, which also wipes clones.
- Document the goal: callers compute the BIP39 seed to support
  passphrases and mnemonics in every BIP39 wordlist.
- Replace the per-case tests with one table-driven test pinning
  the public contract (root keys of official vectors, and
  equivalence with `new_with_network` for English words).
@ethicnology-agent

Copy link
Copy Markdown
Author

@ethicnology ready for your review.

@ethicnology
ethicnology merged commit 33b1be3 into SatoshiPortal:master Nov 5, 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.

2 participants