You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
web3.eth.accounts.privateKeyToAccount() doesn't check for the input string length. Neither does it check for
Expected behavior
Calling const my_account = await web3.eth.accounts.privateKeyToAccount(<Really Long String>) should throw an error pointing out that the string is too long for a typical Ethereum private key.
Actual behavior
No error is thrown. console.log(my_account.privateKey) prints out the huge string.
The problem seems to be in the eth-lib npm package. The fromPrivate method does not check for the key length. Also, it does not check if the first two characters are '0x', it just slices out the first two characters.