Bitcoin
transaction – How to convert a signature to DER encoded format in Python
vk = ecdsa.VerifyingKey.from_string(bytes.fromhex(pubKey),curve=ecdsa.SECP256k1)
if vk.verify(bytes.fromhex(signature), bytes.fromhex(sha256_hash), hashlib.sha256, sigdecode=sigdecode_der) == True: # True
print("Signature is Valid")
else:
print("Signature is not Valid")
I’m trying to verify a transaction using secp256k1_generator, but I can’t get the signature in the correct (r,s) format and I get the following output:
File "/.local/lib/python3.10/site-packages/ecdsa/keys.py", line 741, in verify_digest
raise BadSignatureError("Signature verification failed")
ecdsa.keys.BadSignatureError: Signature verification failed
We took the help of signature verification in Python using compressed public keys.
https://stackoverflow.com/questions/73630540/how-to-verify-ecdsa-signatures-with-python but I still get this error. How can I solve this?