From d2a386cf7f19a60dab65f6e1404b5dd9c2b0983b Mon Sep 17 00:00:00 2001 From: krupawan5618 Date: Fri, 5 Mar 2021 17:54:26 -0500 Subject: [PATCH 1/3] Update ch07.asciidoc Aim is to clarify the current restrictions of standard multisig vs. P2SH. The aim is to further clarify why a transaction would be invalid, in each perspective. On a technical note, saying that it 'invalidates the transaction' may not be correct, but my current understanding is that a 2 of 5 multisig transaction would enter the mempool but then become invalid by nodes. On the other hand, nodes wouldn't have a way to tell if a P2SH hash has within it 15 public keys as it is just a hash; therefore, the only way to tell is to analyze unlocking script of a transaction in input, unless the basis for 15 public keys is a size restriction? Thank you --- ch07.asciidoc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ch07.asciidoc b/ch07.asciidoc index d179253f..23cc11ec 100644 --- a/ch07.asciidoc +++ b/ch07.asciidoc @@ -177,7 +177,10 @@ If the redeem script hash matches, the unlocking script is executed on its own, 2 PK1 PK2 PK3 PK4 PK5 5 CHECKMULTISIG ---- -Almost all the scripts described in this chapter can only be implemented as P2SH scripts. They cannot be used directly in the locking script of an UTXO.((("", startref="mohamseven"))) +[TIP] +==== +Remember, standard multisignature scripts are limited to at most 3 listed public keys (as determined by IsStandard() function), while P2SH allows for up to 15 public keys. For example, using a 2 of 5 standard multisignature locking script cannot be used directly in the locking script of an UTXO and would invalidate the transaction. Furthermore, a transaction input cannot include more than 15 public keys to redeem a P2SH. ((("", startref="mohamseven"))) +==== ==== P2SH Addresses From 73c3af32c377d172f582f60e1ba24c4defc99794 Mon Sep 17 00:00:00 2001 From: krupawan5618 Date: Fri, 5 Mar 2021 19:44:54 -0500 Subject: [PATCH 2/3] Update ch07.asciidoc Elaborated a bit more on IsStandard() function and provided clarity to the examples written above. Reference: https://github.com/bitcoin/bitcoin/blob/ed25cb58f605ba583c735f330482df0bf9348f3a/src/policy/policy.cpp#L53 --- ch07.asciidoc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ch07.asciidoc b/ch07.asciidoc index 23cc11ec..161b8c15 100644 --- a/ch07.asciidoc +++ b/ch07.asciidoc @@ -14,7 +14,7 @@ First, we will look at _multisignature_ scripts. Next, we will examine the secon ((("transactions", "advanced", "multisignature scripts")))((("transactions", "advanced", id="Tadv07")))((("scripting", "multisignature scripts", id="Smulti07")))((("multisignature scripts")))Multisignature scripts set a condition where N public keys are recorded in the script and at least M of those must provide signatures to unlock the funds. This is also known as an M-of-N scheme, where N is the total number of keys and M is the threshold of signatures required for validation. For example, a 2-of-3 multisignature is one where three public keys are listed as potential signers and at least two of those must be used to create signatures for a valid transaction to spend the funds. -At this time, _standard_ multisignature scripts are limited to at most 3 listed public keys, meaning you can do anything from a 1-of-1 to a 3-of-3 multisignature or any combination within that range. The limitation to 3 listed keys might be lifted by the time this book is published, so check the +IsStandard()+ function to see what is currently accepted by the network. Note that the limit of 3 keys applies only to standard (also known as "bare") multisignature scripts, not to multisignature scripts wrapped in a Pay-to-Script-Hash (P2SH) script. P2SH multisignature scripts are limited to 15 keys, allowing for up to 15-of-15 multisignature. We will learn about P2SH in <>. +At this time, _standard_ multisignature scripts are limited to at most 3 listed public keys, meaning you can do anything from a 1-of-1 to a 3-of-3 multisignature or any combination within that range. The limitation to 3 listed keys might be lifted by the time this book is published, so check the +IsStandard()+ function to see what is currently accepted by the network. Note that the limit of 3 keys applies only to standard (also known as "bare") multisignature scripts, not to multisignature scripts wrapped in a Pay-to-Script-Hash (P2SH) script. P2SH multisignature scripts are limited to 15 keys, allowing for up to 15-of-15 multisignature. This limitation is also imposed by the +IsStandard()+ function. We will learn about P2SH in <>. The general form of a locking script setting an M-of-N multisignature condition is: @@ -179,7 +179,9 @@ If the redeem script hash matches, the unlocking script is executed on its own, [TIP] ==== -Remember, standard multisignature scripts are limited to at most 3 listed public keys (as determined by IsStandard() function), while P2SH allows for up to 15 public keys. For example, using a 2 of 5 standard multisignature locking script cannot be used directly in the locking script of an UTXO and would invalidate the transaction. Furthermore, a transaction input cannot include more than 15 public keys to redeem a P2SH. ((("", startref="mohamseven"))) +Remember, because of policy set forth by the +IsStandard()+ function at the time of this writing, standard multisignature scripts are limited to at most 3 listed public keys, while P2SH are limited to at most 15 public keys. Standard multisignature scripts can invalidate transactions by way of their locking +or+ unlocking script, while P2SH can invalidate transactions by way of their unlocking script +only+. This is because there is no way for +IsStandard()+ to tell if a hash of a redeem script in a locking script includes more signatures than the currenetly imposed size limitation, so it can only observe the unlocking scripts in transaction inputs. + +Almost all the scripts described in this chapter can only be implemented as P2SH scripts. For example, a 2 of 5 standard multisignature locking script cannot be used directly in the locking script of an UTXO, as +IsStandard()+ would invalidate the transaction. To conform, a P2SH locking script can be used instead, as seen above. A transaction that then includes a P2SH unlocking script can be used to redeem this UTXO and will be valid so long as it does not contain more than 15 public keys. ((("", startref="mohamseven"))) ==== ==== P2SH Addresses From a9a5ed38a9b0703c3a3bc935470231d35432695c Mon Sep 17 00:00:00 2001 From: krupawan5618 Date: Fri, 5 Mar 2021 19:48:37 -0500 Subject: [PATCH 3/3] Update ch07.asciidoc refactored text to create sizeable tip box; fixed typos --- ch07.asciidoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ch07.asciidoc b/ch07.asciidoc index 161b8c15..2b755068 100644 --- a/ch07.asciidoc +++ b/ch07.asciidoc @@ -177,11 +177,11 @@ If the redeem script hash matches, the unlocking script is executed on its own, 2 PK1 PK2 PK3 PK4 PK5 5 CHECKMULTISIG ---- +Almost all the scripts described in this chapter can only be implemented as P2SH scripts. For example, a 2 of 5 standard multisignature locking script cannot be used directly in the locking script of an UTXO, as +IsStandard()+ would invalidate the transaction. To conform, a P2SH locking script can be used instead, as seen above. A transaction that then includes a P2SH unlocking script can be used to redeem this UTXO and will be valid so long as it does not contain more than 15 public keys. ((("", startref="mohamseven"))) + [TIP] ==== -Remember, because of policy set forth by the +IsStandard()+ function at the time of this writing, standard multisignature scripts are limited to at most 3 listed public keys, while P2SH are limited to at most 15 public keys. Standard multisignature scripts can invalidate transactions by way of their locking +or+ unlocking script, while P2SH can invalidate transactions by way of their unlocking script +only+. This is because there is no way for +IsStandard()+ to tell if a hash of a redeem script in a locking script includes more signatures than the currenetly imposed size limitation, so it can only observe the unlocking scripts in transaction inputs. - -Almost all the scripts described in this chapter can only be implemented as P2SH scripts. For example, a 2 of 5 standard multisignature locking script cannot be used directly in the locking script of an UTXO, as +IsStandard()+ would invalidate the transaction. To conform, a P2SH locking script can be used instead, as seen above. A transaction that then includes a P2SH unlocking script can be used to redeem this UTXO and will be valid so long as it does not contain more than 15 public keys. ((("", startref="mohamseven"))) +Remember, because of policy set forth by the +IsStandard()+ function at the time of this writing, standard multisignature scripts are limited to at most 3 listed public keys, while P2SH are limited to at most 15 listed public keys. Standard multisignature scripts can invalidate transactions by way of their locking +or+ unlocking script, while P2SH can invalidate transactions by way of their unlocking script +only+. This is because there is no way for +IsStandard()+ to tell if a hash of a redeem script in a locking script includes more signatures than the currently imposed size limitation, so it can only observe the unlocking scripts in transaction inputs. ==== ==== P2SH Addresses