segregated witness – What’s the v0 SegWit enter verification course of?

0
54


I’ve posted questions for each script varieties (P2WPKH and P2SH) in the identical place for consistency. A solution to any of the questions is of nice assist.

Let’s begin.

As I do know, conventional scripts (which additionally embody P2PKH and P2SH) are executed by concatenating scriptSig and the corresponding ScriptPubKey and if the top-most merchandise after execution is non-zero, the enter is taken into account legitimate.

If I perceive 141 accurately, it really works a bit in a different way for SegWit. Thus:

1. P2WPKH:

scriptPubKey: OP_0 <hash-pubkey>

scriptSig: empty

witness: <signature> <pubkey>

So, for P2WPKH there is no such thing as a conventional concatenation and stack-based execution of script as OP codes like CHECKSIG, DUP, EQUALVERIFY and so on. don’t exist in scriptSig nor ScriptPubKey. My understanding is that it’ll simply “out of conventional stack execution” calculate the HASH160 of <pubkey> from the witness area and examine with <hash-pubkey> from the scriptPubKey. Then, if the earlier matches, it’s going to push every thing from witness area, add OP_CHECKSIG and execute it as in conventional scripts. So there may be not classical stack-based execution, it goes “out of stack”.

1.1. Am I proper? Is that this the way it works?

Additionally, in BIP141 it says the next:

After regular script analysis, the signature is verified in opposition to the general public key with CHECKSIG operation. The verification should lead to a single TRUE on the stack.

1.2. What does it imply “after regular script analysis…”, by my understanding regular script analysis doesn’t exist?

1.3. What does it imply that the result’s a single TRUE on stack? Does it imply that by consensus guidelines for SegWit we should have solely <signature> and <pubkey> for P2WPKH in witness area and if now we have something further, like OP_1 earlier than <signature> it will likely be invalid since, including OP_CHECKSIG after OP_1 <signature> <pubkey>, multiple merchandise will left on stack (1 TRUE)?

2. P2WPSH:

scriptPubKey: OP_0 <hash-witscript>

scriptSig: empty

witness: <information pushes> <witness script>

So once more, since there are not any OP codes, conventional concatenation and stack-based execution won’t be carried out right here both. It can out of “conventional stack execution” take <witness script>, calculate SHA256 and examine it with <hash-witscript>. If that matches, then every thing from the witness area (<information pushes> and <witness script>) will probably be pushed on the stack and execute in conventional stack-based means.

2.1. Am I proper? Is that this the way it works?

BIP141 says the next:

The witnessScript is deserialized, and executed after regular script
analysis with the remaining witness stack (≤ 520 bytes for every
stack merchandise).

2.2. What does it imply “after regular script analysis”? Script analysis doesn’t exist by my perceive.

2.3. After executing <information pushes> and <witness script> (content material from witness area) in conventional stack-based means it should be just one non-zero merchandise on a stack (in contrast to P2SH the place it may be multiple and solely top-most merchandise is necessary)? Proper?

LEAVE A REPLY

Please enter your comment!
Please enter your name here