Skip to content

Conversation

khalahan
Copy link

Adds two rpc commands :

  • signmessage
  • verifymessage

It allows to sign a message with the public key of a bitcoin address you own, to be sure of the identity of the sender.
Command : ./bitcoind signmessage 1L5zqFahc8Ahu9wtgJqCeJMendvD174xsG "Hi github users :p"
Output :
{
"address" : "1L5zqFahc8Ahu9wtgJqCeJMendvD174xsG",
"pubkey" : "04ef6e366cd6b0b8fbf02c0c25ad39fe892b90c597875899fdc9db16941cf43fb8c429e0534cb8b972f5cc9f1a50f36dc3352ffad427f073e1c64a145828a3be6e",
"sign" : "3046022100a80b6e0c7c54c54ba943f4e3cde12f5a7dc5313e3f0a15ce868f01683ced64fa0221008b4ad7d3800a11c241dcef7aaf44c8224a7d9f1e54d3e669bf4887036b6d10af"
}

Command : ./bitcoind verifymessage "Hi github users :p"
Output :
{
"address" : "1L5zqFahc8Ahu9wtgJqCeJMendvD174xsG",
"pubkey" : "04ef6e366cd6b0b8fbf02c0c25ad39fe892b90c597875899fdc9db16941cf43fb8c429e0534cb8b972f5cc9f1a50f36dc3352ffad427f073e1c64a145828a3be6e"
}

Reviews and comments are welcomed, I don't know if all is used as it should.

Forum thread : http://www.bitcoin.org/smf/index.php?topic=6428.0

EDIT(alex): Sipa's revision references pull 183 - #524

@gavinandresen
Copy link
Contributor

Can you start a forum thread about this? There was some concern about possible attacks revealing private keys if the attacker can send arbitrary data to be signed.

Also some nits: indentation looks messed up on the git diff, and isn't there a better way to get a string into a vector ?

@khalahan
Copy link
Author

Forum thread is available here : http://www.bitcoin.org/smf/index.php?topic=6428.0

@gavinandresen
Copy link
Contributor

Can you squash the 4 commits into one please? It'll make the commit history cleaner.
(other than that, I agree this is a cool new feature and is ready to be pulled)

@jgarzik
Copy link
Contributor

jgarzik commented May 5, 2011

ACK, once rebased as Gavin requested

@gavinandresen
Copy link
Contributor

Also: consensus on the forums seems to be that making the padding: address+padding+message ... wouldn't hurt.

Add padding to input (fixed string + address) before hashing
@khalahan
Copy link
Author

khalahan commented May 6, 2011

Here is the rebased commit plus address used as padding (cool feature the rebase/squash commands :p).

@amiryal
Copy link
Contributor

amiryal commented May 7, 2011

Nice work, khalahan; thanks!

I am not familiar with the JSON RPC protocol, so this may be a silly question: is it necessary for the server to echo some of the parameters back to the caller? (e.g. address when signing and pubkey when verifying.)

$ bitcoind signmessage 1GsDU... hello
{
"address" : "1GsDU...",
"pubkey" : "04c4...",
"sign" : "3045..."
}
$ bitcoind verifymessage 04c4... 3045.... hello
{
"address" : "1GsDU...",
"pubkey" : "04c4..."
}

Second question: why not use the address for verifying rather than the pubkey? Can the pubkey not be inferred from the address?

@sipa
Copy link
Member

sipa commented May 8, 2011

The pubkey can indeed not be inferred from the address. I suggested on the forum to encode the pubkey in the signature output, so the verifymessage interface can take an address. (see http://www.bitcoin.org/smf/index.php?topic=6428.msg108668#msg108668)

@khalahan
Copy link
Author

amiryal > there is no real need to echo some of the input parameters.

Should i remove duplicates ?

sipa > i replied on the forum

@gmaxwell
Copy link
Contributor

The pubkey can be inferred from the address plus the signature value, however.

@gavinandresen
Copy link
Contributor

I resurrected discussion on forum thread: https://bitcointalk.org/index.php?topic=6428.msg443377#msg443377

@gavinandresen
Copy link
Contributor

Closing, sipa has a more refined version.

dexX7 pushed a commit to dexX7/bitcoin that referenced this pull request Nov 24, 2014
Move rounduint64, swapByteOrderN, test and "fix" rounduint64
lateminer pushed a commit to lateminer/bitcoin that referenced this pull request Dec 9, 2017
Fix for no text shown in status bar when hovering minting button
cryptapus added a commit to cryptapus/bitcoin that referenced this pull request Feb 28, 2020
rajarshimaitra pushed a commit to rajarshimaitra/bitcoin that referenced this pull request Aug 5, 2021
- consistently sticking to "2-out-of-2"
- rephrasing some sentences to make them more palatable. "obviously a lie" is a bit aggressive. 
- avoid using exaggerating terms like "very expensive", just state the facts without too many emotions
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants