<p>There are no compressed signatures. Bitcoin uses two different formats (encodings) for signatures:</p>
<ul>
<li><p><em>transaction</em> 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 <em>usually</em> 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 <em>excluding</em> sighash would occur about 3/512 (about one-half a percent) of the time; that length <em>including</em> sighash would be much rarer.</p>
</li>
<li><p><em>message</em> 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.</p>
</li>
</ul>
<p>See e.g.:<br />
<a href="https://bitcoin.stackexchange.com/questions/12554/why-the-signature-is-always-65-13232-bytes-long">Why the signature is always 65 (1+32+32) bytes long?</a><br />
<a href="https://bitcoin.stackexchange.com/questions/2376/ecdsa-r-s-encoding-as-a-signature">ECDSA r, s encoding as a signature</a><br />
<a href="https://bitcoin.stackexchange.com/questions/90799/difference-between-sign-message-and-sign-transaction">Difference between Sign Message and Sign Transaction</a></p>
<p>Though I haven't looked at it, I expect a library named <code>bitcoinjs-message</code> likely handles signatures for messages not transactions, and any signature that is 69 bytes cannot be a message signature.</p>

CC BY-SA 4.0
2020-08-12T11:08:27.880Z
Actually, there is a bitcoin-ruby library in ruby. This lib generates the 138 length message signature.
Shubham Chadokar
CC BY-SA 4.0
2020-08-14T07:59:47.763Z
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
CC BY-SA 4.0
2020-08-12T05:40:30.370Z
2020-08-12T05:40:30.370Z
dave_thompson_085
<p>If you have the bitcoin core software, you should be able to use the CLI to verify signatures using the <code>verifymessage</code> command. Some wallet software also has this functionality.</p>

CC BY-SA 4.0
2020-08-11T18:03:10.700Z
2020-08-11T18:03:10.700Z
Sachin Meier
<p>I am using the <code>bicoinjs-message</code> npm module for signature verification.</p>
<p>I learned that there are few signatures which are of length 138 in hexadecimal.<br />
When I tried to verify such a signature it is throwing an error:</p>
<blockquote>
<p>Error: Invalid signature length</p>
</blockquote>
<p>How to verify the compressed signature?<br />
I think there is a lib in ruby, <a href="https://rubygems.org/gems/bitcoin-ruby/versions/0.0.20" rel="nofollow noreferrer">bitcoin-ruby 0.0.20</a>, which verifies it, but I don't know ruby.</p>

<bitcore><bitcoinjs><node.js><ruby>
How to verify the compressed signature in Bitcoin? It is 138 long in hex
Shubham Chadokar
# How to verify the compressed signature in Bitcoin? It is 138 long in hex

(Asked by: username_0 on 2020-08-06)

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](https://rubygems.org/gems/bitcoin-ruby/versions/0.0.20), which verifies it, but I don't know ruby.

**Tags:** bitcore, bitcoinjs, node.js, ruby


---

## 2 answers

### Answer by username_1 on 2020-08-12. Score: 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?](https://bitcoin.stackexchange.com/questions/12554/why-the-signature-is-always-65-13232-bytes-long)  
[ECDSA r, s encoding as a signature](https://bitcoin.stackexchange.com/questions/2376/ecdsa-r-s-encoding-as-a-signature)  
[Difference between Sign Message and Sign Transaction](https://bitcoin.stackexchange.com/questions/90799/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.

> **Comments:**
> **username_0**: Actually, there is a bitcoin-ruby library in ruby. This lib generates the 138 length message signature.  
> **username_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.  

---

### Answer by username_2 on 2020-08-11. Score: 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.


---

