Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: jgmBitcoin on June 04, 2016, 08:01:27 PM



Title: How to get the Public Keys of a bitcoin User
Post by: jgmBitcoin on June 04, 2016, 08:01:27 PM
Is there some way in which I could get the public key of a Bitcoin user ?

Lets say If I have transaction from a Bitcoin user. Is there some means by which I could get the public key of a particular Bitcoin address ?

How does https://slock.it/ guys does it ? From where do they get the public key from ?

https://www.youtube.com/watch?v=-Ht23KXic1k


Title: Re: How to get the Public Keys of a bitcoin User
Post by: DannyHamilton on June 04, 2016, 10:04:07 PM
There is no certainty that any of the previous outputs that were used to fund the transaction were received at addresses under the control of the person that arranged for you to receive the bitcoins (or that those previous outputs were received at addresses at all).

However, if you are certain that you know that a particular output was received at an address that was under the control of the person that arranged for you to receive the bitcoins, then you can retrieve the public key from the transaction ScriptSig.


Title: Re: How to get the Public Keys of a bitcoin User
Post by: bob123 on June 07, 2016, 11:39:00 AM
There is no certainty that any of the previous outputs that were used to fund the transaction were received at addresses under the control of the person that arranged for you to receive the bitcoins (or that those previous outputs were received at addresses at all).

However, if you are certain that you know that a particular output was received at an address that was under the control of the person that arranged for you to receive the bitcoins, then you can retrieve the public key from the transaction ScriptSig.

And how is this technically done?


Title: Re: How to get the Public Keys of a bitcoin User
Post by: DannyHamilton on June 07, 2016, 12:03:38 PM
If you are certain that you know that a particular output was received at an address that was under the control of the person that arranged for you to receive the bitcoins, then you can retrieve the public key from the transaction ScriptSig.
And how is this technically done?

If you are using Bitcoin Core with tindex turned on, then you would use the following command:

Code:
getrawtransaction TRANSACTION_ID

replacing TRANSACTION_ID with the actual transaction ID of the transaction you are interested in.

Note that this only works if the user that sent you the bitcoins had previously received those bitcoins at an output that used a script requiring a an ECDSA signature for the key you are interested in. If the output script doesn't require a signature from the public key you're interested in, then you wont be able to get the public key.


Title: Re: How to get the Public Keys of a bitcoin User
Post by: deepceleron on June 16, 2016, 06:29:17 AM
When I see a thread like this, the first question - what is the OP hoping to achieve? Sometimes the question asked is not the real question.

A "Bitcoin User" doesn't have a public key, a Bitcoin address has a public key. The public key is only published when a transaction spends funds previously sent to that exact address.

Only after an address has spent money can the public key be recovered from a transaction stored in the blockchain. By recommendation, addresses are often never reused. Nothing about the address or its public key informs you about other addresses the user may have or use.


Title: Re: How to get the Public Keys of a bitcoin User
Post by: amaclin on June 16, 2016, 07:45:44 AM
When I see a thread like this, the first question - what is the OP hoping to achieve? Sometimes the question asked is not the real question.
A "Bitcoin User" doesn't have a public key, a Bitcoin address has a public key.
You should mention that you are talking about p2pkh outputs

The public key is only published when a transaction spends funds previously sent to that exact address.
Only after an address has spent money can the public key be recovered from a transaction stored in the blockchain.
Not only. Let us take the genesis block and its coinbase transaction
4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b (https://blockchain.info/tx/4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b?show_adv=true)
The public key (belongs to Satoshi Nakamoto) is
04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3 8c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f
The associated address 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa (https://blockchain.info/address/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa) does not have spending transactions


Title: Re: How to get the Public Keys of a bitcoin User
Post by: deepceleron on June 16, 2016, 08:49:18 AM

You should mention that you are talking about p2pkh outputs
....
The public key is only published when a transaction spends funds previously sent to that exact address.
Only after an address has spent money can the public key be recovered from a transaction stored in the blockchain.
Not only. Let us take the genesis block and its coinbase transaction
..

Well, you answered the OP's first question as "yes" (as long as that user is Satoshi). Not news to me, but informative to others:
The original generation of 50 BTCs from mining was a pay-to-pubkey script.

OP hasn't really revealed a topic of curiosity though, unless you want to send someone unsolicited op_checksig payments.