<p>The message signing function in Bitcoin Core uses a different extra compact format for encoding signatures. The algorithm is also intentionally incompatible (through an extra hashing step) with the one used in transactions, to avoid people being tricked into signing a transaction.</p>

CC BY-SA 4.0
2018-08-15T02:40:05.063Z
Does this apply to transaction signatures as well? Is the `openssl` cli unable to sign a transaction sigHash?
JBaczuk
CC BY-SA 3.0
2016-11-12T19:23:03.267Z
2016-11-12T19:23:03.267Z
Pieter Wuille
<p>as a follow up to here:</p>

<p><a href="https://bitcoin.stackexchange.com/questions/46455/verifying-a-bitcoin-trx-on-the-unix-cmd-line-with-openssl">Verifying a bitcoin trx on the Unix cmd line with OpenSSL?</a></p>

<p>and here:</p>

<p><a href="https://bitcoin.stackexchange.com/questions/32305/how-does-the-ecdsa-verification-algorithm-work-during-transaction/32308#32308">How does the ECDSA verification algorithm work during transaction?</a></p>

<p>I use the pizza trx, and verify at the command line (using openssl), that produces expected result. When I want to check in graphical BITCOIN QT 0.13.1 client, s.th. fails. What I did so far:</p>

<p>I have these values in the files:</p>

<pre><code>pizza.sighex
30450221009908144ca6539e09512b9295c8a27050d478fbb96f8addbc3d075544dc41328702201aa528be2b907d316d2da068dd9eb1e23243d97e444d59290d2fddf25269ee0e

pizza.keyhex
3056301006072a8648ce3d020106052b8104000a034200
042e930f39ba62c6534ee98ed20ca98959d34aa9e057cda01cfd422c6bab3667b76426529382c23f42b9b08d7832d4fee1d6b437a8526e59667ce9c4e9dcebcabb

pizza.hash2
c2d48f45d7fbeff644ddb72b0f60df6c275f0943444d7df8cc851b3d55782669
</code></pre>

<p>(Attention: in the original webpage the double hash was given by amaclin in reversed order!)</p>

<pre><code> $ xxd -r -p &lt;pizza.sighex &gt;pizza.sigraw
 $ xxd -r -p &lt;pizza.keyhex | openssl pkey -pubin -inform der &gt;pizza.keypem
 $ xxd -r -p &lt;pizza.hashhex &gt;pizza.hash2
 $ openssl pkeyutl &lt;pizza.hash2 -verify -pubin -inkey pizza.keypem -sigfile pizza.sigraw
</code></pre>

<blockquote>
  <p>--> Signature Verified Successfully</p>
</blockquote>

<p>now try in Bitcoin Core, the uncompressed public key hashes to this Bitcoin address:</p>

<pre><code>17SkEw2md5avVNyYgj6RiXuQKNwkXaxFyQ
</code></pre>

<p>The signature as base64 encoded string:</p>

<pre><code>$ echo 30450221009908144ca6539e09512b9295c8a27050d478fbb96f8addbc3d075544dc41328702201aa528be2b907d316d2da068dd9eb1e23243d97e444d59290d2fddf25269ee0e | base64 -
</code></pre>

<blockquote>
  <p>MzA0NTAyMjEwMDk5MDgxNDRjYTY1MzllMDk1MTJiOTI5NWM4YTI3MDUwZDQ3OGZiYjk2ZjhhZGRiYzNkMDc1NTQ0ZGM0MTMyODcwMjIwMWFhNTI4YmUyYjkwN2QzMTZkMmRhMDY4ZGQ5ZWIxZTIzMjQzZDk3ZTQ0NGQ1OTI5MGQyZmRkZjI1MjY5ZWUwZQo=</p>
</blockquote>

<p>Entered into the QT client, I always get a "Message verification failed". So I try from scratch, I go to the tab "sign message", and enter this:
pubkey hash:</p>

<pre><code>1DHG9SbeW3SXNpvbRUG3txXm1yDZTPKY9X
</code></pre>

<p>hash value:</p>

<pre><code>56cc00a443f7b457ac3ec4bf1cc10ab3fa0c97fb173c27465b35766d313cd18c
</code></pre>

<p>and click "sign", to receive a base64 (?) encoded string:</p>

<pre><code>IKWqGIVDCcpTBgFNushFeOlDj/08B4LEzYl4LDrWLLKnPQrqaSjjFYrdeWGXH9eIgHw7F7bkRtPpwC6jOur+R8k=
</code></pre>

<p>Now I should be able to enter these three values in the verify tab, so I cut and paste them into the fields, and they fail as well. I couldn't find any relevant information on how to use the Bitcoin Core 13.1 client. I am looking for some description or some reference, that explains underlying logic. Any help appreciated :-)</p>

<client><signature>
sign and verify a message in Bitcoin Core 0.13.1 (OSX)?
pebwindkraft
# sign and verify a message in Bitcoin Core 0.13.1 (OSX)?

(Asked by: username_0 on 2016-11-12)

as a follow up to here:

[Verifying a bitcoin trx on the Unix cmd line with OpenSSL?](https://bitcoin.stackexchange.com/questions/46455/verifying-a-bitcoin-trx-on-the-unix-cmd-line-with-openssl)

and here:

[How does the ECDSA verification algorithm work during transaction?](https://bitcoin.stackexchange.com/questions/32305/how-does-the-ecdsa-verification-algorithm-work-during-transaction/32308#32308)

I use the pizza trx, and verify at the command line (using openssl), that produces expected result. When I want to check in graphical BITCOIN QT 0.13.1 client, s.th. fails. What I did so far:

I have these values in the files:

```
pizza.sighex
30450221009908144ca6539e09512b9295c8a27050d478fbb96f8addbc3d075544dc41328702201aa528be2b907d316d2da068dd9eb1e23243d97e444d59290d2fddf25269ee0e

pizza.keyhex
3056301006072a8648ce3d020106052b8104000a034200
042e930f39ba62c6534ee98ed20ca98959d34aa9e057cda01cfd422c6bab3667b76426529382c23f42b9b08d7832d4fee1d6b437a8526e59667ce9c4e9dcebcabb

pizza.hash2
c2d48f45d7fbeff644ddb72b0f60df6c275f0943444d7df8cc851b3d55782669

```

(Attention: in the original webpage the double hash was given by amaclin in reversed order!)

```
 $ xxd -r -p <pizza.sighex >pizza.sigraw
 $ xxd -r -p <pizza.keyhex | openssl pkey -pubin -inform der >pizza.keypem
 $ xxd -r -p <pizza.hashhex >pizza.hash2
 $ openssl pkeyutl <pizza.hash2 -verify -pubin -inkey pizza.keypem -sigfile pizza.sigraw

```

> --> Signature Verified Successfully

now try in Bitcoin Core, the uncompressed public key hashes to this Bitcoin address:

```
17SkEw2md5avVNyYgj6RiXuQKNwkXaxFyQ

```

The signature as base64 encoded string:

```
$ echo 30450221009908144ca6539e09512b9295c8a27050d478fbb96f8addbc3d075544dc41328702201aa528be2b907d316d2da068dd9eb1e23243d97e444d59290d2fddf25269ee0e | base64 -

```

> MzA0NTAyMjEwMDk5MDgxNDRjYTY1MzllMDk1MTJiOTI5NWM4YTI3MDUwZDQ3OGZiYjk2ZjhhZGRiYzNkMDc1NTQ0ZGM0MTMyODcwMjIwMWFhNTI4YmUyYjkwN2QzMTZkMmRhMDY4ZGQ5ZWIxZTIzMjQzZDk3ZTQ0NGQ1OTI5MGQyZmRkZjI1MjY5ZWUwZQo=

Entered into the QT client, I always get a "Message verification failed". So I try from scratch, I go to the tab "sign message", and enter this:
pubkey hash:

```
1DHG9SbeW3SXNpvbRUG3txXm1yDZTPKY9X

```

hash value:

```
56cc00a443f7b457ac3ec4bf1cc10ab3fa0c97fb173c27465b35766d313cd18c

```

and click "sign", to receive a base64 (?) encoded string:

```
IKWqGIVDCcpTBgFNushFeOlDj/08B4LEzYl4LDrWLLKnPQrqaSjjFYrdeWGXH9eIgHw7F7bkRtPpwC6jOur+R8k=

```

Now I should be able to enter these three values in the verify tab, so I cut and paste them into the fields, and they fail as well. I couldn't find any relevant information on how to use the Bitcoin Core 13.1 client. I am looking for some description or some reference, that explains underlying logic. Any help appreciated :-)

**Tags:** client, signature


---

## 1 answers

### Answer by username_1 on 2016-11-12. Score: 0 | Accepted answer

The message signing function in Bitcoin Core uses a different extra compact format for encoding signatures. The algorithm is also intentionally incompatible (through an extra hashing step) with the one used in transactions, to avoid people being tricked into signing a transaction.

> **Comments:**
> **username_2**: Does this apply to transaction signatures as well? Is the `openssl` cli unable to sign a transaction sigHash?  

---

