Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: wingding on May 28, 2017, 09:40:08 AM



Title: How is a bitcoin address digitally signed?
Post by: wingding on May 28, 2017, 09:40:08 AM
To verify a digital signature you need the public key. But the public key can not be recovered from a bitcoin address. So how is signing done?


Title: Re: How is a bitcoin address digitally signed?
Post by: bL4nkcode on May 28, 2017, 11:21:12 AM
To verify a digital signature you need the public key.
Yes, thats true and you can do it from any desktop wallet client, like electrum which has its own, you can signed message using electrum.
But the public key can not be recovered from a bitcoin address. So how is signing done?
So what is the wallet you are using now to signed a message.


Title: Re: How is a bitcoin address digitally signed?
Post by: ranochigo on May 28, 2017, 11:45:10 AM
To verify a digital signature you need the public key. But the public key can not be recovered from a bitcoin address. So how is signing done?
If you're talking about the signature verification when someone sends a transaction, the public key is sent in the scriptsig of the transaction so nodes can verify the signature. The scriptsig contains both the signature and the public key. If it doesn't verify, the transaction is invalid.

If you mean a message that is signed by an address, the signature will contain necessary information that can be used to calculate the public key. From there, once the signature is verified to be signed by that public key, the public key can be converted into a Bitcoin address.

Private key is used to sign the message. With the private key, you can get the public key, RIPEMD 160 hash and public key hash.


Title: Re: How is a bitcoin address digitally signed?
Post by: wingding on May 28, 2017, 01:15:20 PM

Quote
If you're talking about the signature verification when someone sends a transaction, the public key is sent in the scriptsig of the transaction so nodes can verify the signature. The scriptsig contains both the signature and the public key. If it doesn't verify, the transaction is invalid.

Ok. I think I get it: the public key of txin bitcoin address is made public when you announce a transaction.
Is it also possible to use the public key directly as address instead of the bitcoin address? I ask because this may be useful if you want the sender to attach a private message to the receiver.


Title: Re: How is a bitcoin address digitally signed?
Post by: achow101 on May 28, 2017, 05:57:00 PM
Is it also possible to use the public key directly as address instead of the bitcoin address? I ask because this may be useful if you want the sender to attach a private message to the receiver.
Yes. Many old transactions did this since Bitcoin used to be pay to IP (ask an IP address for a public key). However you will need to ask the person you are sending to to give you a public key and many wallets do not have this information readily available.


Title: Re: How is a bitcoin address digitally signed?
Post by: ranochigo on May 29, 2017, 02:56:47 AM
I ask because this may be useful if you want the sender to attach a private message to the receiver.
Achow has answered your question on the first part. As to your second part, you can use a public key to encrypt messages but you cannot really include them in your transaction.

Of course, you can encrypt and put the message in the OP_Return of the transaction.


Title: Re: How is a bitcoin address digitally signed?
Post by: wingding on May 29, 2017, 11:03:37 PM
I ask because this may be useful if you want the sender to attach a private message to the receiver.
Achow has answered your question on the first part. As to your second part, you can use a public key to encrypt messages but you cannot really include them in your transaction.

Of course, you can encrypt and put the message in the OP_Return of the transaction.

I was more thinking about external handling of messages, like a server service. The sender use receiver's public key to encrypt a message, and sign it by using his public key from txin address.

Edit: the sender use receiver's public key/address to encrypt a message that receiver can decrypt with his private key.


Title: Re: How is a bitcoin address digitally signed?
Post by: Markley on June 11, 2017, 04:16:19 PM
signing is done using private keys, you verify the signature with the public key

I ask because this may be useful if you want the sender to attach a private message to the receiver.
Achow has answered your question on the first part. As to your second part, you can use a public key to encrypt messages but you cannot really include them in your transaction.

Of course, you can encrypt and put the message in the OP_Return of the transaction.

I was more thinking about external handling of messages, like a server service. The sender use receiver's public key to encrypt a message, and sign it by using his public key from txin address.


Title: Re: How is a bitcoin address digitally signed?
Post by: fan_of_things_and_stuff on June 12, 2017, 04:55:47 AM
If there was ever a private key for a specific wallet, there was also a public key; the two are generated as a pair. I'm not entirely sure what the question is, but suffice to say that the public key shouldn't ever really be lost...its public knowledge  :)


Title: Re: How is a bitcoin address digitally signed?
Post by: ranochigo on June 12, 2017, 05:48:31 AM
signing is done using private keys, you verify the signature with the public key

I ask because this may be useful if you want the sender to attach a private message to the receiver.
Achow has answered your question on the first part. As to your second part, you can use a public key to encrypt messages but you cannot really include them in your transaction.

Of course, you can encrypt and put the message in the OP_Return of the transaction.

I was more thinking about external handling of messages, like a server service. The sender use receiver's public key to encrypt a message, and sign it by using his public key from txin address.
You CAN use a public key to encrypt messages for the person with the corresponding private key to decrypt. Note that this isn't exactly the best way to encrypt messages and it doesn't provide as much security as a PGP encryption would.

Electrum has this implementation.