Pages:
Author

Topic: Tool or method for finding public key of Bitcoin address - page 2. (Read 1387 times)

member
Activity: 184
Merit: 14
Ok I think I have found how to do that now. How about a method to do the reverse (turn uncompressed public key into address)? So I can verify that the public key I am gathering is correct.
legendary
Activity: 3038
Merit: 4418
Crypto Swap Exchange
Ok I get that but the full  public key is 130 characters. Is it the first 65 (X value)
I think it'll be easier to represent it in a transaction with an uncompressed public key.

Let's inspect this address: 1MsHWS1BnwMc3tLE8G35UXsS58fKipzB7a

TXID: 3410bc9f7671d30225678a870f8d695cad1af6f64b0a319a487d3b86540794ab
ScriptSig: 48

3045022100a9830934fffb69c597f68a1d5f5b6621a5d384ba4a4c81c316c08f652ed8036202206 cef70d41b95bfd53c6ee3cc0a69ab7c96d9a1ef18ffbf100505851ba53d266b01 - Signature

41

044f355bdcb7cc0af728ef3cceb9615d90684bb5b2ca5f859ab0f0b704075871aa385b6b1b8ead8 09ca67454d9683fcf2ba03456d6fe2c4abe2b07f0fbdbb2f1c1 - Public key.

Yes, you can interpret the last 130 characters (or 65 bytes) of a scriptsig as the public key. Clients generating uncompressed public keys are a rarity nowadays, given bech32 and the inefficiency of uncompressed public keys.


member
Activity: 184
Merit: 14
I am referring to addresses that have spent coins and therefore exposed public key.
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
Hi guys. Just wandering  if their is a tool, script or method for finding the uncompressed public key of Bitcoin address. I have heard that you can if an addressed has sent funds. I haven't got a clue on how to find this information. Thanks

An address that has never spent any coins hasn't revealed its public key. Public keys are hashed multiple times to get our addresses. Specifically, these are the steps of how we end up with an address:

1) We generate a 256-bit private key.
Code:
18e14a7b6a307f426a94f8114701e7c8e774e7f9a47e2c2035db29a206321725

2) We, then, perform ECDSA to get our public key (compressed):
Code:
0250863ad64a87ae8a2fe83c1af1a8403cb53f53e486d8511dad8a04887e5b2352
(Compressed means only the x coordinate. We don't have to carry the y since it can be calculated from y2 = x3 + 7. Since y2 returns 2 different values, we use the prefix 02 or 03 in front of the compressed public key to determine if y is odd or even)

3) We hash that compressed public key with SHA-256:
Code:
0b7c28c9b7290c98d7438e70b3d3f7c848fbd7d1dc194ff83f4f7cc9b1378e98

4) After that, we perform RIPEMD-160 hashing to the SHA-256 result:
Code:
f54a5851e9372b87810a8e60cdd2e7cfd80b6e31

5) Add version byte in front of RIPEMD-160 hash (00 for Main Network):
Code:
00f54a5851e9372b87810a8e60cdd2e7cfd80b6e31

6) Again, SHA-256 to the previous result:
Code:
ad3c854da227c7e99c4abfad4ea41d71311160df2e415e713318c70d67c6b41c

7) We hash the SHA-256 result with SHA-256 again:
Code:
c7f18fe8fcbed6396741e58ad259b5cb16b7fd7f041904147ba1dcffabf747fd

8) The first 4 bytes of the last SHA-256 result is address' checksum:
Code:
c7f18fe8

9) Extend the RIPEMD-160 hash from part 5 with these 4 bytes:
Code:
00f54a5851e9372b87810a8e60cdd2e7cfd80b6e31c7f18fe8

10) Convert this to base58 and here you go:
Code:
1PMycacnJaSqwwJqjawXBErnLsZ7RkXUAs
[from bitcoin.it]


Got a little off-topic, but anyway. As far as I know, you can find the uncompressed public key from the scriptSig of a transaction (P2PKH address).

Ok I get that but the full  public key is 130 characters. Is it the first 65 (X value)
You can do it pretty easily here: iancoleman.io/bitcoin-key-compression. You can also convert compressed public keys to uncompressed with the equation I mentioned above.
member
Activity: 184
Merit: 14
I actually posted[1] about this a few days back I think.

So the format of P2PKH sigscript is the signature followed by the public key. So basically, extract the sigscript, identify the signature and there should be a OP_Pushbytes_65 (since we're talking about uncompressed) which is 41 in hex. You should get the public key pertaining to that specific address.


You can probably write a script to separate and identify the public key pretty easily.

[1] https://bitcointalksearch.org/topic/m.55912788

Ok I get that but the full  public key is 130 characters. Is it the first 65 (X value)
member
Activity: 184
Merit: 14
Any way that's available I just thought that getting it from sigscript was only way possible
legendary
Activity: 3038
Merit: 4418
Crypto Swap Exchange
I actually posted[1] about this a few days back I think.

So the format of P2PKH sigscript is the signature followed by the public key. So basically, extract the sigscript, identify the signature and there should be a OP_Pushbytes_65 (since we're talking about uncompressed) which is 41 in hex. You should get the public key pertaining to that specific address.


You can probably write a script to separate and identify the public key pretty easily.

[1] https://bitcointalksearch.org/topic/m.55912788
legendary
Activity: 2464
Merit: 4415
🔐BitcoinMessage.Tools🔑
Hi guys. Just wandering  if their is a tool, script or method for finding the uncompressed public key of Bitcoin address. I have heard that you can if an addressed has sent funds. I haven't got a clue on how to find this information. Thanks
In essence, bitcoin address is a hash of public key. Given that hash function is a one-way function, there are no methods or tools exist to calculate it "back". When you send your bitcoins, you are signing a message with your private key and also reveal your public key, so that everyone in the network can verify that you actually have a private key, meaning that you have a right to spend coins.
member
Activity: 184
Merit: 14
Hi guys. Just wandering  if their is a tool, script or method for finding the uncompressed public key of Bitcoin address. I have heard that you can if an addressed has sent funds. I haven't got a clue on how to find this information. Thanks
Pages:
Jump to: