From 23bdf8f305c810d8b48a88c9ce34fb49aefc3520 Mon Sep 17 00:00:00 2001 From: krupawan5618 Date: Thu, 4 Mar 2021 21:47:13 -0500 Subject: [PATCH] Update ch07.asciidoc Moved this Tip Box for flow. --- ch07.asciidoc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ch07.asciidoc b/ch07.asciidoc index db8eb38b..d179253f 100644 --- a/ch07.asciidoc +++ b/ch07.asciidoc @@ -782,12 +782,6 @@ Now, let's look at how this entire example would be upgraded to segwit. If Moham Again, as with the example of P2WPKH, you can see that the Segregated Witness equivalent script is a lot simpler and omits the various script operands that you see in P2SH scripts. Instead, the Segregated Witness program consists of two values pushed to the stack: a witness version (0) and the 32-byte SHA256 hash of the redeem script. -[TIP] -==== -While P2SH uses the 20-byte +RIPEMD160(SHA256(script))+ hash, the P2WSH witness program uses a 32-byte +SHA256(script)+ hash. This difference in the selection of the hashing algorithm is deliberate and provides stronger security to P2WSH (128 bits of security in P2WSH versus 80 bits of security in P2SH). It is also used to differentiate between the two types of witness programs (P2WPKH and P2WSH) by using the length of the hash (see below). - -==== - Mohammed's company can spend the P2WSH output by presenting the correct redeem script and sufficient signatures to satisfy it. Both the redeem script and the signatures would be segregated _outside_ the spending transaction data as part of the witness data. Within the transaction input, Mohammed's ((("", startref="mohamappd")))wallet would put an empty +scriptSig+: .Decoded transaction showing a P2WSH output being spent with separate witness data @@ -803,6 +797,12 @@ Mohammed's company can spend the P2WSH output by presenting the correct redeem s [...] ---- +[TIP] +==== +While P2SH uses the 20-byte +RIPEMD160(SHA256(script))+ hash, the P2WSH witness program uses a 32-byte +SHA256(script)+ hash. This difference in the selection of the hashing algorithm is deliberate and provides stronger security to P2WSH (128 bits of security in P2WSH versus 80 bits of security in P2SH). It is also used to differentiate between the two types of witness programs (P2WPKH and P2WSH) by using the length of the hash (see below). + +==== + ===== Differentiating between P2WPKH and P2WSH In the previous two sections, we demonstrated two types of witness programs: <> and <>. Both types of witness programs consist of a single byte version number followed by a longer hash. They look very similar, but are interpreted very differently: one is interpreted as a public key hash, which is satisfied by a signature and the other as a script hash, which is satisfied by a redeem script. The critical difference between them is the length of the hash: