Conversation
|
If this lands and there is interest, I am happy to write the follow-up on the The BIP mandates NFKD and says nothing more, so implementations differ and the I left it out of this PR because it is new normative text rather than a |
|
On several occasions I raised my will that we should drop non-English wordlists from BIP39, but I was always blocked by editors. Since I am not able to edit my own standard, I don't really care about issues related to non-English use. |
|
prusnak I do understand your position, and I agree with you about English only. That said, I do care about fixing inconsistencies, and I would love it if your "I don't really care" could become an ACK. Also, the possible follow-up — what to do with whitespace that is not the separator, a leading or trailing space and so on — concerns English too, not just Japanese. |
|
@murchandamus a month has passed since the authors were cc'd. One of them, @prusnak, has answered: not an objection, but not an ACK either, and scoped to non-English use; the other three have not replied. Is a non-objection from an author enough to move a clarification like this forward under the "Pending acceptance" label, or does it need an explicit ACK? Happy to wait longer if that is the process, I just want to know what the thread is waiting on. |
1dd18aa to
a955414
Compare
|
A few shallow thoughts on this:
Nonetheless, if the industry standard is white space normalization (before hashing), then this could be reflected in the spec, but this is non-trivial to assess. |
|
We agree on the principle, and I want to say that first. A BIP that is already widely implemented should not be changed in a way that makes a conforming implementation non-conforming, and much less in a way that derives a different wallet from the same input. If this PR did either, I would withdraw it. I think it does neither, and the PR description did not make that clear enough. No input derives a different wallet. The seed is PBKDF2 over the NFKD of the sentence, and NFKD maps U+3000 to U+0020, so the two ways of writing a Japanese sentence already agree today. Taking the standard all-zero-entropy Japanese vector: Both forms also pass the checksum. This PR does not touch derivation at all. What the paragraph is about is splitting a sentence into words, which is what an implementation does to look the words up and to verify the checksum. Split on U+0020 before normalizing and that sentence is 1 word; split after normalizing and it is 12. So the text can change whether an implementation accepts a sentence, never which wallet it derives. And it is not a new rule.
and then explains that after normalization "dealing with ASCII or Ideographic space is the same". The body of BIP-39 never mentions the separator at all. So the paragraph lifts an existing "must" out of a linked file and into the text implementers actually read. On your first point, the paragraph does not change anything about non-English wordlists either — it repeats the rule the wordlists file already sets. So the question I would put back to you: with the above, does this fall within the clarification you say in your fourth point you could accept — the deficiency documented, no mandated rule changed? If not, I would rather fix the wording than argue the point: what would you need it to say? |
|
You are correct, the change in its current form does not affect wallet derivation. I was carried away by the mention of trailing spaces, but that's not addressed in the current PR. My comments were general, but not valid here, my apologies! The proposed clarification is being added to the "From mnemonic to seed" section, but I don't think it belongs there. The section describes the NFKD Unicode normalization before PBKDF2. Looking at the "Japanese" section of I think a better place to mention the space separator would be after the sentence: |
a955414 to
f84880d
Compare
|
Thank you for the detailed follow-up — the placement note is fair, and I've moved the paragraph. The seed section covers NFKD before PBKDF2; this is about how a sentence is written and read, so it now sits right after the sentence you named. On content, I'd keep one clause beyond your version, and the reason is in the file you linked. It does address splitting, but only as a precondition:
Verifying the checksum requires recovering the individual words, and in practice that means splitting the sentence — so that precondition does not hold for an implementation that checks a mnemonic it was given. What is left unsaid is the order splitting happens in. Split a Japanese sentence on U+0020 before normalizing and the whole sentence reads as one token; normalize first and it splits into the individual words, since NFKD maps U+3000 to U+0020. That order is the detail I think is missing rather than implied. What I've pushed is your sentence plus that clarification:
Two sentences, in the section you chose. If you'd rather the second lived in the wordlists file instead of the BIP, I'm happy to move it — the order is what matters to me, not where it's written. |
|
I think it has improved, thanks! I still have some comments:
|
The BIP never says it. The rule is on the wordlist page, which requires the ideographic space for Japanese, and it is not quoted here; the note there also holds a caveat that ASCII and ideographic spaces are the same "as long as your code ... [does not try] to split the phrase input by the user". The reference implementation's to_entropy() does split it, on U+0020 and with no prior normalization, and so cannot read back the Japanese sentences to_mnemonic() writes; check() and to_seed() normalize first and are unaffected. No test vector changes.
f84880d to
dc02d52
Compare
|
Both moves make sense; I've pushed them. The separator rule now appears once, in "Generating the mnemonic", in the form you proposed. The second sentence has moved where you suggested, right after the paragraph that requires a checksum to be computed — that paragraph is what makes it concrete, since computing the checksum is what forces the sentence to be split. I also dropped the restatement you flagged: it no longer repeats how words are joined, only what the split has to cope with. What I kept, rather than a pointer back to "Generating", is that requirement. The rules laid out there are about joining, and So the requirement is that the split accept either separator, and the way to get it wrong is splitting on U+0020 without normalizing first — which is what the reference implementation's
I deliberately avoided prescribing an order: Electrum splits on whitespace first and normalizes each word afterwards, which is equally correct. |
The BIP never says it. The rule exists — the Japanese wordlist page requires
the ideographic space U+3000, added in #130 — but it is not in the BIP text,
and the note there holds a caveat: ASCII and ideographic spaces are
equivalent "as long as your code never shows the user an ASCII space
separated phrase or tries to split the phrase input by the user".
The reference implementation splits the input, on U+0020, and so cannot read
back the Japanese sentences it writes:
to_entropyraises on all 24Japanese vectors of its own
vectors.json. The fix of the referenceimplementation is open there: trezor/python-mnemonic#145
This adds three sentences to "From mnemonic to seed": the separator, the
Japanese exception, and what it means for software that splits a sentence
before normalizing it. No test vector changes, and nothing that is correct
today becomes incorrect.
Found downstream in btclib: btclib-org/btclib#258.
🤖 Generated with Claude Code