Check if multiple signatures match a specifc public key 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):

&lt;sig_S1&gt; &lt;sig_A&gt; &lt;sig_S2&gt; &lt;sig_S5&gt; 


but not this one:

&lt;sig_S1&gt; &lt;sig_S4&gt; &lt;sig_S3&gt; &lt;sig_S5&gt; 


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 &lt;pub_A&gt; &lt;pub_S1&gt; &lt;pub_S2&gt; ... &lt;pub_S5&gt; 5 OP_CHECKMULTISIG
OP_ENDIF
(the same as above for B)
(the same as above for C)
I believe it could work with a RedeemScript like this (haven't tested the scripts):  

OP_IF
  3 &lt;pub_A&gt;&lt;pub_B&gt;&lt;pub_C&gt; 3 OP_CheckMultiSig
OP_ELSE
  1 &lt;pub_A&gt;&lt;pub_B&gt;&lt;pub_C&gt; 3 OP_CheckMultiSigVerify
  4 &lt;pub_S1&gt;&lt;pub_S2&gt;&lt;pub_S3&gt;&lt;pub_S4&gt;&lt;pub_S5&gt; 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 &lt;sig_A&gt;&lt;sig_B&gt;&lt;sig_C&gt; OP_TRUE &lt;RedeemScript&gt;


or

OP_0 &lt;sig_S1&gt;&lt;sig_S2&gt;&lt;sig_S4&gt;&lt;sig_S5&gt; OP_0 &lt;sig_A or B or C&gt; OP_FALSE &lt;RedeemScript&gt;