Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support unambiguous detection of language if only prefixes are supplied #106

Closed
wants to merge 3 commits into from

Conversation

pjkundert
Copy link
Contributor

If a BIP-39 Mnemonic is supplied that contains word prefixes (such as would be resolved by calling Mnemonic.expand), the Mnemonic.detect_language function fails. This fix simply allows detect_language to proceed until the prefix no longer appears in multiple language dictionaries.

Also, we detect that ambiguity no longer exists (less than 2 languages remain), and we suspend t the search.

Tests added to confirm that the search proceeds in the face of prefixes available in multiple languages.

@matejcik matejcik mentioned this pull request Jun 29, 2023
@pjkundert
Copy link
Contributor Author

Hi, @matejcik -- sorry for not bringing this up-to-date earlier! It should now be ready for the next release. Thanks!

@pjkundert
Copy link
Contributor Author

Turns out supporting prefixes in language deduction was more complex than I though...

The present implementation correctly resolves ambiguity, by requiring exactly one language to match word(s) fully, if all words are prefixes in multiple languages.

Only completely unambiguous codes pass language deduction.

@matejcik
Copy link
Contributor

matejcik commented Jan 5, 2024

merged as 4b14fc5

@matejcik matejcik closed this Jan 5, 2024
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