Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: fabbit on January 19, 2020, 04:10:41 PM



Title: How does HASHSIG work?
Post by: fabbit on January 19, 2020, 04:10:41 PM
Hi everyone,

I am reading an article about how HASHSIG works, but i don't understand this:

Before the signature is computed, several temporary changes are made to the transaction: The signature script of the currently signed input is replaced with the public key script, excluding all occurences of OP CODESEPARATOR in it, of the referenced transaction output.

I mean why the scriptSig is replaced with the scriptPubKey?


Title: Re: How does HASHSIG work?
Post by: DaCryptoRaccoon on January 19, 2020, 09:25:33 PM
OP_CODESEPARATOR is not used any more from what I can tell this was actually a security risk for bitcoin as per the post below.

The official info behind this would be as follows :

OP_CODESEPARATOR   
OPCode = 171   
Hex =  0xab   
Input = Nothing   
Output = Nothing   
Description = All of the signature checking words will only match signatures to the data after the most recently-executed OP_CODESEPARATOR.

The post below will give some more info related to this  OP code though it is no longer used as far as I can tell.

https://bitcointalk.org/index.php?topic=255145.msg2760786#msg2760786

** Edit **

You can also read here some more info about it.

https://github.com/bitcoin/bips/blob/master/bip-0017.mediawiki


Title: Re: How does HASHSIG work?
Post by: fabbit on January 19, 2020, 09:38:46 PM
Thanks, but why the scriptSig is replaced with scriptPubKey?


Title: Re: How does HASHSIG work?
Post by: BrewMaster on January 20, 2020, 10:24:35 AM
Thanks, but why the scriptSig is replaced with scriptPubKey?

did you read the replies in your other topic? the answer to this question is already explained there in 2 posts particularly in this one: https://bitcointalk.org/index.php?topic=5216988.msg53606106#msg53606106