def recoverPubkeyParameter(message, digest, signature, pubkey):
if not isinstance(message, bytes):<EOL><INDENT>message = bytes(message, "<STR_LIT:utf-8>")  <EOL><DEDENT>for i in range(<NUM_LIT:0>, <NUM_LIT:4>):<EOL><INDENT>if SECP256K1_MODULE == "<STR_LIT>":  <EOL><INDENT>sig = pubkey.ecdsa_recoverable_deserialize(signature, i)<EOL>p = secp256k1.PublicKey(pubkey.ecdsa_recover(message, sig))<EOL>if p.serialize() == pubkey.serialize():<EOL><INDENT>return i<EOL><DEDENT><DEDENT>elif SECP256K1_MODULE == "<STR_LIT>" and not isinstance(pubkey, PublicKey):<EOL><INDENT>p = recover_public_key(digest, signature, i, message)<EOL>p_comp = hexlify(compressedPubkey(p))<EOL>pubkey_comp = hexlify(compressedPubkey(pubkey))<EOL>if p_comp == pubkey_comp:<EOL><INDENT>return i<EOL><DEDENT><DEDENT>else:  <EOL><INDENT>p = recover_public_key(digest, signature, i)<EOL>p_comp = hexlify(compressedPubkey(p))<EOL>p_string = hexlify(p.to_string())<EOL>if isinstance(pubkey, PublicKey):  <EOL><INDENT>pubkey_string = bytes(repr(pubkey), "<STR_LIT:ascii>")<EOL><DEDENT>else:  <EOL><INDENT>pubkey_string = hexlify(pubkey.to_string())<EOL><DEDENT>if p_string == pubkey_string or p_comp == pubkey_string:  <EOL><INDENT>return i<EOL><DEDENT><DEDENT><DEDENT>
Use to derive a number that allows to easily recover the
        public key from the signature