7

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.

3 Answers 3

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

2
  • 2
    Is there any premade PHP class / code for this?
    – Max Min
    May 4, 2013 at 17:45
  • This seems to fail for signatures that came from -regtest. Has anyone updated it?
    – Aaron Ash
    Apr 3, 2016 at 22:10
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.

2
  • 1
    Thanks 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
    Jul 8, 2012 at 4:22
  • @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. Jul 8, 2012 at 4:26
1

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

1
  • 1
    I saw this, and thanks but I was looking more of pseudo code or documentation.
    – user1562
    Jul 8, 2012 at 4:38

Your Answer

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

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