Importing wallet that have verified signature message

I just remembered how to do math with hex in python…convert it to an integer like this:
x = ‘HiUikekeJilleivlUyelkbWNoeLpBxcweQqlzAer08cl2vlkjfl38ivlbh3l4lbklboijldfjcobn=’
y = x.decode(“hex”)
z = int(y, 16)

this converts the variable to a integer from base16hex

now “z” is an integer so you can do math with it…

so take the message and convert it the same way and then subtract the unsigned message from the signed one
then convert the new integer back to hex like this:
hex(‘new integer’)
or
import binascii
binascii.hexlify(‘newinteger’)
this should be the hex version of your private key…
from there you can convert it to WIF using pycoin or any other software that will calculate wallet import format

Thanks. The y = x.decode(“hex”) is giving the following error:
AttributeError: ‘str’ object has no attribute ‘decode’

I tried import base64, codecs but still error.

you aren’t replacing “hex” with your string are you?
you have to specify that you want it to decode to hex format

you can actually copy and paste this:

x = ‘HiUikekeJilleivlUyelkbWNoeLpBxcweQqlzAer08cl2vlkjfl38ivlbh3l4lbklboijldfjcobn=’

then copy and paste this:
x.decode(‘hex’)

The vk and sk coding works well. One question, about the sk output. When type sk, it shows an object at 0x7f9324da3t98. This is a very short string. Is that what is called a nonce.

yes this is your key that you just generated using the elliptic curve to be used with the private key to sign the message with and is verified with the public key

No, I’m not replacing “hex” with anything. I’m typing:
x = 'HiUikekeJilleivlUyelkbWNoeLpBxcweQqlzAer08cl2vlkjfl38ivlbh3l4lbklboijldfjcobn=’
y = x.decode(“hex”)

a nonce…is a “number only used once”

the string object you are seeing is the result from using the ecdsa function that you call to a new variable

does the same thing with hash functions

if it cannot decode the string like that then you can try this:

import binascii
binascii.unhexlify(‘HiUikekeJilleivlUyelkbWNoeLpBxcweQqlzAer08cl2vlkjfl38ivlbh3l4lbklboijldfjcobn=’)

if this does not work then you may just be stuck using base64.b64decode(x)

So how do I use the sk string object in the transaction.

I get a “” error like binascii.Error: Non-hexadecimal digit found

Okay, base64.b64decode(x) works. Great!
Thanks.

X = 'HiUikekeJilleivlUyelkbWNoeLpBxcweQqlzAer08cl2vlkjfl38ivlbh3l4lbklboijldfjcobn=’
y = base64.b64decode(x)
z = int(y, 16)

get error with the ‘z’ as follows:
Traceback (most recent call last):
File “”, line 1, in
ValueError: invalid literal for int() with base 16: b’ PN\x0b\data data’

replace “message” with your message to be signed in the sig = sk.sign(b"message") function

in this case you would place the transaction hex data there to be signed.

the verifying key is the public key

like I said…in this case…
you need the private key instead of a newly generated signing key

fr this you will need to extract the private key from the signature by converting it to an integer and subtracting the unsigned message from the signed message…
then the function would be like this:

import ecdsa
pkey= private key
sk = ecdsa.SigningKey(pkey)
vk =pkey.get_verifying_key()
sig = pkey.sign(b"message")
vk.verify(sig, b"message")

sk_string = binascii.hexlify(sk.to_string)
sig_string = binascii.hexlify(sig)

don’t forget that the message would now be an unsigned transaction hex in order to send the coins to a new address

might want to try decoding the base64 string like this

import binascii
x = 'HiUikekeJilleivlUyelkbWNoeLpBxcweQqlzAer08cl2vlkjfl38ivlbh3l4lbklboijldfjcobn=
binascii.hexlify(x.to_string())

hope you catch the edit I just made before trying it…
basically your just replacing the newly generated key with a private key like this:

pkey = private key
sk = ecdsa.SigningKey(pkey)

this will give you a signing object using your private key
the do
sk.sign(b"message")

notice the “b”…this means that the message must be in the form of a byte array to work properly

Oh! so have to put the message in bytes format in sk.sign(b"—")
Okay.

if you watch that video…
the way they came up with “K” is the same way I am suggesting to extract your private key
the guy just subtracts the unsigned message from the signed/hashed one and this gives the private key…

this can be done with any bitcoin/litecoin private key that used a static “K” to sign transactions
which is one reason it is NOT recommended to reuse addresses

good luck with it…I have to wake up early so I am out for the evening

Okay. Thanks man. Appreciate it!

1 more thing I forgot about

you can convert a string to bytes in python like this

x = ‘message’
bytes(x)

this will return something like this b’message’

so you may need to try both that and

bytearray.fromhex(x)

I am honestly not too sure on that one…more than likely the first option will be the one you need to use though

I was thinking about it and actually the way they came up with “K” in the video is the same way you would come up with a unsigned message
so you actually already have your “k” value
you just need to get the private key from it by subtracting you “k”(message) from the signed message