Pseudocode to verify a signed message

7

1

Can someone explain or point to some documents with pseudo code that would show me how to verify bitcoin address based on a signature and message. I know how to do this in clients I want to know how to programmatically do it.

user1562

Posted 2012-07-08T03:48:20.067

Reputation: 73

Answers

4

Even better than pseudocode: here's some python code for message signing and verification, largely pilfered from the electrum client:

https://github.com/nanotube/supybot-bitcoin-marketmonitor/blob/master/GPG/local/bitcoinsig.py

nanotube

Posted 2012-07-08T03:48:20.067

Reputation: 2 254

2Is there any premade PHP class / code for this?Max Min 2013-05-04T17:45:43.870

This seems to fail for signatures that came from -regtest. Has anyone updated it?Aaron Ash 2016-04-03T22:10:41.200

2

According to this bitcointalk thread, it can be done via the JSON-RPC API: Code:

verifymessage [address] [signature] [message]

See here for non-programmatical methods to verify a message.

Highly Irregular

Posted 2012-07-08T03:48:20.067

Reputation: 10 514

1Thanks for the answer, but I am looking for technical or pseudo code explanation of the verify of a signed message. I want to use it in a program.user1562 2012-07-08T04:22:53.747

@user1562, I wonder if you might be best to start wih the source code for the bitcoin.org client? If you search the source for "verifymessage" you might be able to find some code you can reuse.Highly Irregular 2012-07-08T04:26:23.413

1

In the satoshi client the verifymessage command is implemented by this code which calls CKey::SetCompactSignature() to do its work.

Chris Moore

Posted 2012-07-08T03:48:20.067

Reputation: 13 952

1I saw this, and thanks but I was looking more of pseudo code or documentation.user1562 2012-07-08T04:38:38.483