Bitcoin Forum
October 17, 2019, 06:35:07 AM *
News: If you like a topic and you see an orange "bump" link, click it. More info.
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: problematic scenario with SIGHASH_ANYONECANPAY  (Read 88 times)
BrewMaster
Hero Member
*****
Offline Offline

Activity: 1330
Merit: 814


There is trouble abrewing


View Profile
September 04, 2019, 08:37:10 AM
Merited by bones261 (2), darosior (2), ETFbitcoin (1), HeRetiK (1)
 #1

(lets call SIGHASH_ANYONECANPAY ACP for short)

ACP allows you to only sign your own input and ignore the rest.
Code:
[input_ACP] [output_1, output_2]
so if others can add their inputs to this transaction like so:
Code:
[input_ACP, input_1, input_2] [output_1, output_2]
or
Code:
[input_1, input_2, input_ACP, input_3] [output_1, output_2]
now this works fine with ALL and NONE since the index of the input_ACP doesn't matter at all.

but the problem is if it was signed with SINGLE:
Code:
[input_ACP] [output_1, output_2]
in this transaction you only sign output_1 from outputs since input_ACP index is 0.
and if someone added their input like this:
Code:
[input_ACP, input_1] [output_1, output_2]
it works fine.

but if someone added their input like this:
Code:
[input_1, input_ACP] [output_1, output_2]
then input_ACP signature would become invalid since now the index of it is 1 and should have signed output_2 instead!

so the question is, am i understanding the way SINGLE | ACP signhash works and is this a problem or am i mistaken?

1571294107
Hero Member
*
Offline Offline

Posts: 1571294107

View Profile Personal Message (Offline)

Ignore
1571294107
Reply with quote  #2

1571294107
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
Carlton Banks
Legendary
*
Offline Offline

Activity: 2520
Merit: 1981



View Profile
September 04, 2019, 03:14:39 PM
 #2

so the question is, am i understanding the way SINGLE | ACP signhash works and is this a problem or am i mistaken?

there must be some reason the input script cannot be written in a way that it can be interpreted as ACP as part of the spending script itself, instead of using an input index to reference ACP instead (the scripting language cannot express ACP? if there is an opcode, why not?). there must (of course) be some way of defining which input to a tx is ACP, otherwise using ACP wouldn't be safe to use at all.

maybe ACP is an old part of Bitcoin script that is bound by the consensus rules? I'm not sure

Vires in numeris
darosior
Full Member
***
Offline Offline

Activity: 189
Merit: 218



View Profile WWW
September 04, 2019, 04:06:08 PM
Merited by Carlton Banks (3), BrewMaster (3), DooMAD (2), bones261 (2), ETFbitcoin (1)
 #3

SIGHASH_SINGLE only signs one input and one ouput, bound  by there index, so moving them invalidates the signature. SIGHASH_NONE and SIGHASH_ALL obviously don't need indexes (since they don't need to pick either one of the input or one of the outputs), that's why it works to move them.

EDIT: You might find the libbitcoin doc about SIGHASHES of interest :-)

EDIT 2: This is also stated on the OP_CHECKSIG wiki :
Quote
Note: The transaction that uses SIGHASH_SINGLE type of signature should not have more inputs than outputs. However if it does (because of the pre-existing implementation), it shall not be rejected, but instead for every "illegal" input (meaning: an input that has an index bigger than the maximum output index) the node should still verify it, though assuming the hash of 0000000000000000000000000000000000000000000000000000000000000001 [1]

BrewMaster
Hero Member
*****
Offline Offline

Activity: 1330
Merit: 814


There is trouble abrewing


View Profile
September 05, 2019, 04:54:49 AM
 #4

<snip>

i guess since the usage of different sighash types is in special cases which could be called "contracts", then those that are in that "contract" have to come up with agreements like the (SINGLE | ACP) hashtype has to be at index "I" beforehand to avoid problems. but they have to know the problems first.

EDIT: You might find the libbitcoin doc about SIGHASHES of interest :-)
thanks, the pictures in this link were excellent for visualization of what really happens. Smiley

Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!