SSL Pinning security: can MitM generate the same public key? This is a very newbie question.
SSL Pinning is &quot;safe&quot; in assumption that only the real server can decrypt the public key.
By design, it should be almost impossible to find the private key from the public key.
However, is it relatively easy to create a new certificate (private key) that generates the &quot;same&quot; public key which the SSL Pinning trusts?
In order words, how hard is to create a new private key that generates the public key &quot;I want&quot;.
For example, if I want to create a new certificate which the public key is:
sha256/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=
Can I easily do that?
It's astonishingly difficult.

With RSA, it's literally a mathematical impossibility.

With Weierstrass, Montgomery and Edwards elliptic curves, the possibility of generating the same public key from different private key should be impossible assuming the private key scalar value doesn't overflow the order of the generator of the group.

With Hash-based digital signatures, this may be possible, because the public key is the tree hash of many one-time hash signature public keys. But still, finding such public key collision is as difficult as finding any regular hash collision. (not to mention real-world hash signatures often use randomized hashing).

Lattice-based schemes have the mathematical possibility of generating colliding public keys if the public component reduces the dimension of the private component, but that's very improbable. However, it should be noted, even the public component are randomly generated in most candidate schemes in NIST Post-Quantum Cryptography Project.