Skip to content

Fix Japanese delimiter bug - #110

Merged
prusnak merged 5 commits into
trezor:masterfrom
shellOrg:master
Jun 29, 2023
Merged

Fix Japanese delimiter bug#110
prusnak merged 5 commits into
trezor:masterfrom
shellOrg:master

Conversation

@LucienSong

Copy link
Copy Markdown
Contributor

Fix Japanese delimiter bug.
And add Czech and Portuguese wordlist.

Add Czech and Portuguese wordlist.
Fix Japanese delimiter bug.
@LucienSong

Copy link
Copy Markdown
ContributorAuthor

When generate mnemonics in Japanese, the delimiter is \u3000. But when converting that mnemonic words to entropy or seed, It forget the \u3000 delimiter.

Fix Japanese delimiter bug.
And add Czech and Portuguese wordlist.
Fix Japanese delimiter bug.
And add Czech and Portuguese wordlist.
@prusnakprusnak mentioned this pull request Jun 29, 2023
@prusnak
prusnak merged commit 71cf520 into trezor:masterJun 29, 2023
prusnak added a commit that referenced this pull request Aug 13, 2023
@prusnak

Copy link
Copy Markdown
Member

I reverted the commit 71cf520 because it failes in the CI.

See https://github.com/trezor/python-mnemonic/actions/runs/5849364691/job/15857611745 as one instance.

@LucienSong please try fixing the issue again, but this time make sure the CI does not fail.

fametrano added a commit to fametrano/python-mnemonic that referenced this pull request Aug 13, 2026
to_mnemonic joins a japanese mnemonic with U+3000 while to_entropy,
check and expand split on " ", so the library cannot read the sentences
it writes: to_entropy raises on all 24 japanese vectors of vectors.json
and expand returns the sentence unchanged.
The separator is read after NFKD, which maps U+3000 to U+0020, so it
cannot be self.delimiter -- that was trezor#110, reverted in df3e150 for
failing CI. What is left to split on is any run of whitespace, which is
what detect_language already reads.
to_seed follows the same rule, so that a sentence check refuses no
longer stretches into a different seed in silence.
The tests fail without the fix: to_entropy raises on every japanese
vector, check refuses a sentence separated by anything but one space,
and expand hands back a tab- or U+3000-separated sentence unexpanded.
The existing round trip hides the first by splitting the sentence itself
before handing it over.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for freeto 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

@LucienSong@prusnak