I am new to bitcoin and I am trying to understand Pay-to-Public-Key-Hash (P2PKH) from the book: Mastering Bitcoin: Unlocking Digital Cryptocurrencies (p. 127). I understand that digital keys (which are derived from private-keys) are not actually stored in the network, but are instead stored by users in a wallet.
For example: Alice wants to send Bob 1-BTC:
---------------------------------------------------------
| Sender: Hash(alice-public-key) |
| Receiver: Hash(bob-public-key) |
| Amount: 1-BTC |
| Signature: Hash(Encrypt_{alice-private-key}(Message)) |
---------------------------------------------------------
Question:
- So how can we verify this transaction is valid without having the public-key?
- If we attach the public-key with the message then why spending time finding hash of public-key in the first place?
- Are we storing the public keys in some centralized database?
- If the recipient provides the public-key and verifies the transaction is valid how can others validate that was a valid transaction?