feat(key-wallet): add normalize_phrase and is_word_in_language helpers#806
Draft
llbartekll wants to merge 1 commit into
Draft
feat(key-wallet): add normalize_phrase and is_word_in_language helpers#806llbartekll wants to merge 1 commit into
llbartekll wants to merge 1 commit into
Conversation
Add two BIP39 input helpers to Mnemonic so consumers don't re-implement wordlist/normalization logic on top of the bip39 crate: - normalize_phrase: NFKD + lowercase + whitespace-collapse (lenient input normalization for validation/membership; NOT BIP39 seed normalization, which to_seed already performs) - is_word_in_language: exact wordlist membership for a given language Re-export Language from the crate root + prelude, and add the unicode-normalization dependency. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #806 +/- ##
==========================================
+ Coverage 72.55% 72.73% +0.18%
==========================================
Files 322 323 +1
Lines 71006 71796 +790
==========================================
+ Hits 51518 52224 +706
- Misses 19488 19572 +84
|
llbartekll
added a commit
to dashpay/platform
that referenced
this pull request
Jun 10, 2026
Address review feedback on #3842: instead of a direct `bip39` dependency and re-derived wordlist/normalization logic, the recover-flow mnemonic FFI now delegates to key-wallet's primitives (is_word_in_language / normalize_phrase / validate). Requires the key-wallet additions in dashpay/rust-dashcore#806 — all 8 rust-dashcore deps bumped to that branch rev (307582cf == 3d0d5dc + the key-wallet change only). App-specific policy stays in the facade: the 7-language bundled set and cleanupPhrase's CJK ideographic auto-split. The platform_wallet_mnemonic_* FFI surface is unchanged (generated header byte-identical), so the Swift SDK and dashwallet need no change. The direct `bip39` dependency is removed; it is now reached only transitively via key-wallet. 18 unit tests pass; clippy + fmt clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What
Adds two BIP39 input helpers to
key-wallet'sMnemonic, plus aLanguagere-export, so downstream consumers can build recover-flow word/phrase validation on top of key-wallet instead of pulling in a second, directbip39dependency and re-deriving the logic.Mnemonic::normalize_phrase(&str) -> String— NFKD + lowercase + whitespace-collapse. Lenient input normalization for validation/membership of user-typed phrases; explicitly NOT BIP39 seed normalization (to_seedalready performs the required NFKD for seed derivation).Mnemonic::is_word_in_language(&str, Language) -> bool— exact wordlist membership for a given language (no normalization; pre-normalize vianormalize_phrasefor case/accent tolerance).Languagefrom the crate root +prelude(was only reachable viamnemonic::Language).unicode-normalizationdependency (already present transitively viabip39).Why
In dashpay/platform PR #3842,
rs-platform-wallet-ffiadded recover-flow mnemonic helpers by depending directly onbip39and re-implementing wordlist membership / phrase normalization. Review feedback flagged this as duplicating logic key-wallet already owns. These primitives let the platform crate become a thin facade over key-wallet — one source of BIP39 logic — and drop its directbip39dependency. App-specific concerns (CJK ideographic auto-split, the app's bundled-language policy) stay in the platform facade.Tests
`cargo test -p key-wallet --lib mnemonic` adds `test_normalize_phrase`, `test_normalize_phrase_unicode_forms_converge`, `test_is_word_in_language` (36 mnemonic unit tests pass). `cargo clippy -p key-wallet` clean.
Notes
Branched off `3d0d5dc` (the commit dashpay/platform currently pins) for a minimal, conflict-free diff: only `key-wallet/{Cargo.toml, src/lib.rs, src/mnemonic.rs}` change.
🤖 Generated with Claude Code
Summary by CodeRabbit
Languagetype alongsideMnemonicfor language-specific operations.