Bitcoin Forum
May 07, 2024, 06:30:16 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Why is scriptSig filled with scriptPubKey before signing a transaction?  (Read 416 times)
croraf (OP)
Newbie
*
Offline Offline

Activity: 10
Merit: 1


View Profile
November 26, 2017, 11:14:12 PM
Merited by ABCbits (1)
 #1



I'm checking the transaction signing as described here https://bitcoin.stackexchange.com/questions/32628/redeeming-a-raw-transaction-step-by-step-example-required.

What is the reason for steps 5 and 6: temporarily filling scriptSig with scriptPubKey of the output we want to redeem?

Can't this just be skipped, as with txid and output index we uniquely specify the output thus scriptPubKey and we don't get any value with this filling?
1715106616
Hero Member
*
Offline Offline

Posts: 1715106616

View Profile Personal Message (Offline)

Ignore
1715106616
Reply with quote  #2

1715106616
Report to moderator
1715106616
Hero Member
*
Offline Offline

Posts: 1715106616

View Profile Personal Message (Offline)

Ignore
1715106616
Reply with quote  #2

1715106616
Report to moderator
1715106616
Hero Member
*
Offline Offline

Posts: 1715106616

View Profile Personal Message (Offline)

Ignore
1715106616
Reply with quote  #2

1715106616
Report to moderator
"This isn't the kind of software where we can leave so many unresolved bugs that we need a tracker for them." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715106616
Hero Member
*
Offline Offline

Posts: 1715106616

View Profile Personal Message (Offline)

Ignore
1715106616
Reply with quote  #2

1715106616
Report to moderator
1715106616
Hero Member
*
Offline Offline

Posts: 1715106616

View Profile Personal Message (Offline)

Ignore
1715106616
Reply with quote  #2

1715106616
Report to moderator
1715106616
Hero Member
*
Offline Offline

Posts: 1715106616

View Profile Personal Message (Offline)

Ignore
1715106616
Reply with quote  #2

1715106616
Report to moderator
pebwindkraft
Sr. Member
****
Offline Offline

Activity: 257
Merit: 343


View Profile
November 27, 2017, 10:59:19 AM
Merited by ABCbits (1)
 #2

I posted my answer as well on your question in stackexchange...

https://bitcoin.stackexchange.com/questions/63489/why-is-scriptsig-filled-with-scriptpubkey-before-signing-a-transaction/63519#63519

croraf (OP)
Newbie
*
Offline Offline

Activity: 10
Merit: 1


View Profile
November 27, 2017, 01:32:11 PM
 #3

Thanks man.

I have kind of a follow up question, that I will also post on SE.

So to make transaction the following is done.

For each input
 
- all inputs and outputs are taken
- the respective input scriptSig is filled with txPrev.pubScript, other inputs's scriptSigs are left blank?
- this is signed and signature is put in respective scriptSig


Is there any benefit for bundling all inputs in each signature? Could just respective input (and all outputs) be used when signing for that input?

This will give N_inputs different templates.

But if currently other inputs' scriptSig than respective are left blank (instead of each being filled with txPrev.pubScript) then we currently also have N_inputs different templates.

The ideal would be to leave all scriptSigs blank when making signing template and use all inputs and outputs. This will give us 1 template that is signed N_input times.

What you think? Were you able to follow my thoughts?
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6631


Just writing some code


View Profile WWW
November 27, 2017, 04:36:48 PM
Merited by ABCbits (2)
 #4

Is there any benefit for bundling all inputs in each signature? Could just respective input (and all outputs) be used when signing for that input?
The benefit is that each signature commits to the inputs and outputs of the transaction so that they cannot be changed. If each input only commit to one input, then more inputs could be added and malleate the transaction. However there is a sighash type that allows this, sighash ANYONECANPAY.

croraf (OP)
Newbie
*
Offline Offline

Activity: 10
Merit: 1


View Profile
November 28, 2017, 09:08:05 AM
 #5

Is there any benefit for bundling all inputs in each signature? Could just respective input (and all outputs) be used when signing for that input?
The benefit is that each signature commits to the inputs and outputs of the transaction so that they cannot be changed. If each input only commit to one input, then more inputs could be added and malleate the transaction. However there is a sighash type that allows this, sighash ANYONECANPAY.

Cool. Understood.
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!