1

As the title says, can we pass multiple signers in invoke_signed()?

2
  • please add a code example of what you've tried that didn't work or link to whatever documentation you're referencing and explain why it leads you to believe this isn't possible
    – trent.sol
    Jul 28, 2022 at 7:08
  • thanks! please come back in two days to accept it then :)
    – trent.sol
    Jul 28, 2022 at 17:34

2 Answers 2

3

Ok, so it is possible to pass multiple signers in invoke_signed().

Example code:

invoke_signed(
    &Instruction,
    account_infos.as_slice(),
    // Multiple Signers
    &[
        &[ "PDA1_SEED1".as_bytes(), "PDA1_SEED2".as_bytes(), &[PDA1_bump] ], // first seed
        &[ "PDA2_SEED1".as_bytes(), "PDA2_SEED2".as_bytes(), &[PDA2_bump] ], // second seed

    ],
)?;
2
  • I think this represents signing for multiple different PDAs but critically, both PDAs in this case must be under the single authority of the program that calls invoke_signed. The documentation indicates "the runtime will re-derive the PDA from the seeds and the calling program’s ID" when checking for a signature. This makes it possible to sign multiple accounts, but only as the same entity... right?
    – Nate
    Jul 28, 2022 at 17:18
  • depends on your definition of "entity". as I stated in my comment to your answer, multiple "entities" could sign the transaction, which the program then verifies and invokes some other program with corresponding PDAs for each. The program effectively "approves" the CPI.
    – trent.sol
    Jul 28, 2022 at 17:39
1

Well no, but actually yes.

The call to invoke_signed is only designed to generate signatures for program derived accounts (PDAs) that correspond directly to your program's deployed ID. You can sign multiple PDAs but you can't represent multiple different signing entities.

Programs can make use of signature extension however to pass signatures previously provided by another entity along to subsequent programs. This means whatever signatures were provided when your program was loaded and executed are considered to remain signed when you use invoke_signed. So if you need additional parties to provide signatures, they should be added to the instruction that calls your program. Then they will be passed through to invoke_signed. They cannot be added within your program.

4
  • it really depends on the program's logic. several independent authorities could sign a transaction and the program logic pass seeds referencing each to invoke_signed, promoting their corresponding PDA to signers. i believe the answer is simply, "yes"
    – trent.sol
    Jul 28, 2022 at 0:05
  • I think we're in agreement here. I avoided the simple "yes" just to make clear the distinction between adding a new program-generated "signature" (which invoke_signed can do for only the calling program) and passing previous signatures/signers through the same call.
    – Nate
    Jul 28, 2022 at 17:30
  • right, but the program can cosign for unlimited (within the tx size limit) other authorities via PDA. it's all up to the logic it implements. which is why I suggest the answer is in fact "simple yes"
    – trent.sol
    Jul 28, 2022 at 18:17
  • the program can also pass unlimited (within the tx size limit) other signatures through invoke without adding any endorsement. The purpose of choosing invoke_signed though is to introduce co-signing and in that capacity, the program can represent only one signer. The semantic distinction between a signature and a signer here, although admittedly a little nit-picky, seems relevant to the context of this question.
    – Nate
    Jul 28, 2022 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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