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

Remove "0x" from beginning of raw private keys (super low priority) #687

Closed
tayvano opened this issue Sep 30, 2016 · 6 comments
Closed

Remove "0x" from beginning of raw private keys (super low priority) #687

tayvano opened this issue Sep 30, 2016 · 6 comments
Assignees

Comments

@tayvano
Copy link
Contributor

tayvano commented Sep 30, 2016

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?

  • Chrome extension -> click key icon/export private key for a wallet -> type I understand -> copy private key.

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 unlock
  • e316ca8ecfb79b0f0d085a17ac835cd390f806ac736ef39c9951747445cff202 = unlocks, displays address 0xE2979fD0eB5d304891aBA9D39b27E82c9Fda6eE2

Geth (Using this method for importing plain private key):

  • file with0xe316ca8ecfb79b0f0d085a17ac835cd390f806ac736ef39c9951747445cff202 returns Fatal: Failed to load the private key: encoding/hex: invalid byte: U+0078 'x'
  • file with e316ca8ecfb79b0f0d085a17ac835cd390f806ac736ef39c9951747445cff202 returns true and encrypts the private key to UTC--2016-09-30T07-08-26.155091180Z--e2979fd0eb5d304891aba9d39b27e82c9fda6ee2
@danfinlay
Copy link
Contributor

Thanks for the report!

It's strange to me nobody else hex prefixes this, but it's easy to exclude.

  • Dan

On Sep 30, 2016, at 3:11 PM, Taylor Van Orden notifications@github.com wrote:

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?

Chrome extension -> click key icon/export private key for a wallet -> type I understand -> copy private key.
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 unlock
e316ca8ecfb79b0f0d085a17ac835cd390f806ac736ef39c9951747445cff202 = unlocks, displays address 0xE2979fD0eB5d304891aBA9D39b27E82c9Fda6eE2
Geth (Using this method for importing plain private key):

file with0xe316ca8ecfb79b0f0d085a17ac835cd390f806ac736ef39c9951747445cff202 returns Fatal: Failed to load the private key: encoding/hex: invalid byte: U+0078 'x'
file with e316ca8ecfb79b0f0d085a17ac835cd390f806ac736ef39c9951747445cff202 returns true and encrypts the private key to UTC--2016-09-30T07-08-26.155091180Z--e2979fd0eb5d304891aba9d39b27e82c9fda6ee2

You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@tayvano
Copy link
Contributor Author

tayvano commented Sep 30, 2016

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! 🙏 😛

@danfinlay danfinlay self-assigned this Oct 4, 2016
danfinlay added a commit that referenced this issue Oct 4, 2016
For compatibility with Jaxx, MEW, and Geth.

Fixes #687
@ghost ghost assigned frankiebee Oct 4, 2016
@ghost ghost removed the in progress label Oct 4, 2016
@paymog
Copy link

paymog commented Jul 11, 2018

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?

@tayvano
Copy link
Contributor Author

tayvano commented Jul 11, 2018

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?

0xafdfd9c3d2095ef696594f6cedcae59e72dcd697e2a7521b1578140422a4f890

0xb8b1f812af73c8e67b41520e5a93135b4d061002d33de1d06a606f5d314b7004

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.

@danfinlay
Copy link
Contributor

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.

@paymog
Copy link

paymog commented Jul 13, 2018

@tayvano you're right! Turns out I wasn't using the latest version of Ganache. Problem seems to be fixed in v6.1.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants