<p>You've used the wrong key to sign the first input. You are using the private key for the second input in the first input, so you are getting a different signature. Using the correct key for the first input, I get the same signature as Electrum does. If I use the key for the second input, I get the signature that you got.</p>

<p>Also, just an FYI, you've constructed your first input incorrectly in your final transaction. You have the second input's signature in the first input.</p>

<hr>

<p>Specifically:</p>

<p>The private key for input 1 is </p>

<pre><code>2f6a4ea2eb8fdfbfd33008b767b4b7b86f2421278c5c1e4dd03353a080b956bb
</code></pre>

<p>Using this to sign the message digest of </p>

<pre><code>65396c41a751254177c73c26f30c25ea4a683de0977acccec5e61d89473ed7d8
</code></pre>

<p>results in the signature </p>

<pre><code>304402201979b4849549868208a9098a75e78ef34bef3f17d57d032844fd48ce1fbfeff4022001129ec9fa472bb7be4a466f4bd49d127195618f7d25211506d15653f642258f
</code></pre>

<p>which is the signature that Electrum made for input 1.</p>

<p>The private key for input 2 is</p>

<pre><code>ae953391f394b83f796dafe29bf2820fc1e91038bea100971465499a9d0be96f
</code></pre>

<p>Using that private key to sign the same message digest, I get the signature</p>

<pre><code>3045022100ca92cfde70a674377c2e3cfcc46031ee50103e5036b7890930c3e1fa924105c7022021a71ad5121d7b84f9dd14900ab836bd36ab7959483fe9c6d4dcab7a1a152b77
</code></pre>

<p>which is the signature that you got for input 1.</p>

<p>Therefore, you have mistakenly used the private key for input 2 to sign input 1.</p>

CC BY-SA 4.0
2019-12-23T04:47:46.747Z
thanks for your reply.. can you describe in detail, so that i can correct my mistake.
Amish Sharma
CC BY-SA 4.0
2019-12-23T15:29:24.020Z
I've updated my answer.
Ava Chow
CC BY-SA 4.0
2019-12-22T22:54:26.620Z
2019-12-23T15:29:18.300Z
2019-12-23T15:29:18.300Z
Ava Chow
<p>(For Bitcoin TestNet Only)</p>

<p>I am working on Signed Transaction which consists More than One Inputs and More than One Outputs (Unsigned HEX Data).</p>

<p>after that i have generated two DER Signature of both Inputs.
But First input DER Signature is not Right, where as Second Input DER Signature is Right.</p>

<p>This is Serialized Data for Input 1 and Address Node:
0200000002103f960104b258426cf61dac8d8287cc993efd56f2ad0ebe8d279d71a3998343000000001976a9145ecef50c9b41f9714c3aa9c8198a45355e55480688acfdffffff103f960104b258426cf61dac8d8287cc993efd56f2ad0ebe8d279d71a39983430100000000fdffffff02d1d10000000000001976a9142be8cc719306b87e23bc9f1478cb77440adac44288ac60182300000000001976a9141d71b20b5123b6a559693e8ad871015a9a19947d88ac26ec180001000000</p>

<p>Chain Code : b6e74e646730dc4a0d00006e648322325d21f9ffcc182ac7f41dc6a8bc327f50</p>

<p>Private Key : 2f6a4ea2eb8fdfbfd33008b767b4b7b86f2421278c5c1e4dd03353a080b956bb</p>

<p>Public Key : 02f8419833c76c016478a2d3f10ee9399c3c2c0af301e616ff54581cd7ee344d8b
strSHA256Digest_SerializeData [0]: 65396c41a751254177c73c26f30c25ea4a683de0977acccec5e61d89473ed7d8</p>

<p>Signed Message [0]: ca92cfde70a674377c2e3cfcc46031ee50103e5036b7890930c3e1fa924105c721a71ad5121d7b84f9dd14900ab836bd36ab7959483fe9c6d4dcab7a1a152b77</p>

<p>DER Signature Message [0] (Message Size :71) : 3045022100ca92cfde70a674377c2e3cfcc46031ee50103e5036b7890930c3e1fa924105c7022021a71ad5121d7b84f9dd14900ab836bd36ab7959483fe9c6d4dcab7a1a152b77</p>

<h1>================================================================</h1>

<p>This is Serialized Data for Input 2 and address Node:
0200000002103f960104b258426cf61dac8d8287cc993efd56f2ad0ebe8d279d71a39983430000000000fdffffff103f960104b258426cf61dac8d8287cc993efd56f2ad0ebe8d279d71a3998343010000001976a914c4c6b6dc0e7d63a2441d89df9e088a8b1e06655f88acfdffffff02d1d10000000000001976a9142be8cc719306b87e23bc9f1478cb77440adac44288ac60182300000000001976a9141d71b20b5123b6a559693e8ad871015a9a19947d88ac26ec180001000000</p>

<p>Chain Code : 1d2580001e84096d110da4bb2617d93f8210b06163410660ee4b5f7330b849ef</p>

<p>Private Key : ae953391f394b83f796dafe29bf2820fc1e91038bea100971465499a9d0be96f</p>

<p>Public Key : 035ad36065a1dd8a74dc473c651cac1c34af6431f6457c634c73bece96522d454f</p>

<p>strSHA256Digest_SerializeData [1]: 3727266237d36b57fb5c343dc0bca40a925072c94947e41b118006983af6efe6</p>

<p>Signed Message [1]: 727937a941b405c4bb3652037b21c5c34714391f30348f8504ca06ea08642fa76509af604cbfcbce6127ae2f94bd7a15b1fc72907409354ae2bc3bb4074c83aa</p>

<p>DER Signature Message [1] (Message Size :70) : 30440220727937a941b405c4bb3652037b21c5c34714391f30348f8504ca06ea08642fa702206509af604cbfcbce6127ae2f94bd7a15b1fc72907409354ae2bc3bb4074c83aa</p>

<h1>================================================================</h1>

<p>This is Final Outcome Signed Data (From My code) : 0200000002103f960104b258426cf61dac8d8287cc993efd56f2ad0ebe8d279d71a3998343000000006a4730440220727937a941b405c4bb3652037b21c5c34714391f30348f8504ca06ea08642fa702206509af604cbfcbce6127ae2f94bd7a15b1fc72907409354ae2bc3bb4074c83aa77012102f8419833c76c016478a2d3f10ee9399c3c2c0af301e616ff54581cd7ee344dfdffffff103f960104b258426cf61dac8d8287cc993efd56f2ad0ebe8d279d71a3998343010000006a4730440220727937a941b405c4bb3652037b21c5c34714391f30348f8504ca06ea08642fa702206509af604cbfcbce6127ae2f94bd7a15b1fc72907409354ae2bc3bb4074c83aa0121035ad36065a1dd8a74dc473c651cac1c34af6431f6457c634c73bece96522d454ffdffffff02d1d10000000000001976a9142be8cc719306b87e23bc9f1478cb77440adac44288ac60182300000000001976a9141d71b20b5123b6a559693e8ad871015a9a19947d88ac26ec1800</p>

<p>And This is Electrum Signed Data :
0200000002103f960104b258426cf61dac8d8287cc993efd56f2ad0ebe8d279d71a3998343000000006a47304402201979b4849549868208a9098a75e78ef34bef3f17d57d032844fd48ce1fbfeff4022001129ec9fa472bb7be4a466f4bd49d127195618f7d25211506d15653f642258f012102f8419833c76c016478a2d3f10ee9399c3c2c0af301e616ff54581cd7ee344d8bfdffffff103f960104b258426cf61dac8d8287cc993efd56f2ad0ebe8d279d71a3998343010000006a4730440220727937a941b405c4bb3652037b21c5c34714391f30348f8504ca06ea08642fa702206509af604cbfcbce6127ae2f94bd7a15b1fc72907409354ae2bc3bb4074c83aa0121035ad36065a1dd8a74dc473c651cac1c34af6431f6457c634c73bece96522d454ffdffffff02d1d10000000000001976a9142be8cc719306b87e23bc9f1478cb77440adac44288ac60182300000000001976a9141d71b20b5123b6a559693e8ad871015a9a19947d88ac26ec1800</p>

<h1>================================================================</h1>

<p>The Only difference between Above Two Signed Message is DER Signature of Input 1 :</p>

<p>DER Signature of Input 1 (My Code) :
4730440220727937a941b405c4bb3652037b21c5c34714391f30348f8504ca06ea08642fa702206509af604cbfcbce6127ae2f94bd7a15b1fc72907409354ae2bc3bb4074c83aa</p>

<p>DER Signature of Input 1 (Electrum) :
47304402201979b4849549868208a9098a75e78ef34bef3f17d57d032844fd48ce1fbfeff4022001129ec9fa472bb7be4a466f4bd49d127195618f7d25211506d15653f642258f</p>

<p>Please Suggest,
1. Please let us know if i am doing anything wrong ?
2. Why DER Signature of Input1 is different ? even if DER signature of Input2 is fine with the same logic .</p>

<transactions><multi-signature><signature>
Query Reagrding DER Signature
Amish Sharma
# Query Reagrding DER Signature

(Asked by: username_0 on 2019-12-22)

(For Bitcoin TestNet Only)

I am working on Signed Transaction which consists More than One Inputs and More than One Outputs (Unsigned HEX Data).

after that i have generated two DER Signature of both Inputs.
But First input DER Signature is not Right, where as Second Input DER Signature is Right.

This is Serialized Data for Input 1 and Address Node:
0200000002103f960104b258426cf61dac8d8287cc993efd56f2ad0ebe8d279d71a3998343000000001976a9145ecef50c9b41f9714c3aa9c8198a45355e55480688acfdffffff103f960104b258426cf61dac8d8287cc993efd56f2ad0ebe8d279d71a39983430100000000fdffffff02d1d10000000000001976a9142be8cc719306b87e23bc9f1478cb77440adac44288ac60182300000000001976a9141d71b20b5123b6a559693e8ad871015a9a19947d88ac26ec180001000000

Chain Code : b6e74e646730dc4a0d00006e648322325d21f9ffcc182ac7f41dc6a8bc327f50

Private Key : 2f6a4ea2eb8fdfbfd33008b767b4b7b86f2421278c5c1e4dd03353a080b956bb

Public Key : 02f8419833c76c016478a2d3f10ee9399c3c2c0af301e616ff54581cd7ee344d8b
strSHA256Digest\_SerializeData [0]: 65396c41a751254177c73c26f30c25ea4a683de0977acccec5e61d89473ed7d8

Signed Message [0]: ca92cfde70a674377c2e3cfcc46031ee50103e5036b7890930c3e1fa924105c721a71ad5121d7b84f9dd14900ab836bd36ab7959483fe9c6d4dcab7a1a152b77

DER Signature Message [0] (Message Size :71) : 3045022100ca92cfde70a674377c2e3cfcc46031ee50103e5036b7890930c3e1fa924105c7022021a71ad5121d7b84f9dd14900ab836bd36ab7959483fe9c6d4dcab7a1a152b77

# ================================================================

This is Serialized Data for Input 2 and address Node:
0200000002103f960104b258426cf61dac8d8287cc993efd56f2ad0ebe8d279d71a39983430000000000fdffffff103f960104b258426cf61dac8d8287cc993efd56f2ad0ebe8d279d71a3998343010000001976a914c4c6b6dc0e7d63a2441d89df9e088a8b1e06655f88acfdffffff02d1d10000000000001976a9142be8cc719306b87e23bc9f1478cb77440adac44288ac60182300000000001976a9141d71b20b5123b6a559693e8ad871015a9a19947d88ac26ec180001000000

Chain Code : 1d2580001e84096d110da4bb2617d93f8210b06163410660ee4b5f7330b849ef

Private Key : ae953391f394b83f796dafe29bf2820fc1e91038bea100971465499a9d0be96f

Public Key : 035ad36065a1dd8a74dc473c651cac1c34af6431f6457c634c73bece96522d454f

strSHA256Digest\_SerializeData [1]: 3727266237d36b57fb5c343dc0bca40a925072c94947e41b118006983af6efe6

Signed Message [1]: 727937a941b405c4bb3652037b21c5c34714391f30348f8504ca06ea08642fa76509af604cbfcbce6127ae2f94bd7a15b1fc72907409354ae2bc3bb4074c83aa

DER Signature Message [1] (Message Size :70) : 30440220727937a941b405c4bb3652037b21c5c34714391f30348f8504ca06ea08642fa702206509af604cbfcbce6127ae2f94bd7a15b1fc72907409354ae2bc3bb4074c83aa

# ================================================================

This is Final Outcome Signed Data (From My code) : 0200000002103f960104b258426cf61dac8d8287cc993efd56f2ad0ebe8d279d71a3998343000000006a4730440220727937a941b405c4bb3652037b21c5c34714391f30348f8504ca06ea08642fa702206509af604cbfcbce6127ae2f94bd7a15b1fc72907409354ae2bc3bb4074c83aa77012102f8419833c76c016478a2d3f10ee9399c3c2c0af301e616ff54581cd7ee344dfdffffff103f960104b258426cf61dac8d8287cc993efd56f2ad0ebe8d279d71a3998343010000006a4730440220727937a941b405c4bb3652037b21c5c34714391f30348f8504ca06ea08642fa702206509af604cbfcbce6127ae2f94bd7a15b1fc72907409354ae2bc3bb4074c83aa0121035ad36065a1dd8a74dc473c651cac1c34af6431f6457c634c73bece96522d454ffdffffff02d1d10000000000001976a9142be8cc719306b87e23bc9f1478cb77440adac44288ac60182300000000001976a9141d71b20b5123b6a559693e8ad871015a9a19947d88ac26ec1800

And This is Electrum Signed Data :
0200000002103f960104b258426cf61dac8d8287cc993efd56f2ad0ebe8d279d71a3998343000000006a47304402201979b4849549868208a9098a75e78ef34bef3f17d57d032844fd48ce1fbfeff4022001129ec9fa472bb7be4a466f4bd49d127195618f7d25211506d15653f642258f012102f8419833c76c016478a2d3f10ee9399c3c2c0af301e616ff54581cd7ee344d8bfdffffff103f960104b258426cf61dac8d8287cc993efd56f2ad0ebe8d279d71a3998343010000006a4730440220727937a941b405c4bb3652037b21c5c34714391f30348f8504ca06ea08642fa702206509af604cbfcbce6127ae2f94bd7a15b1fc72907409354ae2bc3bb4074c83aa0121035ad36065a1dd8a74dc473c651cac1c34af6431f6457c634c73bece96522d454ffdffffff02d1d10000000000001976a9142be8cc719306b87e23bc9f1478cb77440adac44288ac60182300000000001976a9141d71b20b5123b6a559693e8ad871015a9a19947d88ac26ec1800

# ================================================================

The Only difference between Above Two Signed Message is DER Signature of Input 1 :

DER Signature of Input 1 (My Code) :
4730440220727937a941b405c4bb3652037b21c5c34714391f30348f8504ca06ea08642fa702206509af604cbfcbce6127ae2f94bd7a15b1fc72907409354ae2bc3bb4074c83aa

DER Signature of Input 1 (Electrum) :
47304402201979b4849549868208a9098a75e78ef34bef3f17d57d032844fd48ce1fbfeff4022001129ec9fa472bb7be4a466f4bd49d127195618f7d25211506d15653f642258f

Please Suggest,
1. Please let us know if i am doing anything wrong ?
2. Why DER Signature of Input1 is different ? even if DER signature of Input2 is fine with the same logic .

**Tags:** transactions, multi-signature, signature


---

## 1 answers

### Answer by username_1 on 2019-12-22. Score: 1

You've used the wrong key to sign the first input. You are using the private key for the second input in the first input, so you are getting a different signature. Using the correct key for the first input, I get the same signature as Electrum does. If I use the key for the second input, I get the signature that you got.

Also, just an FYI, you've constructed your first input incorrectly in your final transaction. You have the second input's signature in the first input.

---

Specifically:

The private key for input 1 is

```
2f6a4ea2eb8fdfbfd33008b767b4b7b86f2421278c5c1e4dd03353a080b956bb

```

Using this to sign the message digest of

```
65396c41a751254177c73c26f30c25ea4a683de0977acccec5e61d89473ed7d8

```

results in the signature

```
304402201979b4849549868208a9098a75e78ef34bef3f17d57d032844fd48ce1fbfeff4022001129ec9fa472bb7be4a466f4bd49d127195618f7d25211506d15653f642258f

```

which is the signature that Electrum made for input 1.

The private key for input 2 is

```
ae953391f394b83f796dafe29bf2820fc1e91038bea100971465499a9d0be96f

```

Using that private key to sign the same message digest, I get the signature

```
3045022100ca92cfde70a674377c2e3cfcc46031ee50103e5036b7890930c3e1fa924105c7022021a71ad5121d7b84f9dd14900ab836bd36ab7959483fe9c6d4dcab7a1a152b77

```

which is the signature that you got for input 1.

Therefore, you have mistakenly used the private key for input 2 to sign input 1.

> **Comments:**
> **username_0**: thanks for your reply.. can you describe in detail, so that i can correct my mistake.  
> **username_1**: I've updated my answer.  

---

