Skip to content
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

ethers-x Secret storage meta only implements defaultPath? #392

Closed
kyriediculous opened this issue Jan 16, 2019 · 5 comments
Closed

ethers-x Secret storage meta only implements defaultPath? #392

kyriediculous opened this issue Jan 16, 2019 · 5 comments
Assignees
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@kyriediculous
Copy link

So after your wonderful explanation yesterday I set out to implement secret storage format.

Like I perhaps mentioned earlier we use a custom path.
If I understand correctly this should be saved under the x-ethers section but I can't see the property.

When I check var path = searchPath(data, 'x-ethers/path') || defaultPath; it will always result in the defaultPath because searchPath(data, 'x-ethers/path') will always return null.
as a result I get mnemonic mismatch.

The path is set in the plaintext version but after encryption it is not to be found.


const ethers = require('ethers')
const bip39 = require('bip39')
const adminWallet = ethers.Wallet.fromMnemonic(bip39.generateMnemonic(),  `m/99'/66'/0'/0/0`)

adminWallet.encrypt("test").then(e => ethers.Wallet.fromEncryptedWallet(e, "test")).then(w => console.log(w)).catch(err => console.log(err))

Wallet {
  privateKey:
   '0x295df01d1a333d6be048cd70a38330c227a3a1458c2c487b8d7a1271ea81711f',
  provider: [Getter/Setter],
  defaultGasLimit: [Getter/Setter],
  address: '0x739a2C705fb12EdF44943D1096294e9aaaD492bc',
  sign: [Function],
  mnemonic:
   'abuse spirit twice hat pizza pull mom usual loyal toilet satoshi rug',
  path: 'm/99\'/66\'/0\'/0/0' }
Error: mnemonic mismatch
    at getSigningKey (C:\Users\N.vergauwen\Desktop\knuckles-web\node_modules\ethers\wallet\secret-storage.js:192:24)
    at C:\Users\N.vergauwen\Desktop\knuckles-web\node_modules\ethers\wallet\secret-storage.js:237:42
    at Immediate.incrementalSMix (C:\Users\N.vergauwen\Desktop\knuckles-web\node_modules\scrypt-js\scrypt.js:420:28)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)

I use ethers 3.0 but I checked the 4.0 version codebase and the problem seems to persist there?

@ricmoo
Copy link
Member

ricmoo commented Jan 16, 2019

You are absolutely correct, which is even stranger, because I actually just yesterday fixed this bug (and added test cases) for this in the v5 branch on my desktop. Are you secretly spying on me in Starbucks? :p

I can back-port the fix to v4 today and copy the tests over.

@ricmoo ricmoo self-assigned this Jan 16, 2019
@ricmoo ricmoo added bug Verified to be an issue. on-deck This Enhancement or Bug is currently being worked on. labels Jan 16, 2019
@kyriediculous
Copy link
Author

kyriediculous commented Jan 17, 2019

Would be awesome ! Thanks :D

Altough I'd have to migrate eventually.

I already thought that was you in starbucks ;-) Just kidding :D

@ricmoo
Copy link
Member

ricmoo commented Jan 17, 2019

Forgot to fill in the issue number: e5bee7e

@ricmoo ricmoo removed the on-deck This Enhancement or Bug is currently being worked on. label Jan 23, 2019
@ricmoo
Copy link
Member

ricmoo commented Jan 23, 2019

This should be working in 4.0.22. Please let me know if you have any issues with it.

Thanks! :)

@ricmoo ricmoo closed this as completed Jan 23, 2019
@kyriediculous
Copy link
Author

Confirmed, I pulled from master yesterday an implemented it, running on dev now and going into prod today ! :)

@ricmoo ricmoo added the fixed/complete This Bug is fixed or Enhancement is complete and published. label Jan 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests

2 participants