Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: andathw on December 28, 2021, 06:30:58 AM



Title: The questions of Public key,help me !
Post by: andathw on December 28, 2021, 06:30:58 AM
1. If an address has not sent any transaction, will the public key not be disclosed?



2. Does the real public key of this address only exist in the wallet.dat?



3. If i have the real public key from this wallet.dat, can it prove that the wallet is true rather than a tampered fake wallet file?

Because no transaction has been sent, there is no public key on the public chain.


Title: Re: The questions of Public key,help me !
Post by: pooya87 on December 28, 2021, 06:40:31 AM
1. If an address has not sent any transaction, will the public key not be disclosed?
It depends on the address or output type. There is only one address type that uses public key directly and that is the new P2TR address that uses the tweaked public key. Other addresses are using hash of the public key and since hash is irreversible we can not know the public key.
However, there are outputs scripts that can use the public key directly (they don't have any address defined). Like P2PK or P2MS outputs or anything similar that uses public keys.

Quote
2. Does the real public key of this address only exist in the wallet.dat?
It depends on the client that create the wallet file and the type of the wallet.
For example a watch only wallet that only received the address to watch will not have the public key but a wallet that was created from a private key or deterministic wallet created from a seed will have both private and the public key in addition to the script type of the addresses created by that wallet.

Quote
3. If i have the real public key from this wallet.dat, can it prove that the wallet is true rather than a tampered fake wallet file?

Because no transaction has been sent, there is no public key on the public chain.
If you have created the wallet file yourself then you already know that it is the real thing but if you have bought it or found it somewhere then you should be sure that it is a fake thing possibly containing malware.


Title: Re: The questions of Public key,help me !
Post by: andathw on December 28, 2021, 06:52:22 AM
1. If an address has not sent any transaction, will the public key not be disclosed?
It depends on the address or output type. There is only one address type that uses public key directly and that is the new P2TR address that uses the tweaked public key. Other addresses are using hash of the public key and since hash is irreversible we can not know the public key.
However, there are outputs scripts that can use the public key directly (they don't have any address defined). Like P2PK or P2MS outputs or anything similar that uses public keys.

Quote
2. Does the real public key of this address only exist in the wallet.dat?
It depends on the client that create the wallet file and the type of the wallet.
For example a watch only wallet that only received the address to watch will not have the public key but a wallet that was created from a private key or deterministic wallet created from a seed will have both private and the public key in addition to the script type of the addresses created by that wallet.

Quote
3. If i have the real public key from this wallet.dat, can it prove that the wallet is true rather than a tampered fake wallet file?

Because no transaction has been sent, there is no public key on the public chain.
If you have created the wallet file yourself then you already know that it is the real thing but if you have bought it or found it somewhere then you should be sure that it is a fake thing possibly containing malware.


Since this address has not sent transactions, how can we know its public key?

Please check this :1JqPFnGPhHhy54zJKmC1MPiczzgFjCmzE9

public key:
04f51f8d0c4dc4a5338bef745098e6f6364f8936fee6aa5a9d4ab0c214e7cdd727f094f442779b3 7d9046e53ea3f0b988aefaa6e0adb0662155cd763229e8519aa

check site:https://bitcointools.site/tool/pubkey-to-address


Title: Re: The questions of Public key,help me !
Post by: pooya87 on December 28, 2021, 07:10:21 AM
Since this address has not sent transactions, how can we know its public key?

Please check this :1JqPFnGPhHhy54zJKmC1MPiczzgFjCmzE9
public key    : 04f51f8d0c4dc4a5338bef745098e6f6364f8936fee6aa5a9d4ab0c214e7cdd727f094f442779b3 7d9046e53ea3f0b988aefaa6e0adb0662155cd763229e8519aa

check site:https://bitcointools.site/tool/pubkey-to-address
This is partly because of a bug in block explorers where they show P2PK outputs (that already contain the public key) as a P2PKH address. If you check the first received transaction in this "address" here (https://blockchair.com/bitcoin/transaction/39a7cf8a69891b86fabdc779b1e21d7c97522efd2954d7f26632dc0d4ff767df) you can clearly see that the payment was to the public key (ie. a P2PK output) so we already know the public key.

There is also some payments to the actual P2PKH address that uses the has of the public key (1JqPFnGPhHhy54zJKmC1MPiczzgFjCmzE9) but the block explorer shows all txs under the same address.
So if you search the public key of the said address, what the tools do is that they simply look up that P2PK output and return its public key which makes it look like they guessed it from the hash!


Title: Re: The questions of Public key,help me !
Post by: andathw on December 28, 2021, 07:21:18 AM
Since this address has not sent transactions, how can we know its public key?

Please check this :1JqPFnGPhHhy54zJKmC1MPiczzgFjCmzE9
public key    : 04f51f8d0c4dc4a5338bef745098e6f6364f8936fee6aa5a9d4ab0c214e7cdd727f094f442779b3 7d9046e53ea3f0b988aefaa6e0adb0662155cd763229e8519aa

check site:https://bitcointools.site/tool/pubkey-to-address
This is partly because of a bug in block explorers where they show P2PK outputs (that already contain the public key) as a P2PKH address. If you check the first received transaction in this "address" here (https://blockchair.com/bitcoin/transaction/39a7cf8a69891b86fabdc779b1e21d7c97522efd2954d7f26632dc0d4ff767df) you can clearly see that the payment was to the public key (ie. a P2PK output) so we already know the public key.

There is also some payments to the actual P2PKH address that uses the has of the public key (1JqPFnGPhHhy54zJKmC1MPiczzgFjCmzE9) but the block explorer shows all txs under the same address.
So if you search the public key of the said address, what the tools do is that they simply look up that P2PK output and return its public key which makes it look like they guessed it from the hash!

I knew,TX,
But this one,please have a check .

0465c1d2cadf9178ed4bf739205dad4ab20b52a0c4ff64e5bcb6acc9f4a3d1964805d11ad5ebb4f 3fc7f4c2b4ea9fd13b000350750d682497e03833e1112b8e9ed


Title: Re: The questions of Public key,help me !
Post by: pooya87 on December 28, 2021, 08:01:05 AM
I knew,TX,
But this one,please have a check .

0465c1d2cadf9178ed4bf739205dad4ab20b52a0c4ff64e5bcb6acc9f4a3d1964805d11ad5ebb4f 3fc7f4c2b4ea9fd13b000350750d682497e03833e1112b8e9ed
The principle is the same. There is no way to know the public key if all we have is the hash from the corresponding address. Either the public key has to be revealed in the output script or the owner of the address has to spend from it and reveal the public key.

In this case the owner has spent the shitcoins they received as an airdrop on a poor copy of bitcoin and its blockchain called bcash. But they never spent their bitcoins so we know the corresponding public key from that shitcoin's blockchain: https://blockchair.com/bitcoin-cash/transaction/6e8b59f6e9f3c472df0b40ec8742f61d3e8af3678b3568a14a047317be320ffa


Title: Re: The questions of Public key,help me !
Post by: andathw on December 28, 2021, 08:45:55 AM
I knew,TX,
But this one,please have a check .

0465c1d2cadf9178ed4bf739205dad4ab20b52a0c4ff64e5bcb6acc9f4a3d1964805d11ad5ebb4f 3fc7f4c2b4ea9fd13b000350750d682497e03833e1112b8e9ed
The principle is the same. There is no way to know the public key if all we have is the hash from the corresponding address. Either the public key has to be revealed in the output script or the owner of the address has to spend from it and reveal the public key.

In this case the owner has spent the shitcoins they received as an airdrop on a poor copy of bitcoin and its blockchain called bcash. But they never spent their bitcoins so we know the corresponding public key from that shitcoin's blockchain: https://blockchair.com/bitcoin-cash/transaction/6e8b59f6e9f3c472df0b40ec8742f61d3e8af3678b3568a14a047317be320ffa

Understood  Thank you !!


Title: Re: The questions of Public key,help me !
Post by: odolvlobo on December 28, 2021, 09:06:09 AM
Your questions are not quite clear. I think this is the answer you are looking for: the public key for an address is revealed when bitcoins are sent from that address. The public key is included in the transaction as part of the signature.

Since the public key cannot otherwise be determined from an address (the address is a hash of the public key), a public key may be used to prove that you control the address, but typically that would not be acceptable as proof because the public key is not intended to be kept secret.

I could be wrong, but I don't believe that public keys are stored in a wallet (except for a watch-only wallet perhaps) because they can be derived easily from the private key. On the other hand, a wallet may hold an "extended public key" so that all addresses from a seed can be monitored.


Title: Re: The questions of Public key,help me !
Post by: PawGo on December 28, 2021, 11:26:00 AM

3. If i have the real public key from this wallet.dat, can it prove that the wallet is true rather than a tampered fake wallet file?


I think it is one of the methods used by forged wallets sellers. The need to inject public key into wallet.dat file, so Bitcoin Core shows values from the address which private key does not exists in the wallet. And one way to know public key is to retrieve it from outgoing transactions - if you check wallets offered for sale, almost all of them are for addresses with outgoing transactions.
The trick is that forked Bitcoin Cash uses the same values, so you may have no outgoing Bitcoin transaction, but outgoing BCH transaction and public key is exposed.


Title: Re: The questions of Public key,help me !
Post by: NotATether on December 29, 2021, 04:30:15 AM
2. Does the real public key of this address only exist in the wallet.dat?

The public key of any address can be derived dynamically from the corresponding private key that you saved in a wallet file or anywhere else. The wallet.dat files themselves are not used for blockchain verification and transactions.