Signing a 2/2 Multisig Transaction on separate machines

Hi everyone,

i have a device A that holds a private key Sk(A) and its respective public key Pk(A).

I’ve also a backend service B that holds a private key Sk(B) and its respective public key Pk(B).

A knows only the address string of B.

I want to create a 2/2 Multisig transaction, where both the signatures of A and B are required.

Is it possibile to send a signedTransaction (by A only) to the backend B (so a conversion of the transaction to a JSON format - like) and make B to append its signature to the transaction and then send it to the blockchain?

I want to achieve this using JavaSDK.

Yes this is possible. Take a look at this section:
https://developer.algorand.org/docs/features/transactions/signatures/#multisignatures
Notice that the first account signs the tx.
let rawSignedTxn = algosdk.signMultisigTransaction(txn, mparams, account1.sk).blob;
You can save off this signed tx and send to backend service which would then do:

let twosigs = algosdk.appendSignMultisigTransaction(rawSignedTxn, mparams, account2.sk).blob;
//submit the transaction
let tx = (await algodclient.sendRawTransaction(twosigs));
console.log("Transaction : " + tx.txId);

Take a look at this page for details on saving the signed tx:
https://developer.algorand.org/docs/features/transactions/offline_transactions/#signed-transaction-file-operations

1 Like

Thanks!
In Java i have a issue in this line

publicKeys.add(acct2.getEd25519PublicKey())

since my acct2 is the backend B and at this point i know only its public key (since the code is running on the client), i can write this address only in a String format and i couldn’t figure out how to convert it to the Ed25519PublicKey required by the code.

try

Address addr = new Address("WICXIYCKG672UGFCCUPBAJ7UYZ2X7GZCNBLSAPBXW7M6DZJ5YY6SCXML4A");
Ed25519PublicKey pk = new Ed25519PublicKey(addr.getBytes());

Then you can add it like:

publicKeys.add(acct1.getEd25519PublicKey());
publicKeys.add(acct2.getEd25519PublicKey());
publicKeys.add(pk);
1 Like

Thank you! It worked like a charm

1 Like