{"id":123,"date":"2024-11-24T12:03:31","date_gmt":"2024-11-24T12:03:31","guid":{"rendered":"http:\/\/teachbitcoin.org\/?page_id=123"},"modified":"2024-11-24T12:08:52","modified_gmt":"2024-11-24T12:08:52","slug":"how-to-sign-a-message-using-a-bitcoin-private-key","status":"publish","type":"page","link":"http:\/\/teachbitcoin.org\/index.php\/how-to-sign-a-message-using-a-bitcoin-private-key\/","title":{"rendered":"How to sign a message using a Bitcoin private key"},"content":{"rendered":"<h1>Signing a Message to Prove Ownership of a Bitcoin Address<\/h1>\n<h2>Reasons to Sign a Message<\/h2>\n<ul>\n<li>To prove that the address is valid for receiving funds.<\/li>\n<li>To show proof of funds (confirming that the balance attached to the address is spendable by you).<\/li>\n<\/ul>\n<p>Bitcoin full nodes and most self custody wallets with key control have this functionality built in.<\/p>\n<hr \/>\n<h2>Steps to Sign a Message<\/h2>\n<h3>1. Retrieve the Private Key<\/h3>\n<p>To sign a message, first, obtain the private key corresponding to the address. Use the following command:<\/p>\n<pre><code>bitcoin-cli dumpprivkey \"address\"<\/code><\/pre>\n<p>Replace <code>\"address\"<\/code> with the public address you wish to sign for.<br \/>\nThe output will be the private key corresponding to that address.<\/p>\n<h3>2. Sign the Message<\/h3>\n<p>Use the private key to sign a message. This message can be anything, for example, <code>\"Harry's Pet Store\"<\/code> or <code>\"Public Bank Address\"<\/code>. Use the command:<\/p>\n<pre><code>bitcoin-cli signmessagewithprivkey \"privkey\" \"my message\"<\/code><\/pre>\n<p>Replace <code>\"privkey\"<\/code> with the private key retrieved earlier.<br \/>\nReplace <code>\"my message\"<\/code> with the message you want to sign.<\/p>\n<p>The output will be a long string of characters \u2014 this is the <strong>signature<\/strong>.<\/p>\n<h3>3. Verify the Signature<\/h3>\n<p>Share the <strong>message<\/strong> and <strong>signature<\/strong> along with the public <strong>address<\/strong> to allow others to verify ownership. Verification can be done using:<\/p>\n<pre><code>bitcoin-cli verifymessage \"address\" \"signature\" \"message\"<\/code><\/pre>\n<ul>\n<li><code>\"address\"<\/code>: The public address.<\/li>\n<li><code>\"signature\"<\/code>: The signature generated in the previous step.<\/li>\n<li><code>\"message\"<\/code>: The message you signed.<\/li>\n<\/ul>\n<p>If everything checks out, the result will be:<\/p>\n<pre><code>true<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Signing a Message to Prove Ownership of a Bitcoin Address<\/p>\n","protected":false},"author":1,"featured_media":117,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-123","page","type-page","status-publish","has-post-thumbnail","hentry"],"_links":{"self":[{"href":"http:\/\/teachbitcoin.org\/index.php\/wp-json\/wp\/v2\/pages\/123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/teachbitcoin.org\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/teachbitcoin.org\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/teachbitcoin.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/teachbitcoin.org\/index.php\/wp-json\/wp\/v2\/comments?post=123"}],"version-history":[{"count":2,"href":"http:\/\/teachbitcoin.org\/index.php\/wp-json\/wp\/v2\/pages\/123\/revisions"}],"predecessor-version":[{"id":126,"href":"http:\/\/teachbitcoin.org\/index.php\/wp-json\/wp\/v2\/pages\/123\/revisions\/126"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/teachbitcoin.org\/index.php\/wp-json\/wp\/v2\/media\/117"}],"wp:attachment":[{"href":"http:\/\/teachbitcoin.org\/index.php\/wp-json\/wp\/v2\/media?parent=123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}