How to convert signature to DER encoded format in python

on

|

views

and

comments


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 am trying to verify a transaction using secp256k1_generator, but I can’t seem to get the signature into the correct (r,s) format, and am getting 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

I have taken help of Signature verification in python using compressed public key
and

https://stackoverflow.com/questions/73630540/how-to-verify-ecdsa-signatures-with-python
But still I am getting this error. How can I resolve it?

Share this
Tags

Must-read

The Great Bitcoin Crash of 2024

Bitcoin Crash The cryptocurrency world faced the hell of early 2024 when the most popular Bitcoin crashed by over 80% in a matter of weeks,...

Bitcoin Gambling: A comprehensive guide in 2024

Bitcoin Gambling With online currencies rapidly gaining traditional acceptance, the intriguing convergence of the crypto-trek and gambling industries is taking place. Cryptocurrency gambling, which started...

The Rise of Bitcoin Extractor: A comprehensive guide 2024

Bitcoin Extractor  Crypto mining is resources-thirsty with investors in mining hardware and those investing in the resources needed as the main beneficiaries. In this sense,...

Recent articles

More like this