When a block is being processed by the miner he has to verify the signature by using the public key. How does the miner know about this public key? Is it included in the block data?
1 Answer
The miner searches for a hash that is a valid solution to the mining puzzle at the current difficulty level. The mining software trusts whatever node it is told to trust by the person that runs the mining software. If the miner is being sent invalid blocks with invalid transactions, the miner won't notice, because it's not the job of the miner to validate blocks. That's the job of the node. If the miner finds a solution and broadcasts the solved block back to other nodes, those other nodes will ignore that block if it is invalid.
Transactions contain the public keys of the outputs created in those transactions. The transactions contain "inputs", which are references to the public keys of outputs that were created by prior transactions.
Therefore the node looks up a database it keeps of outputs created via previously mined transactions to know the public keys that need to be checked as part of the transaction validation process. These newly received and validated transactions are pulled into a block template by a miner which will attempt to solve the mining puzzle, and if successful will then broadcast the solved block to the world via the node it is connected to.