Backport of core#22089.
Instead of the retry loop to get a fixed DER signature size, we could use the Schnorr signatures which are fixed size.
However the only test that uses the P2PK mode so far is the DER signature test, and using schnorr would invalidate the test.