How to sign a message using Bitcoin private key?



How does one create a proper signature for a given message using Bitcoin private keys?

I have an input address of




I want to sign message:


I convert it to hex:


I feed it to a signing function of ECDSA library that uses secp256k1, and I get two outputs,

r = D16A44BF1095FB7D517C7C4DD6A51E3EFD29548C5CAD8CA4AB763946D02AE0E8 
s = 2AB3E674B788804B87CED50619A1EFA267E17D20C016D0779BC3203D40E8105D 

If I marshal it with DER/asn1 as a list of Big Integers, I get a result of:


If I marshal them as a list of byte arrays, I get


if I marshal them as one long byte array, I get 0WpEvxCV+31RfHxN1qUePv0pVIxcrYykq3Y5RtAq4Ogqs+Z0t4iAS4fO1QYZoe+iZ+F9IMAW0HebwyA9QOgQXQ==

None of them appear to work as signatures when I try to verify the message signature using tools like .

How do I properly sign messages using Bitcoin private keys to be compatible with BitcoinQT?


Posted 2013-11-15T15:06:10.420

Reputation: 42 235

2The ultimate documentation is the source... – Nate Eldredge – 2013-11-15T16:46:07.507

1What's wrong with signmessage <bitcoinaddress> <message>? – KJ O – 2014-04-05T20:19:34.597

Have you found the signing algorithm? I tried doubleSha(msg.getBytes) (in Java). Verification fails. – Jus12 – 2017-12-20T17:08:11.053

2For heavens sake the question is asked so things can be done manually with out using any programs such as bitcoin-qt its a technical question !

The user wants to sign a tx manually and check with bitcoin-qt or cli to make sure he signed is correct ! – f4r4 – 2018-03-27T18:24:51.243



Using bitcoind and bitcoin-cli you can do it as follows:

bitcoin-cli signmessage 1DiWX6p3FdHPZqN88vMeGVXSwAQ1h7BeVj 'Hello world!'

Luca Venturini

Posted 2013-11-15T15:06:10.420

Reputation: 41


In Bitcoin-qt

enter image description here enter image description here

Or you can do it in by clicking the menu above your addresses.

No need to do it manually.


Posted 2013-11-15T15:06:10.420

Reputation: 216