tyler-smith / go-bip39

The BIP39 library for Go.
MIT License
549 stars 196 forks source link

Mnemonic whitespace separator deviates from reference implementation #29

Closed gz-c closed 5 years ago

gz-c commented 5 years ago

The use of strings.Fields in splitMnemonicWords allow more than one whitespace character between words.

https://golang.org/pkg/strings/#Fields

Fields splits the string s around each instance of one or more consecutive white space characters, as defined by unicode.IsSpace

The bip39 spec is not explicit about how words are to be separated.

The reference implementation uses a single space for the separator, after normalizing unicode to ascii:

https://github.com/trezor/python-mnemonic/blob/7d23efe34f3dd537996f31dae34f663207dac232/mnemonic/mnemonic.py#L153

tyler-smith commented 5 years ago

Thanks for this report! This should be tightened up in the spec. I think until 2.0 is done with real native multi language support it makes sense to stick to single spaces. I'll change this.