bitshares / bitshares1-core

Software to run the old chain (before 2015-10-13). Code for current chain is https://github.com/bitshares/bitshares-core
https://bitshares.org/
The Unlicense
219 stars 174 forks source link

valid WIF private key does not validate #1257

Open nmushegian opened 9 years ago

nmushegian commented 9 years ago

https://bitsharestalk.org/index.php?topic=13340.0;topicseen

jcalfee commented 9 years ago

I think this is the problem:

>>> PrivateKey.fromWif("5H2m3sfuRM51FwxeMURLto7sqZ58mgQYi7jrRxGAFKrK")
AssertionError: Expected version 128, instead got 63

The version is the 1st unsigned byte in the decoded private key.

jcalfee commented 9 years ago

Actually, there is more to this.. the checksum does not match how we are calculating it. If we support this, the private key import could be enhanced to check the version and then verify the checksum a little differently.

Here is my comment: # BTS checksum includes the version

nmushegian commented 9 years ago

So not all WIF keys are created equal? Is there any info about what all the different variations are?

jcalfee commented 9 years ago

https://en.bitcoin.it/wiki/List_of_address_prefixes

Bitcoin-js is ignoring the version byte: https://github.com/bitcoinjs/bitcoinjs-lib/blob/e42c497a3c9afe67c86ba0a602b5a0e9bd66e604/src/eckey.js#L32-L33

nmushegian commented 9 years ago

Wait what does the network byte have to do with this? I thought private keys had no network byte and they are only added when creating the address?

xeroc commented 9 years ago

From my understanding it is safe to use the same private key over and over .. i.e. in BTS, MUSIC, PLAY .. but also in Bitcoin .. or am I missing something here?

pmconrad commented 9 years ago

It is about as secure as using the same password on every website where you're registered. IOW: don't do that.