Bitcoin Forum
June 22, 2024, 01:20:14 PM *
News: Voting for pizza day contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin pushTx fail - Non-canonical signature  (Read 1115 times)
simm19 (OP)
Newbie
*
Offline Offline

Activity: 1
Merit: 0


View Profile
February 07, 2016, 06:05:42 PM
 #1

Hello, we're trying to develop a way to push bitcoin transactions from scratch using the lib bitcoin.js

We've managed to successfully push some transactions, however some are failling, resulting on a blockchain.io error : "Non-canonical signature: High S Value"
Can someone explain what this error means ?

I paste here one of the failing decoded transactions :

{
  "txid": "a700ba0a3f3b0fb046b95f4666e174adda3b3eb66f99028eee4103ad3a2e98d1",
  "version": 1,
  "locktime": 0,
  "vin": [
    {
      "txid": "4e98b0ba546a793db68077759652a1640e504656113574bd95d1f7f35ee0f0ca",
      "vout": 1,
      "scriptSig": {
        "asm": "304402204d144cfd31e9067a2527764969691c6a3907769f13aa77ef47cd0015190932680220424 fdbc2b6f13e3ebb072510bb142f79eee52fd48761de9e7395b5f334f5fe0b01 04bfcb3a6d64f87bd9b303eeb2cfa9140d930a133106ac99b4ca9f5ed23d72c1264276b1fbcc8a1 b024a3866e73e469d0e6d1a08cc829a1e46b05fc2a826b06ffd",
        "hex": "47304402204d144cfd31e9067a2527764969691c6a3907769f13aa77ef47cd00151909326802204 24fdbc2b6f13e3ebb072510bb142f79eee52fd48761de9e7395b5f334f5fe0b014104bfcb3a6d64 f87bd9b303eeb2cfa9140d930a133106ac99b4ca9f5ed23d72c1264276b1fbcc8a1b024a3866e73 e469d0e6d1a08cc829a1e46b05fc2a826b06ffd"
      },
      "sequence": 4294967295
    },
    {
      "txid": "d3d2064a3ccf94d69cfa30d6fdc8ad82481cbfdf4b711ab82d10dd99e317820b",
      "vout": 0,
      "scriptSig": {
        "asm": "3045022100b382b39a8411cb15ec5bd4e59fe6d158735d6eba56fcf7534e59a5c09088492d02200 7191d92cad52da1f7a6e630900aa62634cc013f081dd659053d37faca4aa2c001 04bfcb3a6d64f87bd9b303eeb2cfa9140d930a133106ac99b4ca9f5ed23d72c1264276b1fbcc8a1 b024a3866e73e469d0e6d1a08cc829a1e46b05fc2a826b06ffd",
        "hex": "483045022100b382b39a8411cb15ec5bd4e59fe6d158735d6eba56fcf7534e59a5c09088492d022 007191d92cad52da1f7a6e630900aa62634cc013f081dd659053d37faca4aa2c0014104bfcb3a6d 64f87bd9b303eeb2cfa9140d930a133106ac99b4ca9f5ed23d72c1264276b1fbcc8a1b024a3866e 73e469d0e6d1a08cc829a1e46b05fc2a826b06ffd"
      },
      "sequence": 4294967295
    },
    {
      "txid": "76c68b43dcfefd0fc837fc5d26580d72eeb978b91196a6b97efcb5d3086497ed",
      "vout": 0,
      "scriptSig": {
        "asm": "3046022100fdd65dad87f8583d2fec6f9251cf8c4ba78063c036013fc5f17a77c58b6825d002210 0a1e3f5c6fa3ad96bcd32c72a66f007674f56ca3b09d88370f28dde3aa88d011901 04bfcb3a6d64f87bd9b303eeb2cfa9140d930a133106ac99b4ca9f5ed23d72c1264276b1fbcc8a1 b024a3866e73e469d0e6d1a08cc829a1e46b05fc2a826b06ffd",
        "hex": "493046022100fdd65dad87f8583d2fec6f9251cf8c4ba78063c036013fc5f17a77c58b6825d0022 100a1e3f5c6fa3ad96bcd32c72a66f007674f56ca3b09d88370f28dde3aa88d0119014104bfcb3a 6d64f87bd9b303eeb2cfa9140d930a133106ac99b4ca9f5ed23d72c1264276b1fbcc8a1b024a386 6e73e469d0e6d1a08cc829a1e46b05fc2a826b06ffd"
      },
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 0.0002,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 f1db8572433f9c06e1fc5d72a11674d5869c88cb OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914f1db8572433f9c06e1fc5d72a11674d5869c88cb88ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "1P3ppqXekCWxJQhp18XoYoA9nnZh5LuK9h"
        ]
      }
    },
    {
      "value": 0.00079698,
      "n": 1,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 ddcb1a55b031999e108df4a0bfa0fa23695aff96 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914ddcb1a55b031999e108df4a0bfa0fa23695aff9688ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "1MDjeEJTX6ie1nZXwPhENpVGwUcD6PyU3K"
        ]
      }
    }
  ]
}


And some additional infos provided by blockr.io :
Additional info
Sum of inputs: 0.00109698
Sum of outputs: 0.00099698
Fee: 0.00010000

As you can see im not trying to spend more than i have on my address.
Its a transaction with some change going back to the exp address in order to not loose any coins.

I can show more decoded transactions if needed.

Thanks,
Simon
fbueller
Sr. Member
****
Offline Offline

Activity: 412
Merit: 275


View Profile
February 07, 2016, 09:08:24 PM
 #2

The error is rather well documented - it leads to malleability so is forbidden by local node policy. It's probably a good idea to inform bitcoinjslib about this!

Bitwasp Developer.
luv2drnkbr
Hero Member
*****
Offline Offline

Activity: 793
Merit: 1016



View Profile
February 08, 2016, 02:50:31 AM
Last edit: February 08, 2016, 03:08:30 AM by luv2drnkbr
 #3

The signature is composed of two values, the r value and the s value.  In your third input, the s value is greater than N/2, which is not allowed.  Just add in some code that if s is greater than N/2, then s = N - s.

Change the third signature from

Code:
3046022100fdd65dad87f8583d2fec6f9251cf8c4ba78063c036013fc5f17a77c58b6825d0022100a1e3f5c6fa3ad96bcd32c72a66f007674f56ca3b09d88370f28dde3aa88d011901

to

Code:
3045022100fdd65dad87f8583d2fec6f9251cf8c4ba78063c036013fc5f17a77c58b6825d002205e1c0a3905c5269432cd38d5990ff8976b5812aba5701ccacd44805227a9402801

--------

Edit:  I fixed the transaction and broadcast it for you.  Here's the correct transaction with the lower s value:

Code:
0100000003caf0e05ef3f7d195bd7435115646500e64a15296757780b63d796a54bab0984e010000008a47304402204d144cfd31e9067a2527764969691c6a3907769f13aa77ef47cd0015190932680220424fdbc2b6f13e3ebb072510bb142f79eee52fd48761de9e7395b5f334f5fe0b014104bfcb3a6d64f87bd9b303eeb2cfa9140d930a133106ac99b4ca9f5ed23d72c1264276b1fbcc8a1b024a3866e73e469d0e6d1a08cc829a1e46b05fc2a826b06ffdffffffff0b8217e399dd102db81a714bdfbf1c4882adc8fdd630fa9cd694cf3c4a06d2d3000000008b483045022100b382b39a8411cb15ec5bd4e59fe6d158735d6eba56fcf7534e59a5c09088492d022007191d92cad52da1f7a6e630900aa62634cc013f081dd659053d37faca4aa2c0014104bfcb3a6d64f87bd9b303eeb2cfa9140d930a133106ac99b4ca9f5ed23d72c1264276b1fbcc8a1b024a3866e73e469d0e6d1a08cc829a1e46b05fc2a826b06ffdffffffffed976408d3b5fc7eb9a69611b978b9ee720d58265dfc37c80ffdfedc438bc676000000008b483045022100fdd65dad87f8583d2fec6f9251cf8c4ba78063c036013fc5f17a77c58b6825d002205e1c0a3905c5269432cd38d5990ff8976b5812aba5701ccacd44805227a94028014104bfcb3a6d64f87bd9b303eeb2cfa9140d930a133106ac99b4ca9f5ed23d72c1264276b1fbcc8a1b024a3866e73e469d0e6d1a08cc829a1e46b05fc2a826b06ffdffffffff02204e0000000000001976a914f1db8572433f9c06e1fc5d72a11674d5869c88cb88ac52370100000000001976a914ddcb1a55b031999e108df4a0bfa0fa23695aff9688ac00000000

with transaction ID

0b174b04b294f70be355b4ca86023153af65a3f99db79cb48dd2dc0abe206f9f

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!