26

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
  • 2,019
  • 1
  • 17
  • 26

3 Answers3

28

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 belongs to you.

Update: you need to use getaddressinfo now instead of validateaddress.

Pieter Wuille
  • 105,497
  • 9
  • 194
  • 308
  • 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 Jun 13 '13 at 20:07
  • 2
    To 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 Jan 11 '16 at 02:30
  • 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 Jan 23 '16 at 21:27
  • 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. –  Jun 28 '17 at 14:09
  • 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 Jul 26 '17 at 08:30
  • @PieterWuille : but payment transactions are performed to a pubkey… Right ? – user2284570 Mar 28 '19 at 01:21
  • What are "payment transactions"? – Pieter Wuille Mar 28 '19 at 01:48
  • 2
    @user2284570 Bitcoin transactions have an input and output address and are normally sent to a "pubkey hash", not a "pubkey". A bitcoin address is just a pubkey hash with a header and checksum bytes appended then encoded with base58checked. So you can go from a bitcoin address to a pubkey hash without a problem. – dodgy_coder Feb 01 '20 at 11:43
14

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
  • 251
  • 2
  • 4
12

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
  • 1,151
  • 12
  • 18