Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: cookiebro on November 29, 2021, 02:27:30 PM



Title: Is it possible to obtain the public key from any address?
Post by: cookiebro on November 29, 2021, 02:27:30 PM
Hey,

I need to know if it's possible to obtain the public key from any given BTC address. And if so, how?

I usually get it via the "decodescript" command hash value via the Bitcoin core, but this particular hash doesn't contain the public key, as far as I can tell.

Ta


Title: Re: Is it possible to obtain the public key from any address?
Post by: DeepComplex on November 29, 2021, 02:43:40 PM
The Public Key is only disclosed after a spending transaction has occurred. As long as no bitcoin has been sent from the address the key is unknown.

 


Title: Re: Is it possible to obtain the public key from any address?
Post by: BlackHatCoiner on November 29, 2021, 03:44:27 PM
When someone funds a bitcoin address, they lock those funds in a hash of the public key which is, essentially, the address. Those funds can be unlocked only if the public key, that once hashed gives the same hash, is provided along with a message that says they want to spend that UTXO plus a valid signature.

If there's no spent transaction output from an address, you only have the base58 representation of the hash, which means you only have the hash.


Title: Re: Is it possible to obtain the public key from any address?
Post by: NotATether on November 29, 2021, 06:02:09 PM
The addresses are designed to not reveal to you the public key, that's why you cannot find the one for your address.

In particular, decoding the hash does not reveal the public key, it only reveals the script and also the HASH160 that it's pushing to the stack to compare for equality. There is no public key in this process at this stage (only when you sign the transaction and the public key is fed into the script to get Boolean true/false accepted/rejected value).


Title: Re: Is it possible to obtain the public key from any address?
Post by: o_e_l_e_o on November 29, 2021, 08:20:19 PM
I usually get it via the "decodescript" command hash value via the Bitcoin core, but this particular hash doesn't contain the public key, as far as I can tell.
Not all addresses have a public key. It could be that you are trying to decode a P2SH or P2WSH address which is using a hash of the locking script instead of a hash of the public key, for example.

Can you share the script you are decoding and then we can tell you exactly what is going on?


Title: Re: Is it possible to obtain the public key from any address?
Post by: Pmalek on November 30, 2021, 10:27:28 AM
Why is my gut feeling telling me that DeepComplex is just an alt of cookiebro and that the whole purpose of this thread is for either of the two to get some merits? If I am wrong, I apologize to both users.

The fact is that both registered on the same day and coincidentally ended up posting in the same thread. 


Title: Re: Is it possible to obtain the public key from any address?
Post by: DeepComplex on November 30, 2021, 10:16:00 PM
No, i'm not "cookiebro", i'm a long-time lurker who only had a reason to post recently.

I'm now learning about the technology.

Why is my gut feeling telling me that DeepComplex is just an alt of cookiebro and that the whole purpose of this thread is for either of the two to get some merits? If I am wrong, I apologize to both users.

The fact is that both registered on the same day and coincidentally ended up posting in the same thread. 


Title: Re: Is it possible to obtain the public key from any address?
Post by: bitcoinbeto on December 03, 2021, 11:58:55 PM
In the new P2TR (pay-to-taproot) single key address type, the bech32 decoded address is also a public key.