Multi-Signature Transactions
The Sui TypeScript SDK provides a MultiSigPublicKey
class to support
Multi-Signature (MultiSig)
transaction and personal message signing.
This class implements the same interface as the PublicKey
classes that Keypairs uses
and you call the same methods to verify signatures for PersonalMessages
and Transactions
.
Creating a MultiSigPublicKey
To create a MultiSigPublicKey
, you provide a threshold
(u16) value and an array of objects that
contain publicKey
and weight
(u8) values. If the combined weight of valid signatures for a
transaction is equal to or greater than the threshold value, then the Sui network considers the
transdaction valid.
The multiSigPublicKey
in the preceding code enables you to verify that signatures have a combined
weight of at least 2
. A signature signed with only kp1
or kp2
is not valid, but a signature
signed with both kp1
and kp2
, or just kp3
is valid.
Combining signatures with a MultiSigPublicKey
To sign a message or transaction for a MultiSig address, you must collect signatures from the
individual key pairs, and then combine them into a signature using the MultiSigPublicKey
class for
the address.
Creating a MultiSigSigner
The MultiSigSigner
class allows you to create a Signer that can be used to sign personal messages
and Transactions like any other keypair or signer class. This is often easier than manually
combining signatures, since many methods accept Signers and handle signing directly.
A MultiSigSigner
is created by providing the underlying Signers to the getSigner
method on the
MultiSigPublicKey
. You can provide a subset of the Signers that make up the public key, so long as
their combined weight is equal to or greater than the threshold.
Multisig with zkLogin
You can use zkLogin to participate in multisig just like keys for other signature schemes. Unlike other keys that come with a public key, you define a public identifier for zkLogin.
For example, the following example creates a 1-out-of-2 multisig with a single key and a zkLogin public identifier:
Benefits and Design for zkLogin in Multisig
Because zkLogin assumes the application client ID and its issuer (such as Google) liveliness, using zkLogin with multisig provides improved recoverability to a zkLogin account. In the previous example of 1-out-of-2 multisig, users can use zkLogin in their regular wallet flow, but if the application or the issuer is deprecated, the user can still use the regular private key account to access funds in the multisig wallet.
This also opens the door to design multisig across any number of zkLogin accounts and of different providers (max number is capped at 10 accounts) with customizable weights and thresholds. For example, you can set up a multisig address with threshold of 2, where the public keys or identifiers are defined as:
- Charlie's own Google account with weight 2
- Charlie's friend Alice's Apple account with weight 1
- Charlie's friend Bob's Facebook account with weight 1
In this case, Charlie can always use their Google account for transactions out of the multisig address for the threshold. At the same time, Charlie still has access to his account by combining partial signatures from Alice and Bob.