-
Notifications
You must be signed in to change notification settings - Fork 60
Show a warning if passphrase contains extra whitespace #815
Show a warning if passphrase contains extra whitespace #815
Conversation
Good! But I think that the better way is to remove this kind of problem at the root. Trim passphrase in the component. something like this:
And we have a valid passphrase with removed extra spaces. |
That would be the right way to do it if you did it like this from the start... However, if you check that thread, this specific person had to add an extra whitespace to the passphrase to be able to log in, because they had a whitespace there when they created the wallet. And if they log in with no extra whitespace, they go into an empty wallet instead. So if you always auto-trim the passphrase now, they will have no way to log in to their actual wallet... So I think what I've done is probably the best way to do it if you want to be backward compatible. |
@mackuba indeed. |
It's possible that e.g. he copied the generated passphrase somewhere, didn't send any LSK yet; then logged in again copying or retyping that saved passhprase, but added a space by accident, and got into a different address, but didn't notice it (since he expected it to be empty anyway), and sent coins to that address. Then on another day tried logging in again, but not adding the extra space this time, and saw an empty wallet. |
AFAIK space at the end of the passphrase has no effect on the generated seed. You can try adding trailing whitespace on this tool: https://iancoleman.github.io/bip39/ and see that the While I don't see how could happen the issue to the user from Reddit, I like this PR. I have just one improvement suggestion - give a more instructive message in this case: |
That's how I expected it to work, since that would make perfect sense, but from what I could find, the passphrase is being passed to SHA256 as a single string, without even trimming it:
https://github.com/LiskHQ/lisk-js/blob/master/lib/transactions/crypto.js#L503-L511 As far as I can tell, the mnemonic (and Do I not understand correctly how this works? Testing logging in with various combinations of whitespace:
|
@mackuba thank you for the extensive explanation. Now I see the problem. There is one eslint error in Jenkins that prevents merge:
|
Yeah, I got it in the stdout log now too, not sure why I missed it previously. I've applied the fix and rebased again and forced-pushed to that branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @mackuba
👍 |
That's what I meant about keeping it backwards compatible by making it a warning, not an error: https://www.reddit.com/r/Lisk/comments/78glpw/new_release_lisk_nano_120_improved_core/dou1mr7/. Looks like someone changed it later to be an error: 1727b3e |
Hi!
I've noticed that a lot of people are having trouble logging in to their existing address, because they enter the passphrase with extra whitespace somewhere, they get a different empty address and they freak out that their money is gone, e.g: https://www.reddit.com/r/Lisk/comments/73n57o/help_lisk_is_gone/. This is really something that the app should prevent from happening at all... so I decided to do something about it.
One tricky thing here is that some people might have already entered the whitespace wrong when creating a wallet, so if we add validation that prevents them from logging in with a bad passphrase, they won't be able to get back to their wallet at all... so instead I added a 'warning' to the passphrase input component that is displayed just like an error, but isn't passed outside as an error, so it doesn't disable the login button. You're still able to log in with such incorrect passphrase, if you really need to, but it will be obvious to you that something is wrong, if that's not your intention.
I'm not sure how well I managed to do this in terms of proper React architecture... I have basically zero experience with anything in JavaScript that came after the ES5/jQuery/Backbone era. But it seems to be working 🙂 I couldn't figure out how to write a test though, I couldn't find any way to access the component's state with a warning field through the wrapper.
So it probably needs some more work, but I hope you'll be able to do something with this and merge it.