If I get a public key of two integers, x and y values what code is necessary to convert them into their hex versions without any additional letters, or numbers? This is half a Python programming question and half a bitcoin question though I think it is better asked here due to the familiarity with bitcoin requirements.

Pseudo code:

xpublickey = 20091690549896866803343277351761137627937393619088856147056855893222768847187

ypublickey = 69823032225116710867248379519530157435196049639426167980995931003755153241086

hexpublickey = "04" + hex(xpublickey) + hex(ypublickey)

I don't know what code is necessary to turn it into (as the above code does not work):


1 Answer 1


y = hex(xPublicKey).rstrip("L").lstrip("0x")

z = hex(yPublicKey).rstrip("L").lstrip("0x")

hexpublickey = "04" + y + z

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.