sign_message_with_wif_privkey also requires the secret.
So let's say I generate a key through bitaddress.org which gives me WIF format, hex format and all that, how would I go about using that?.
...
class EC_KEY(object):
def __init__( self, k ):
secret = string_to_number(k)
...
def string_to_number(string):
return int(binascii.hexlify(string), 16)
..
I'll have a mess around tonight... and see if I can come up with some example code to string some of it together.
EDIT: I'm too lazy to hack the code, so I was messing with the Electrum console:
>> import binascii
>> binascii.unhexlify("E705308F9F19BA9292FB0A9F022CC07666AA4D63C14C097F44A674C52599AF2D")
'\xe7\x050\x8f\x9f\x19\xba\x92\x92\xfb\n\x9f\x02,\xc0vf\xaaMc\xc1L\t\x7fD\xa6t\xc5%\x99\xaf-'
>> bitcoin.EC_KEY(binascii.unhexlify("E705308F9F19BA9292FB0A9F022CC07666AA4D63C14C097F44A674C52599AF2D"))
>> mystuff = bitcoin.EC_KEY(binascii.unhexlify("E705308F9F19BA9292FB0A9F022CC07666AA4D63C14C097F44A674C52599AF2D"))
>> print(mystuff.secret)
104493437413910685574809975339575985857145839109407479576256729153645095530285
>> print(mystuff.get_public_key())
03c8759d2cd3dc2b12f9ce4e539d956986b6fd0d2b38303b141cd8ee09e683be13
>> mystuff.sign_message("this is my message", False)
'\x1cEp\x0f\xc9\xae\xb4\x0f\x89\xf7\x80x\x88%\xa7\xc8\xd4Te\xfcRc\xaa\x0fe\xfa \xf2wP/\xf9\x0b?L@g\x1f\x07J\xba\x0b\x10Bj\xb1\xe6~\xb8\x9f\xc8\xbb|\xd8\xaer\x15\xb8X\x87^\\\xa0\xd9\xa5'
>> mystuff.verify_message(mystuff.sign_message("this is my message", False),"this is my message")
>> mystuff.verify_message(mystuff.sign_message("this is my message", False),"bad message")
Traceback (most recent call last):
File "C:\Users\jared\AppData\Local\Temp\_MEI114882\lib\bitcoin.py", line 642, in verify_message
raise Exception("Bad signature")
Exception: Bad signature
>>
If you check bitaddress.org with your original WIF key... L4xnRyP8ARQHZ1BwVkUVfk8sMkXsyBJxd9zhEMXci6NjHkFd9ewp or the HEX: E705308F9F19BA9292FB0A9F022CC07666AA4D63C14C097F44A674C52599AF2D you'll see the public address listed: 19M16LN1k5Emc8qBuDEYv9Aggpe2ttuABk