From doc comment above secp256k1_ecdsa_recover:
Returns: 1: public key successfully recovered (which guarantees a correct signature). 0: otherwise.
target_pubkey = ec_pubkey_create(seckey)
msghash32 = hashlib.sha256(b"secret msg").digest()
rec_sig = ecdsa_sign_recoverable(seckey, msghash32)
# instead of correct message - random bytes are provided
recovered_pubkey = ecdsa_recover(rec_sig, os.urandom(32)) # this returns 1 even if message is not the thing that was signed
# recovered pubkey is incorrect
self.assertEqual(recovered_pubkey.raw, target_pubkey.raw) # raises do NOT equal
I would expect ecdsa_recover to fail if message is incorrect. Recovered pubkey is also incorrect. Instead ecdsa_recover returns 1 which seems to contradict with documentation. But maybe I'm missing something ?