KiChain: How to use multi-signatures in the Ki Desktop Wallet

Tarek Awwad
Ki Foundation
Published in
7 min readAug 20, 2020

Welcome to the Ki-steps series, a sequence of how-to posts where we explain the detailed steps to perform more or less advanced tasks on the KiChain. In this post, we will tackle the usage of multi-signature accounts in the Ki Desktop Wallet. Multi-signatures are natively supported in the Cosmos SDK, they allow a secure and distributed governance of personal or shared funds.

In a previous post, we overviewed the multi-signature concept as well as its utility. We also explained how one can perform the multi-signature workflow (i.e., generate, sign, multi-sign and broadcast a transaction) in the command line with ki-tools. While using ki-tools to generate and sign transactions is straightforward for someone familiar with linux commands, it might be a bit more complicated for less techie users. Therefore, we added the multi-signature functionality to the Ki Desktop Wallet.

The Functional Workflow

Before getting into the steps of creating, signing and broadcasting a multi-signature transaction in the desktop wallet, let's overview these steps from a functional perspective.

Creating a multi-signature address:

The first step of using multi-signatures is to create the multi-signature account that holds the shared funds. To do so, the participants — i.e., the parties which share the access to the multi-signature account — need to share their public keys with one of them or with any third party who will be in charge of generating the address from 2 key elements :

  1. The participant public keys (the yellow dots in the figures below).
  2. An agreed on threshold (the red dot in the figures below) that is the minimal number of signatures needed to be able to multi-sign and broadcast a transaction.

A participant can generate their wallets and view their public keys from within the Ki Desktop Wallet while generating the multi-signature address is limited to ki-tools for now. Both steps are shown further in this post.

Note that

Creating a multi-signature transaction:

In order to create and broadcast a multi-signature transaction, three steps are required:

  1. First, a transaction needs to be generated from the multi-signature address. This is usually done by one of the key holders or by a delegated third party. The generated transaction file is then distributed to the participants.
  2. Each of the participants checks the conformity of the transaction content and signs it with their private key. The produced signatures are then collected by the transaction generator who combines them to produce the final multi-signature.
  3. This multi-signature is finally included in the transaction which can now be broadcasted to the blockchain to be validated and committed.
The workflow for generating signing and broadcasting a multi-signature transaction.

Multi-signature in The Ki Desktop wallet

Now that the general workflow is described, let's see how one can use the desktop wallet to generate and broadcast multi-signature transactions. To make stuff easier we will consider the following scenario:

Alice, Bob and Carol jointly purchased 1000ҟ. For security reasons, they decided to share the access to these funds through a multi-signature account and agreed on fixing the threshold to a practical value of 2. A while after purchasing the tokens and sending them to the multi-signature address, they decided to gift 100ҟ to their friend Dave for his birthday.

Create a multi-signature address:

Let's start by creating the multi-signature wallets. As mentioned earlier, each participant, i.e,. Alice, Bob and Carol, needs to create their own wallet and share their public Key with the multi-signature address creator, say it's Carol.

In a previous post, we showed how to create and/or import KiChain wallets in the Ki Desktop wallet. Here, let's consider that the participant wallets have been already created and need only to be imported. Below is the workflow that Alice will follow to import her wallet. She will navigate to import a wallet from her home screen, pick a name for her wallet, enter her mnemonic and protect the wallet by a password. When Alice clicks on "save", her wallet will be imported and she can navigate into the wallet view by clicking on the created wallet in the wallet list. To view her public key, Alice will simple click on the wallet avatar found in the top bar. The other participants will follow the exact same workflow and share their public keys with Carol.

Importing a wallet by mnemonic and viewing the wallet pubkey

When Carol receives all of the needed public keys she will use ki-tools to generate the public address of the multi-signature account. Here is a reminder on how to do so (A more detailed tutorial on using ki-tools can be found here):

Carol will add the keys one by one to the local key store :

$ kicli —-home kicli/ keys add alice —-pubkey [pubkey1]
$ kicli —-home kicli/ keys add bob —-pubkey [pubkey2]
$ kicli —-home kicli/ keys add carol —-pubkey [pubkey3]

And she will generate the multi-signature address :

$ kicli --home kicli/ keys add ms-wallet --multisig alice,bob,carol --multisig-threshold 2

Note that this step is done only once. After being created, the multi-signature wallet can be imported and "used" by any participant.

Import a multi-signature address:

Now let's assume that the purchased funds were sent to the multi-signature address and that Carol will also be in charge of initiating and broadcasting the multi-signature transaction. To this end, he will import the multi-signature address into the Ki Desktop Wallet:

Carol clicks on import a wallet, fills in the wallet name, sets the offline mode to No and the multi-signature option to Yes and clicks on proceed to fill in the multi-signature address. Since the multi-signature account haven't been used before to send any transaction, it is unknown by the blockchain. Therefore, Carol will be prompted to fill in the multi-signature data of the wallet. That is, the participant public keys and the threshold. Once done, Carol can click on import to import the wallet.

Note: Once the multi-signature address has served to send at least one transaction, the multi-signature data are automatically detected by the wallet and need no more to be manually entered.

importing a multi-signature account

The new wallet will be imported to the wallet list in the same way the other wallets are with some small yet meaningful differences. indeed, when a multi-signature wallet is chosen in the list, the Desktop Wallet automatically detects the context and switches all transactions forms to transaction generation mode and a Multisign tab appears in the operation tab.

Multi-signature wallet view

Generate a multi-signature transaction:

To generate the transaction that will serve to gift 100ҟ to Dave, Carol clicks on the multi-signature wallet in the wallet list then on transfer. She fill in the transfer amount and Dave's address and clicks on generate. The wallet will generate a transaction file that Carol will share with the Alice and Bob through any communication channel.

Generating a multi-signature transaction

Sign the transaction by the participants:

Each participant imports the file into the wallet as follows: they open the Ki wallet and select their participant wallet from the list. They go to the sign tab and drag the transaction file to the upload area.Since they are signing this transaction on behalf of the multi-signature address, they need to enter the multi-signature address in the “on behalf of” field before entering their password and signing the transaction. Finally they can download the signature and send it to the “broadcaster” Carol.

Alice's generated signature

Combine the signatures:

When Carol receives all the signatures of the other participants, she can proceed to the final signature. From the wallet lists, she selects the previously imported multi-signature wallet then switches to "Multisign" tab. After dragging and dropping the transaction file to the upload area she will get a reminder of the transaction content. Then she starts dropping the signature files one by one in the signature upload area. Once all the received signatures are included and if the signature threshold is reached, Carol can generate the final signature by clicking on “sign”. Finally she can click on broadcast to commit the transaction, or on download to download the final signed transaction.

The ready to broadcast multi-signed transaction

In a future post, we will provide an in-depth theoretical and technical discussion on how multi-signatures are generated and managed under the hood in the Cosmos SDK.

--

--

Tarek Awwad
Ki Foundation

Computer Scientist - PhD - Chief Blockchain Architect @Ki_Foundation - #Blockchain #DistributedSystems #Crowdsourcing #MachineLearning #DataMining