-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Remove "0x" from beginning of raw private keys (super low priority) #687
Comments
Thanks for the report! It's strange to me nobody else hex prefixes this, but it's easy to exclude.
|
I agree. I actually went thru jaxx and geth assuming I needed to update MEW to support both (which we totally could) only to discover you're the outlier. Sorry! 🙏 😛 |
For compatibility with Jaxx, MEW, and Geth. Fixes #687
It seems that ganache requires private keys to have the 0x prefix otherwise a RangeError happens saying that the private key length is invalid. Is it possible to ask metamask to sign with the 0x prefix? |
You should open an issue with ganache then. It's pretty standard at this point not to prefix private keys with 0x. One good reason is private keys and transactions hashes are the same length. Prefixing transaction hashes with 0x and not private keys reduces the likelihood that you'll ever switch one out for another. e.g. which of the below is a transaction hash and which is a private key?
Fun fact, in 2016 there were 6 transaction hashes on the blockchain that, when used as a private key, that had a balance in them. |
That's horrifying. |
@tayvano you're right! Turns out I wasn't using the latest version of Ganache. Problem seems to be fixed in v6.1.6 |
I've never seen this raw, unencrypted private keys start with and add'l "0x" before. I know it doesn't actually make a difference in the grand scheme of things, but it won't unlock in MyEtherWallet.com nor via Geth. Jaxx's output of private key doesn't include the 0x either.
Where does this occur?
Demo
Seed phrase:
section feel merit flower clump accuse exit maple piano chat crouch pyramid
Jaxx Outputs (HD):
0xE2979fD0eB5d304891aBA9D39b27E82c9Fda6eE2
e316ca8ecfb79b0f0d085a17ac835cd390f806ac736ef39c9951747445cff202
MetaMask Outputs:
0xE2979fD0eB5d304891aBA9D39b27E82c9Fda6eE2
0xe316ca8ecfb79b0f0d085a17ac835cd390f806ac736ef39c9951747445cff202
MEW (unlock via private key):
0xe316ca8ecfb79b0f0d085a17ac835cd390f806ac736ef39c9951747445cff202
= invalid, won't unlocke316ca8ecfb79b0f0d085a17ac835cd390f806ac736ef39c9951747445cff202
= unlocks, displays address0xE2979fD0eB5d304891aBA9D39b27E82c9Fda6eE2
Geth (Using this method for importing plain private key):
0xe316ca8ecfb79b0f0d085a17ac835cd390f806ac736ef39c9951747445cff202
returnsFatal: Failed to load the private key: encoding/hex: invalid byte: U+0078 'x'
e316ca8ecfb79b0f0d085a17ac835cd390f806ac736ef39c9951747445cff202
returns true and encrypts the private key toUTC--2016-09-30T07-08-26.155091180Z--e2979fd0eb5d304891aba9d39b27e82c9fda6ee2
The text was updated successfully, but these errors were encountered: