Bitcoin Forum
April 26, 2024, 10:58:57 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: problematic scenario with SIGHASH_ANYONECANPAY  (Read 191 times)
BrewMaster (OP)
Legendary
*
Offline Offline

Activity: 2114
Merit: 1292


There is trouble abrewing


View Profile
September 04, 2019, 08:37:10 AM
Merited by bones261 (2), darosior (2), HeRetiK (1), ABCbits (1), Heisenberg_Hunter (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?

There is a FOMO brewing...
1714129137
Hero Member
*
Offline Offline

Posts: 1714129137

View Profile Personal Message (Offline)

Ignore
1714129137
Reply with quote  #2

1714129137
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714129137
Hero Member
*
Offline Offline

Posts: 1714129137

View Profile Personal Message (Offline)

Ignore
1714129137
Reply with quote  #2

1714129137
Report to moderator
Carlton Banks
Legendary
*
Offline Offline

Activity: 3430
Merit: 3071



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
Sr. Member
****
Offline Offline

Activity: 279
Merit: 435


View Profile
September 04, 2019, 04:06:08 PM
Merited by Carlton Banks (3), BrewMaster (3), DooMAD (2), bones261 (2), ABCbits (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 (OP)
Legendary
*
Offline Offline

Activity: 2114
Merit: 1292


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

There is a FOMO brewing...
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!