ecdsa nonce reuse to compute the private key, modular inverse question
You are looking for the modular inverse of $r$
By Euler's Theorem
$$a^{\phi(m)} \equiv 1 \pmod{m}$$
Then
$$a^{\phi(m)-1} \equiv a^{-1} \pmod{m}$$
Now, for a prime $p$, $\phi(p) = p-1$ then we have
$$a^{p-2} \equiv a^{-1} \pmod{p}$$

Note 1: The multiplicative group $\mathbb{Z}^*_p$ contains $p-1$ elements, the zero is not included.
Note 2: Not all elements of $\mathbb{Z}_m$ has multiplicative inverse. To have one, $x \in \{1,\ldots,m-1\}$ we must have $\gcd(m,x)=1$
Note 3: The order of Secp256k1 is prime.