1

When we sign a transaction at least with 2 inputs and SIGHASH_ALL flag, what happend to the signature message ?

For example:

version: 01000000
inputs:  02
  txid: b7994a0db2f373a29227e1d90da883c6ce1cb0dd2d6812e4558041ebbbcfa54b
  vout: 00000000
  scriptsigsize: 19
  scriptsig: 76a9144299ff317fcd12ef19047df66d72454691797bfc88ac
  sequence: ffffffff
  ----------------------------------------------------------------------
  txid: e9431833fc2380477723e4b50aa6386dc8d6b86a3a6911a240cfacd68208ea28
  vout: 00000001
  scriptsigsize: 19
  scriptsig: 76a9144299ff317fcd12ef19047df66d72454691797bfc88ac
  sequence: ffffffff
outputs: 01
  amount: c965000000000000
  scriptpubkeysize: 19
  scriptpubkey: 76a914b3e2819b6262e0b1f19fc7229d75677f347c91ac88ac
locktime: 00000000

Step 1: Take the first input sign it and replace scriptSigSize and scriptSig by the signature size and the signature data. Then, do I have to edit the message with the replaced input scriptSig? Or Do I keep the same transaction message for every signature in the same transaction ?

Best wishes

1 Answer 1

3

Each input signs a different message. It is always the spending transaction with all inputs blanked out except for the input being signed. So when signing the second input, anything in the scriptSig for the first input is ignored. This allows for independent signing and verification - you don't need to have signed the first input in order to sign and verify the second input.

3
  • Ok, so if I understand what you're saying, The first message in the above example is : toptal.com/developers/hastebin/wepajikove.yaml in a first time. Once the first input was signed I sign the second input by ignoring the first scriptSig data input (message available here) : toptal.com/developers/hastebin/gosasuxuqu.yaml ?
    – Loopite
    Jul 2 at 18:06
  • @Loopite Not quite. In the first message, you have to blank out the second input, and in the second, you blank the first input. So your second is correct, the first is not.
    – Andrew Chow
    Jul 2 at 18:29
  • Ok fine I understood ! Thanks so much for your answer ^^. Have a lovely rest of your day.
    – Loopite
    Jul 2 at 20:08

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.