bitcoinjs / tiny-secp256k1

A tiny secp256k1 native/JS wrapper
MIT License
92 stars 55 forks source link

signature might not be 64 bytes #33

Closed notatestuser closed 5 years ago

notatestuser commented 5 years ago

Why is this assertion made in verify?

https://github.com/bitcoinjs/tiny-secp256k1/blob/29ca6ed28a1b9ba75f515451dc5f62c8bf334ec5/js.js#L67

In this example, the signature <r,s> is 65 bytes, where s is 33 bytes: https://bitcoin.stackexchange.com/a/34049

junderw commented 5 years ago

The link you provided is parsing a signature in DER format.

This library does not use DER format. r and s will always be 32 bytes in this format.

In the DER format, the only time r or s will be 33 bytes will have the first byte as 0x00 for padding. So the format we use does not use or require that padding.

Please let me know if you have other questions.

notatestuser commented 5 years ago

Thanks for the explanation!