# ECDSA Signing and verifying signatures between Python and JS [closed]

I create a signature on js, here jsrsasign Signatures are obtained in the format:

3045022045c61e649ca9f6011a8d34ac865c4780421de08ff50ac3dad0da36043b6de478022100b19208d1ec51f6dd6f6b725342618f55f9fc90c96c5b5409998d66774749a0b


Always start with 30 ... In Python, I use the python-ecdsa library. In this library, the signature format is

a8c7dd7e9b669b1bc841ddf66bc08b10bc1112fa14fce2a5a2246edf997c577450af6b9edfe373546e17ab7363c097ab468db04ed707fb65992e20eabfd1bf40


Therefore, verification does not occur. How to bring signatures to one format?

## closed as off-topic by kelalaka, Gilles, Maeher, Maarten Bodewes♦, Ella Rose♦Dec 14 '18 at 18:10

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Programming questions are off-topic even if you are writing or debugging cryptographic code. Unless your question is specifically about how the cryptographic algorithm, protocol or side-channel (mitigation) works, you should look into asking on Stack Overflow instead." – kelalaka, Gilles, Maeher, Maarten Bodewes, Ella Rose
If this question can be reworded to fit the rules in the help center, please edit the question.

## 1 Answer

An ECDSA signature is, formally, a pair of integers $$(r,s)$$. There are two main conventions for encoding these integers into bytes:

• Encode both integers into unsigned big-endian, using the same size for both, and concatenate the values. This is the traditional way in, for instance, PKCS#11 and OpenPGP; python-ecdsa apparently uses that format.

• Encode the integers as an ASN.1/DER structure (a SEQUENCE of two INTEGER values). This is what is normally used in everything that relates to X.509 certificates, and also in SSL/TLS exchanges. jsrsasign apparently uses that format.

Conversion between these formats can be done, but it is surprisingly tricky to do correctly (it's a parser, after all). It seems that python-ecdsa can also encode and decode ASN.1-based signatures (see the functions sigencode_der() and sigdecode_der(), for instance).

• Thx my frend, sloved – Vadim Dec 10 '18 at 11:20