-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gaiacli keys add gives different addresses with --recover OR --ledger (same mnemonic) #3345
Comments
cc @jleni do you have any idea what the cause might be or where we should start to debug this? Alternatively, have we tested the Ledger app against a separate HD derivation implementation? |
The only "simple" thing I can imagine is that the derivation path is not hardened in the same way. When sending a path to a ledger device, the first three elements in the path are automatically hardened: i.e. 44'/118'/0'/0/5 = Maybe gaia is not hardening in the same way. Could this be the problem? |
It's supposed to - https://github.com/cosmos/cosmos-sdk/blob/develop/crypto/keys/hd/hdpath.go#L28 - but perhaps the hardening isn't being processed correctly? cc also @liamsi - do you remember, when you worked on this before, if we tested it against the Ledger derivation? |
We can easily add more tests for that. It would definitely be a good thing to do. |
EDIT: I can reproduce it, I'm investigating. |
You can also initialize a ledger with a user supplied mnemonic. So I think the issue here is saying that a ledger restored with the mnemonic generated from the fundraiser code provides a different address from that same 12 word phrase restored with |
CC'ing @jessysaurusrex @zmanian |
Looks like a regression:
|
@alessio can we fix this by reverting to the older dependancy. |
@jackzampolin @alessio No, the upgrade is necessary for the latest app. |
I would also like to update gaia's unit tests and extend them to consider all these cases |
I have just tested the PR. I will add some gaia unit tests for this. |
@jleni Can you explain what the upstream issue was (just curious, and wanting to make sure we don't have any similar possible latent bugs)? |
(Sorry, somehow missed that mention/notification) No, I do not really remember (but I think we did somehow manually). Looks like @jleni / @alessio found the issue: instead of the first 3, the first 4 were hardened: Zondax/ledger-cosmos-go@ed9aa39#diff-36caaa1394a5803bfa9f964755f1d733L41 |
Correct. I will later add a few additional integration tests in gaia/sdk to check public keys/mnemonics. |
While the problem in the ledger app has been fixed, there is still a problem in gaiacli. gaiacli keys add gaia0 --recover --account 0 @gamarin2 could you confirm this too? |
Yes, I can confirm |
@jleni can you open another issue to track work there? Also is that recovering with the same seed, or different seeds? |
same seed |
Indeed, we probably do not respect the HD derivation flags in our own |
Summary of Bug
I tried to generate an account from the same 12-words mnemonic (obtained with the fundraiser tool) using two different processes and obtained two different addresses.
The first process was to use the
--recover
flag ofgaiacli keys add
, with--account 0
The second process was to restore a ledger wallet with the 12-words mnemonic, and use the
--ledger
flag ofgaiacli keys add
, with--account 0
.Steps to Reproduce (using 12-words mnemonic)
gaiacli keys add --recover --account 0
. This givesaddress1
.gaiacli keys add --ledger --account 0
. This givesaddress2
.address1
andaddress2
are not the same.Edit: I restored the ledger twice to see if it was not a human error when inputting the mnemonic on the device -- @gamarin2
Steps to Reproduce (using 24-words mnemonic)
gaiacli keys add --ledger ledger-key
gaiacli keys add --recover ledger-key-recover
Addresses/public keys don't match.
For Admin Use
The text was updated successfully, but these errors were encountered: