Bitcoin Forum
June 19, 2024, 10:32:47 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 [2]  All
  Print  
Author Topic: What is up with this SIGHASH_SINGLE and nOut out of range?  (Read 1816 times)
Sergio_Demian_Lerner
Hero Member
*****
expert
Offline Offline

Activity: 554
Merit: 648


View Profile WWW
July 24, 2013, 08:44:05 PM
Last edit: July 25, 2013, 12:40:29 AM by Sergio_Demian_Lerner
 #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.


Sergio_Demian_Lerner
Hero Member
*****
expert
Offline Offline

Activity: 554
Merit: 648


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:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!