Is it possible to get the public key of a bitcoin address I do not have the private keys for with the standard client?

20

6

It is possible to get it from here: https://blockchain.info/de/q/pubkeyaddr https://blockchain.info/q

Is it possible with the standard client? How?

I am aware that the blockchain only contains the pubkey after a tx from that address.

kermit

Posted 2013-06-12T19:01:22.700

Reputation: 1 839

Answers

18

It is impossible to compute the public key of an address, as the address is computed from the hash of the public key. You can retrieve the public key from address with the reference client using the validateaddress RPC call (or in the debug window of Bitcoin-Qt), but that simply fetches it from the wallet, and only works if the address is your.

What do you need the public key for, if it's not your address?

Pieter Wuille

Posted 2013-06-12T19:01:22.700

Reputation: 54 032

1

I would like to encrypt messages by abusing bitcoin/namecoin signing keys as encryption keys. see: https://bitcointalk.org/index.php?topic=145098 I am aware there might be peripheral risks to using the same keys for signing and encryption.

kermit 2013-06-13T20:07:02.600

1To elaborate, a public key is 33 bytes long, whereas an address is a 20-byte hash of the public key. Because the information is smaller, therefore it is impossible to compute the correct public key from an address.Nayuki 2016-01-11T02:30:16.517

don't i need the full pub key for an address i do NOT own when creating a new multisig address with "addmultisigaddress"?Albert s 2016-01-23T21:27:24.323

It IS possible to recover the public key from the signature though (so you can recover the public key of an address already seen on the blockchain), see the answer below. – None – 2017-06-28T14:09:03.540

Wait, shouldn't it be possible to lookup int he blockchain and see if that person spent from that address and then get the public key used to sign the transaction?Guerlando OCs 2017-07-26T08:30:28.440

@PieterWuille : but payment transactions are performed to a pubkey… Right ?user2284570 2019-03-28T01:21:07.093

What are "payment transactions"?Pieter Wuille 2019-03-28T01:48:46.310

9

It is impossible. Given an ECDSA (compressed 65Bytes or not 33Bytes) public-key K, a Bitcoin address is generated using the cryptographic hash functions SHA-256 and RIPEMD-160. The public-key is hashed twice: HASH160 = RIPEMD-160(SHA-256(K)). The Bitcoin address is computed directly from this HASH160 value as

base58(0x00 || HASH160 || bSHA-256(SHA-256(0x00 || HASH160))/2224c). "||=concatenation"

enter image description here

so it is impossible to reverse the hash to get the public key.

Badr Bellaj

Posted 2013-06-12T19:01:22.700

Reputation: 862

@PieterWuille : but payment transactions are performed to a pubkey… Right ?user2284570 2019-03-28T01:21:11.383

it depends on the transaction typeBadr Bellaj 2019-03-28T11:40:57.053

I wrote this in the sense this is a requirement.user2284570 2019-03-28T11:45:30.817

the pub key is shared with the network so no need to reverse an address to get the pubkeyBadr Bellaj 2019-03-28T15:23:56.833

@user2284570 What is a "payment transaction"?Pieter Wuille 2019-03-28T19:32:03.100

@PieterWuille a transaction which bear value with a receipient which is not a miner.user2284570 2019-03-28T21:32:42.697

In that case, no; there are almost no pay-to-pubkey outputs at all.Pieter Wuille 2019-03-28T21:41:38.307

9

To be honest, it IS possible, but you need a signature made by that address. From that point, you can get the public key.

See this piece of code: https://github.com/bitcoinjs/bitcoinjs-message/blob/master/index.js#L57

Peter Willemsen

Posted 2013-06-12T19:01:22.700

Reputation: 101