vbuterin / pybitcointools

SImple, common-sense Bitcoin-themed Python ECC library
1.28k stars 856 forks source link

privtopub only works with wif #115

Open ghost opened 8 years ago

ghost commented 8 years ago

This gives a good address:

priv=sha256("blah") wif = encode_privkey(priv, 'wif_compressed') pub = privtopub(wif) addr = pubtoaddr(pub)

Whereas this (as in example in readme) priv=sha256("blah") pub = privtopub(priv) addr = pubtoaddr(pub)

Gives an incorrect address. (running python2)

wizardofozzie commented 8 years ago
Whereas this (as in example in readme)
priv=sha256("blah") # add "01" flag
pub = privtopub(priv) # or compress(privtopub(priv) )

Hex SEC keys require the appended "compressed" byte. The first example does this automatically when you call wif_compressed in encode_privkey

ghost commented 8 years ago

Ah, I assumed, due to the example, that it was handled/ a problem with old-timey python. Just looked through main.py.

I think your code deserves more comprehensive documentations. Some really cool stuff in there.