1

I am using the bicoinjs-message npm module for signature verification.

I learned that there are few signatures which are of length 138 in hexadecimal.
When I tried to verify such a signature it is throwing an error:

Error: Invalid signature length

How to verify the compressed signature?
I think there is a lib in ruby, bitcoin-ruby 0.0.20, which verifies it, but I don't know ruby.

0

If you have the bitcoin core software, you should be able to use the CLI to verify signatures using the verifymessage command. Some wallet software also has this functionality.

0

There are no compressed signatures. Bitcoin uses two different formats (encodings) for signatures:

  • transaction signatures use the ASN.1 DER encoding, which is variable length depending on the curve and was common when Satoshi published, and adds a 'sighash' byte. For secp256k1 in general, DER(ECDSA-Sig) is usually 72-70 bytes and sometimes but rarely less, but modern bitcoin requires 'low-S' signatures which reduces the maximum to 71. A 69-byte (138-hexit) signature excluding sighash would occur about 3/512 (about one-half a percent) of the time; that length including sighash would be much rarer.

  • message signatures use the P1363 encoding, also called 'plain', 'PKCS11', or 'CVC', which for secp256k1 is always exactly 64 bytes, and adds a recovery byte for a total of 65 (always). It also addes a prefix to the signed data, which changes the value(s) but not the format of the signature.

See e.g.:
Why the signature is always 65 (1+32+32) bytes long?
ECDSA r, s encoding as a signature
Difference between Sign Message and Sign Transaction

Though I haven't looked at it, I expect a library named bitcoinjs-message likely handles signatures for messages not transactions, and any signature that is 69 bytes cannot be a message signature.

2
  • Actually, there is a bitcoin-ruby library in ruby. This lib generates the 138 length message signature. – Shubham Chadokar Aug 12 '20 at 11:08
  • 1
    A bitcoin message signature cannot ever be '138 length'. Not ever in the entire lifetime of the universe. Something named 'bitcoin-ruby' probably handles transactions, which are the original, core, and main function and purpose of bitcoin -- messages are rare and nearly useless. – dave_thompson_085 Aug 14 '20 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.