Now assuming we are reading from the top (pubkeys), we also have to confirm for their corresponding signature at that instance?, (Like read for pubkey3 and confirm with signature2. if it doesn't Correspond, we read again for pubkey3 and confirm with signature1)?.
Yeah, you mostly correct. But the Pubkeys doesn't have to be matched with the signature in a sequence.
Instead the script interpreter would
match any of the signature with any of the PubkeysI actually asked that question initially just to confirm if the reverse process can occur. But I don't think we can just freely match
any of the signature without using a sequential process. From what has been discussed so far, it's certain that the Pubkeys are loaded at the top of the stack, while the signatures proceeds it. From the first link shared by nc50lc, this was suppose to be the actual matching order from a sequential sense..
Loop through all of the public keys, starting with the keys at the top of the stack.
For each public key, check a single signature.
For the first public key checked, start with the signature closest to the top of the stack.
If it fails to verify, go to the next public key and check the same signature.
If it succeeds, go to the next public key with the next signature.
Note that the signatures need to be in the same order as the key's that they're signing for.
If all of the signatures succeeded with one of the keys, CHECKMULTISIG returns 1, otherwise 0.
You see what I was trying to say. But if were to use
any signature and any pubkey, then we might have not followed this sequential process that the quoted text suggested above. The reason for my question earlier was actually to confirm if a reverse process of the quoted text can occur.
Once a signature corresponds with any of the Pubkeys it's considered valid and no longer available for further checking and moves to the next signature until this is satisfied 2-of-3 and if this isn't meant i.e if a signature couldn't correspond with a Pubkey, the entire script fails and the transaction becomes invalid
But there are about 3 available Pubkeys to match with, so I don't think it will fail automatically since there are two more pubkeys to go. So, if we follow the actual sequential process from the quoted text, I think the whole process might end up resulting to 1, which proves to be valid. Except we've successfully tested a signature with the 3 Pubkeys and there isn't any match. But Incase I am missing something here which I don't think so, please clearify me.