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

web3.eth.accounts.wallet.create returns inconsistent accounts #2725

Closed
sshelton76 opened this issue Apr 24, 2019 · 4 comments
Closed

web3.eth.accounts.wallet.create returns inconsistent accounts #2725

sshelton76 opened this issue Apr 24, 2019 · 4 comments
Labels
2.x 2.0 related issues Bug Addressing a bug Stale Has not received enough activity

Comments

@sshelton76
Copy link

Description

When supplying your own entropy to web3.eth.accounts.wallet.create the address returned appears to be random.

Expected behavior

The expectation is that if entropy is supplied that the resulting wallet accounts will always be the same.

Actual behavior

It appears that the accounts created within the wallet are randomly generated despite the fact you are supplying entropy. Either this is designed behavior which is undocumented, or there is a bug here. We either need to fix the bug so the same accounts are created or we need to document what the entropy is supposed to be used for. I have gone through the source code and it appears that consistent entropy should result in consistent accounts...
However eth-lib appears to be inserting random values despite supplied entropy...
https://github.com/MaiaVictor/eth-lib/blob/master/src/account.js

Steps to reproduce the behavior

  1. Generate entropy from a consistent source, for example from bip39.js mnemonic to entropy or mnemonic to seed function.
  2. Call
let seed = await (await bip39.mnemonicToSeed(mnemonic)).toString('hex');
        
        this.wallet = this.web3.eth.accounts.wallet.create(1, seed);
        console.debug("wallet: ",this.wallet);
  1. Do this a few times and notice that the resulting accounts are different every time.

Versions

  • web3.js:
    beta-37 and beyond
@nivida
Copy link
Contributor

nivida commented Apr 24, 2019

I will remove the eth-lib dependency and will refactor the code for the usage of the ethereumjs-wallet package.

@sshelton76
Copy link
Author

Awesome thanks!

@github-actions
Copy link

github-actions bot commented Jul 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions

@github-actions github-actions bot added the Stale Has not received enough activity label Jul 4, 2020
@lucille-bellepleure
Copy link

I have this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x 2.0 related issues Bug Addressing a bug Stale Has not received enough activity
Projects
None yet
Development

No branches or pull requests

3 participants