Repository navigation
signer: take a fixed-size seed in from_seed - #2
Merged
ethicnology merged 2 commits intoNov 5, 2026
Merged
ethicnology merged 2 commits into
ethicnology merged 2 commits into
Conversation
- 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).
Author
|
@ethicnology ready for your review. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Follow-up to #1, aligning
SwSigner::from_seed_with_networkwith the LWK contribution guidelines before it is reviewed upstream in Blockstream#196 (opened from this repository'smaster, 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_networkforces an empty passphrase (to_seed("")) and only parses the wordlists compiled into thebip39crate; 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 theInvalidSeedLengthvariant added toNewErrorin signer: addSwSigner::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.Zeroizing, which also wipes clones; the manual wiping code is gone.new_with_network. The length tests are removed since the type rules out other lengths.Review guide
5bb3cfb0signer: take a fixed-size seed in from_seed#[cfg(test)]in the same file)16c8de56docs: describe the seed signer in the changelogVerified locally on the branch head:
cargo test -p lwk_signer --lib(11 passed),cargo clippy --all-targets -- -D warnings,cargo fmt --checkand rustdoc with-D warnings --cfg docsrs.