Add gem_keystore crate with BIP39 recovery phrase suggestions#1154
Add gem_keystore crate with BIP39 recovery phrase suggestions#11540xh3rman wants to merge 1 commit into
Conversation
Introduce gem_keystore as the foundation crate for keystore and key management work. Initial surface is a Mnemonic helper that exposes BIP39 English word suggestions, wired through gemstone via UniFFI as suggest_recovery_phrase_words.
There was a problem hiding this comment.
Code Review
This pull request introduces a new gem_keystore crate and a keystore module within the gemstone package to provide mnemonic word suggestions based on the BIP39 standard. The implementation includes a suggest_recovery_phrase_words function exported via UniFFI for cross-platform support. Feedback indicates that the suggestion logic should normalize input to lowercase to ensure case-insensitive matching against the wordlist. Additionally, there is a concern regarding performance overhead when returning the full 2048-word list for empty prefixes during FFI serialization, suggesting a limit should be applied.
|
|
||
| impl Mnemonic { | ||
| pub fn suggest(prefix: &str) -> Vec<String> { | ||
| Language::English.words_by_prefix(prefix).iter().map(|word| word.to_string()).collect() |
There was a problem hiding this comment.
The suggestion logic is currently case-sensitive because the BIP39 wordlist is entirely lowercase. Normalizing the input to lowercase would improve the user experience (e.g., allowing "Ab" to match "abandon").
Additionally, returning all 2048 words for an empty prefix might lead to performance overhead when serializing/deserializing across the FFI boundary to mobile platforms. Consider if a limit (e.g., .take(20)) should be applied for the UI's benefit.
| Language::English.words_by_prefix(prefix).iter().map(|word| word.to_string()).collect() | |
| Language::English.words_by_prefix(&prefix.to_lowercase()).iter().map(|word| word.to_string()).collect() |
Introduce gem_keystore as the foundation crate for keystore and key management work. Initial surface is a Mnemonic helper that exposes BIP39 English word suggestions, wired through gemstone via UniFFI as suggest_recovery_phrase_words.