2

Suppose you have a company which has three main leaders called A, B and C also the company have 5 shareholders called S1 to S5. The decision rule for spending any coin from company's address is to either we present 1 of the main leaders signature and three other signature from shareholders. For example following unlocking script works (since it contains one of the leaders):

<sig_S1> <sig_A> <sig_S2> <sig_S5> 

but not this one:

<sig_S1> <sig_S4> <sig_S3> <sig_S5> 

How I can check if amongst multi signatures there exist a signature which corresponds to a specific public key, in this case, I will learn that a leader's signature surely exists. for example, if we find out from 5 signatures provided the signature of A exists, and the locking code will look like follows:

(3 times duplicate of all signatures provided)
(check for the existence of A in signatures)
OP_IF 
   4 <pub_A> <pub_S1> <pub_S2> ... <pub_S5> 5 OP_CHECKMULTISIG
OP_ENDIF
(the same as above for B)
(the same as above for C)
0

I believe it could work with a RedeemScript like this (haven't tested the scripts):

OP_IF
  3 <pub_A><pub_B><pub_C> 3 OP_CheckMultiSig
OP_ELSE
  1 <pub_A><pub_B><pub_C> 3 OP_CheckMultiSigVerify
  4 <pub_S1><pub_S2><pub_S3><pub_S4><pub_S5> 5 OP_CheckMultiSig

Explanation: The redeem script has two parts:
- OP_IF: this part could be removed, it is there to allow the "leaders" to spend the funds without needing the "shareholders" signatures. Depending on the purpose it could be removed (remove first 3 lines of RedeemScript and signature doesn't require OP_TRUE/OP_FALSE in it).
- OP_ELSE: this provides what you need with 2 multi-signature operations. The first one requires at least one signature out of 3 "leaders" signatures and performs a OP_CheckMultiSigVerify (there is no true/false remaining on the stack after the execution) and the second one requires 4 of 5 signatures from "shareholders".

To spend, either one of these signature scripts should be provided (OP_0 is mandatory due to the bug in CheckMultiSig OPs):

OP_0 <sig_A><sig_B><sig_C> OP_TRUE <RedeemScript>

or

OP_0 <sig_S1><sig_S2><sig_S4><sig_S5> OP_0 <sig_A or B or C> OP_FALSE <RedeemScript>
| improve this answer | |
  • How about first checking with all the public key of shareholders with checkmultisig, if the result was true we know that in signatures provided there is not exist either of leaders, if that was not true we could check for 4 s1, s2, .. ,s5, a, b, c 8 checkmultisig. – Parsa Noshafagh Dec 22 '19 at 15:32
  • That would require each shareholder to sign the transaction twice, it also increases the size of the signature (and transaction) by a lot. – Coding Enthusiast Dec 23 '19 at 6:05
  • Instead of twice signature, we could duplicate it in the lucking script. – Parsa Noshafagh Dec 23 '19 at 8:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.