It is possible to recover the public key from an ECDSA signature values $(r,s)$?
Please explain how this works.
Actually, it is not possible to uniquely recover the public key from an ECDSA signature $(r,s)$. This remains true even if we also assume you know the curve, the hash function used, and you also have the message that was signed.
However, with the signature and the message that was signed, and the knowledge of the curve, it is possible to generate two public keys; one of which will be the public key corresponding to the private key used.
Here's how that works:
First, you find the two points $R$, $R'$ which have the value $r$ as the x-coordinate $r$.
You also compute $r^{-1}$, which is the multiplicative inverse of the value $r$ from the signature (modulo the order of the generator of the curve).
Then, you compute $z$ which is the lowest $n$ bits of the hash of the message (where $n$ is the bit size of the curve).
Then, the two public keys are $r^{-1}(sR - zG)$ and $r^{-1}(sR' - zG)$
It is easy to verify that if you plug either of these values in the ECDSA signature routines as the public keys, the signature validates.
As @poncho says, both keys $Q_1=r^{-1}(sR-zG)$ and $Q_2=r^{-1}(sR'-zG)$ will validate the given signature, i.e., $(s^{-1}zG+s^{-1}rQ_i)_x=r\mod{n}$. For some curves, with small but non-zero probability, we have $n\leq(kG)_x<p$, and neither $Q_1$ nor $Q_2$ will validate other signatures made with the original private key $d$. However, by Hasse's theorem, with high probability $1-O(1/\sqrt{p})$ we have $0\leq(kG)_x<n$. In this case either $R=kG$ or $R'=kG$, so, correspondingly, $Q_1$ or $Q_2$ equals the original public key $Q=dG$.
It is well-known that one can recover the ECDSA public key used from a valid ECDSA signature on a known message, cf. Section 4.6 of https://www.secg.org/sec1-v2.pdf.