Bitcoin Forum
September 27, 2018, 11:03:13 PM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: « 1 [2]  All
  Print  
Author Topic: What is up with this SIGHASH_SINGLE and nOut out of range?  (Read 1742 times)
Sergio_Demian_Lerner
Hero Member
*****
expert
Offline Offline

Activity: 540
Merit: 510


View Profile WWW
July 24, 2013, 08:44:05 PM
 #21

yeah it returns one, but the tx is still valid in the blockchain. i know it's a big wtf.

the actual hash looks like 00 00 00 ... 00 01 (last byte is 0x01 but all the rest is 0x00).

Now we've found the first and only way to test the execution of the line:

Code:
// Drop the signature, since there's no way for a signature to sign itself
scriptCode.FindAndDelete(CScript(vchSig));

(for which I thought it would be impossible to ever test in a live transaction)

Since the hash "00 .. 01"  does not depend on the script hash that spends the output, you can create a scriptpub that actually includes the signature of the hash "00 .. 01" in the script.

For example:

<sig("00 .. 01")> OP_DROP OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG

Will result in <sig("00 .. 01")>  being stripped from the script when the output transaction is redeem by a SIGHASH_SINGLE signature with an out-of-bounds nOut.

Nevertheless since it won't affect in any way the outcome of the signature checking, you'll only be checking if that execution path aborts with an exception or continues normally.


1538089393
Hero Member
*
Offline Offline

Posts: 1538089393

View Profile Personal Message (Offline)

Ignore
1538089393
Reply with quote  #2

1538089393
Report to moderator
1538089393
Hero Member
*
Offline Offline

Posts: 1538089393

View Profile Personal Message (Offline)

Ignore
1538089393
Reply with quote  #2

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

Posts: 1538089393

View Profile Personal Message (Offline)

Ignore
1538089393
Reply with quote  #2

1538089393
Report to moderator
1538089393
Hero Member
*
Offline Offline

Posts: 1538089393

View Profile Personal Message (Offline)

Ignore
1538089393
Reply with quote  #2

1538089393
Report to moderator
1538089393
Hero Member
*
Offline Offline

Posts: 1538089393

View Profile Personal Message (Offline)

Ignore
1538089393
Reply with quote  #2

1538089393
Report to moderator
Sergio_Demian_Lerner
Hero Member
*****
expert
Offline Offline

Activity: 540
Merit: 510


View Profile WWW
July 25, 2013, 12:44:07 AM
 #22

BTW, we should be happy Satoshi choose 1 as the error code and not 0, because 0 is a weak message for a ECDSA hash and can be easily forged. This would result in anybody being able to steal each other coins.

(or maybe he knew about this fact)
Pages: « 1 [2]  All
  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!