For a signature done using a private key, we know that the corresponding public key is needed to verify. When the address is a one way hash function of the public key (which means from the address, it is infeasible to compute the public key directly), how does the public key recovery methods find the public key from the signers address, transaction message details including the digital signature? Is there a mapping between the addresses and the corresponding public keys from where the methods recover the public key or a service? Can someone show and explain.
How do the public key recovery methods like secp256k1.RecoverPubkey(msg, sig) recover public key from a transaction signature
Both the unencrypted data and the signed data are received. With those two things the public key can be figured out, and then the sender's address from the public key.
I guess this is a cryptography question, so crypto.stackexchange.com is it's natural home.
The crypto.stackexchange.com link points to another problem and solution on identifying the public key from M and its signature for specific Public Key algorithms if many such pairs of M || DS[m] are available. I will post the answer that i figured out shortly. Thanks.– thiruJul 16, 2022 at 14:03
My earlier assumption (which is incorrect), based on which i posted the question was that, the signed transaction does not contain the public key. But I found out that in the bitcoin context every signed transaction comes with an Unlocking Script (scriptSig) which contains both signature and public key . Since public key is available in the transaction block itself, signature can be directly verified from that. In other contexts like in ethereum addressed below, where it is not directly there in the transaction the platform fetches it through a method. It is clear now that the signer's public key is provided by the signer to the miner for verification.
In the Ethereum context following is the way verification is done: "ECDSA signatures in Ethereum consist of three parameters r, s, and v. Solidity provides a globally available method ecrecover that returns an address given these three parameters. If the returned address is the same as the signer’s address, then the signature is valid.
Signatures produced by web3.js are the concatenation of r, s, and v, so a necessary first step is splitting those parameters back out.
Both smart contracts and Ethereum clients have the ability to verify ECDSA signatures." - For more details refer to the source of the above quote: https://yos.io/2018/11/16/ethereum-signatures/
The ECDSA can be used in two ways 1/ to verify the signature given the message and the public key, 2/ to derive the public key given the signature and the message. In the wikipedia article you have more details en.wikipedia.org/wiki/….– Ismael ♦Jul 17, 2022 at 2:37