mnemonics with double spaces, \n as separators, trailing and leading spaces should be invalid #105
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously mnemonics with leading / trailing / double spaces or with
\nor\ras word separator were treated as valid bymnemonic_is_validand underlyingmnemonic_to_entropyfunctions. This could cause a problem because this mnemonic was passed to pbkdf2 as is, without any normalization. So mnemonics like this would give an invalid seed.I was considering either normalizing mnemonics before sending to pbkdf2 and be more forgiving to user input, or be strict and enforce single spaces between words. In this situation I think it's better to be more strict, and wallet designers can relax this requirements by doing something like
" ".join(mnemonic.split())if they want, or usingmnemonic.strip()especially when reading from text file. Just keep in mind that doing something like that will create additional copies of the mnemonic in RAM.