Crypto Academy / Season 3 / Week 5 - Homework Post for @sapwood
MULTI-SIG WALLET
A multi-sig wallet is a crypto wallet that requires more than one private key to sign a transaction. Our normal single key crypto wallet requires just one user to sign a transaction for it to be broadcasted, however, in a multi-sig wallet, there's more than one signature needed to sign a transaction, before it is broadcasted to the network.
In a multi-sig wallet, there could be an 'n' amount of cosigners but a minimum of 'm' of them is required to sign a transaction. E.g, a wallet could have 7 cosigners in total, but requires a minimum of 5 cosigners to sign a transaction. In this case, the wallet can be referred to as a 5 by 7 multi-sig wallet.
Note: an m by n multi-sig wallet requires at least m cosigners out of the total n cosigners registered. The m by n is referred to as the wallet combination
Note: cosigner(s) is a person who is registered in the multi-sig wallet and can sign a transaction
HOW MULTI-SIG WALLET DIFFERS FROM SINGLE KEY WALLET
Single key wallet requires just one private key to sign transactions. This key is held in the custody of the user for a decentralized single wallet.
A good example is the steemit wallet. To send a transaction, you enter the transaction details, including the receiver's address, memo (sometimes optional), and amount
Then you confirm the details of the transaction
Now you enter your private key. This private key is the only key required to sign this transaction because the steemit wallet is a single key wallet
For a multi-sig wallet however, more than one private key is required to sign the transaction. The number of private keys require to sign a transaction depends on the number set in wallet combination explained earlier.
As a result of this difference, a lot more differences between the two is formed. Since multi-sig wallet requires more than one private key, it has wider applications than the single key wallet.
Also, it improves on the security of transactions as the transaction is confirmed more once. It also eliminates the issue of single point of failure in transaction security.
In summary,
Single key wallet | Multi-sig wallet |
---|---|
Requires only one key to sign a transaction | Requires more than one key to sign a transaction |
Has no wallet signer combination | Has wallet signer combinations e.g 5 by 7, 2 by 3 |
Just one confirmation which can be a mistake | Requires more than one confirmation, reducing the chance of making a mistake |
Single point of failure | Decentralized format |
USES OF A MULTI-SIG WALLET
Multi-sig wallet has lots of use cases. Some are listed below
Security
A multi-sig wallet can be used to enhance the security of a transaction. It eliminates the incidence of a single point of failure as a transaction has to be signed by more than one cosigner. The cosigners can be the same person using different accounts on different devices, in which case multi-sig wallet is used as a two-factor authentication.
Consensus
Since cosigners are required to sign a transaction before it can be broadcasted, multi-sig wallet can be used to achieve a consensus.
E.g a case where a group of people need to vote on a decision. In such cases, the total number of eligible voters will be the total number of cosigners while the minimum required number will be set according to the rules of the cosigners (i.e 2/3 of the group can make a decision)
Escrow
Escrow is a service where a third party mediates between two transacting parties for a particular transaction. In a 2 by 3 multi-sig wallet, an escrow can be the third cosigner such that once the transaction is completed, the escrow and the seller can spend the funds and if it is cancelled, the escrow and the buyer can spend the funds.
Collective account
With multi-sig wallet, people can come together to have a single account where each of them can be a cosigner and a minimum number is set to sign a transaction. This can fit a family account where members of the family can be cosigners.
SETTING UP ELECTRUM WALLET ON MOBILE
Here's a complete guide on downloading, installing and setting up your electrum wallet on your mobile phone (smartphone)
- Go to google play store and search for 'electrum wallet' then download and install it.
- Open it and click on 'Next'
- Then select 'Multi-signature wallet'
- After that, set the multi-sig wallet to 2 by 3, by adjusting the upper slider. Then click on 'Next'
- Select 'Create a new seed'
- Write down the seed phrase and click on 'Next'
- Then rewrite the seed phrase in the order it was shown using the onscreen keyboard, then click next.
- Your master public key will then be shown. Copy it to an accessible location, click 'Next' and close the app.
You've just created the first 2 by 3 multi-sig wallet. We'll call it cosigner 1
Open the app and repeat the process all over again, to create another 2 by 3 multi-sig wallet. This will be cosigner 2.
After creating cosigner 2, close the app and repeat the process the second time to create cosigner 3.
For each cosigner you create, copy the master public key to an easily accessible location.
Adding the cosigners
After you have created the 3 cosigner accounts, open the app again and click on 'Next' to create a new wallet.
Select Multi-sig wallet and set it to 2 by 3 then click on 'Next'
Then select 'I already have a seed'
- Enter your seed key generated during the wallet creation then click on 'Next'
Your master public key will then be shown to you. Click on 'Next'
Click on 'Enter cosigner key'
- Paste the second cosigner key and click on next
- Click on 'Enter cosigner key'
- Paste the third cosigner key and click on next
- Then you set password to protect your wallet on the particular device.
When you're done, the wallets will be synchronized and it is ready for use.
Note: we just set up the multi-sig 2 by 3 wallet for the first Cosigner.
If you're setting up multi-sig wallet for two factor authentication, you should observe the following steps but if the other cosigners are different individuals, each of them should observe the above setup step, each using their seed keys and any of the other 2 cosigner keys as cosigners 2 & 3 keys.
For two-factor authentication
The setup steps has to be repeated again with the seed key for cosigner 2 used, then master public key for cosigner 1 used as the master public key for cosigner 2 while cosigner 3 remains.
The setup steps are also repeated again with cosign seed key used, cosigner 2 remains but the master public key for cosigner 1 is used as that for cosigner 3.
At the end, you should have three different 2 by 3 multi-sig wallets created.
Confirming the setup
To confirm what you just set up, check the receiving addresses of all the wallets, they should be the same.
DIFFERENCE BETWEEN SEED KEY AND MASTER KEY
Seed key is used to recover an existing wallet. If an existing wallet is to be used on another device, this can be done using the seed key. The seed key is usually a random combination of 12 words or more. Whoever holds this combination can import or recover the wallet.
Master public key is a key which is used for adding a multi-sig wallet as a cosigner in another multi-sig wallet. It cannot be used to recover a wallet in another device.
Seed key | Master public |
---|---|
Is a private key | Is a public key |
Can be used to import an existing wallet | Can be used to add a multi-sig wallet as a cosigner in another multi-sig wallet |
WHICH KEY IS TO BE SHARED WITH COSIGNERS AND WHY?
The master public key (MPK) of a particular multi-sig wallet is to be shared with other cosigners of other multi-sig wallets to add the particular multi-sig wallet as a cosigner to the other multi-sig wallet.
The seed key is a private key and is not to be shared with anyone at all.
HOW MANY m by n COMBINATIONS ARE IN THE ELECTRUM MULTI-SIG WALLET?
In a multi-sig wallet like electrum, an m by n combination is used to setup the number of cosigners
Where:
m = the minimum required cosigners
n = the total number of cosigners
For electrum multi-sig wallet (android version):
The minimum value of n = 2
The minimum value of m = 1
The maximum value of n = 5
The maximum value of m = 5
From the above statistics, (using the format m by n) we have:
1 by 2
2 by 2
1 by 3
2 by 3
3 by 3
1 by 4
2 by 4
3 by 4
4 by 4
1 by 5
2 by 5
3 by 5
4 by 5
5 by 5
That gives 14 different combinations
EXPORTING SEED KEY AND PRIVATE KEY ON ELECTRUM
EXPORTING SEED KEY
Here is how to export your seed key on electrum android version.
- Open your wallet and click on the wallet name
Note that you might have to input your password. This is the first password you ever set on your wallet.
- Then click on 'Tap to show' under 'Seed'
- You have to confirm this in a dialog box
- Then the seed key will be shown. You can copy this down or click on 'Export backup'
EXPORTING PRIVATE KEY
Unfortunately, on Electrum's android version, you can't view your private key or export. I'm referring to the Electrum wallet, android version 4.1.5, the latest as at the time of writing this post.
To see and export you multi-sig wallet private key, you have to copy your seed phrase from the previous explanation and import your wallet to a desktop version.
If you have a pc, here's how to go about installing electrum on a PC
- Go to https://electrum.org/#download and select your device
- Next, download the software and install it
- Then run the software, when its open, click on file, and New/restore
src
- Now set a name for the wallet so you can identify it on the pc. Don't forget we already have a wallet. After setting the name, click 'Next'
src
- Then select 'multi-signature' wallet and click on 'Next'
src
- The wallet we're restoring is a 2 by 3 wallet so set the combination accordingly. Then click 'Next'
src
Now, select 'I already have a seed', then click 'Next'
You will then input your seed which you must have retrieved from the mobile version, then click 'Next'
Now, just like in the mobile version, the Master Public Key will be shown to you. You can us it as a confirmation. Then click 'Next'
Also, like in the mobile version, you will add the other 2 cosigners one after the other (via their master public keys) to completely setup the wallet. You will also set a password to encrypt the keys
Once you're done setting up the wallet, click on the 'Wallet' tab, then click on 'private keys' and then click on 'export'.
src
- You'll have to enter you password before you can export your private keys.
Important Notice: Because I currently have no access to a pc, I have used some of the pictures used by the professor to explain the steps, and I'm unable to provide images for the steps the professor didn't cover. All pictures taken from the professor we're duly sourced.
REAL TRANSACTIONS VIA ELECTRUM MOBILE VERSION
I performed a real transaction via the mobile/android version of electrum. Below are the details
Open the wallet on the mobile version and click on the 'Send' tab
Notice that my balance is 0.25437 mBTC
Copy the BTC address you want to send to and paste it in the bitcoin address field. Paste using the paste icon. Also enter the amount, then click 'pay'
Notice that I sent a partial amount of 0.24 mBTC
Next, you have to confirm the payment. Here, you can adjust the fees by adjusting the traget (ETA) the fewer the blocks, the more the fees
Then confirm that you want to send the payment
After that, the first cosigner has signed the transaction, you'll need at least one more cosigner. Notice that it is indicated at the top 'partially signed (1/2)'.
Notice that I sent to a single address but a second address is receiving coins during this transaction. That is my change address receiving the mBTC not sent to the primary recipient.
When a part of the total balance is sent, the total balance is actually sent out of the wallet but only the partial amount gets to yge primary recipient, the rest is rerouted to another wallet address on your electrum account called change address.
Next, click on the QR code at the bottom of the page to the reveal the QR code for this transaction
Screenshot this QR code and send it to another device, you will need to scan this code to sign the transaction with the second cosigner.
Now, close the transaction details page and click on the menu
Select wallets
Then choose the other cosigner who can sign this transaction. Mine is 'CO1'. Then click 'Open'
On this second cosigner wallet, click on the 'Send' tab and click on 'scan'
Then scan the QR code to bring up details of the transaction. Click on 'Sign'
Confirm the transaction
Now the transaction is completely signed, click on 'broadcast'
That's it, payment will be sent.
Shortly after, payment was sent
RECEIVING ADDRESS AND CHANGE ADDRESS
The receiving address is used to receive coins into the multisig wallet. So to fund your multisig wallet, you'll be needing your receiving address to receive funds into your multisig wallet. This receiving address is usually the same for all cosigners and can be set to expire.
Receiving addresses are coloured green
Change address is the internally generated address used to reroute unspent transaction output. Take for instance:
I have 1 BTC and I want to send out 0.8 BTC, but because BTC will not permit spending unspent transaction output partially, Electrum will have to send out all the BTC in my account during the transaction.
Electrum will send the 0.8 BTC to the address I provided but the remaining 0.2 BTC will be sent to an internal address generated by my Electrum multisig wallet called a change address. Hence the transaction looks like it's has two outputs like in our example transaction
Change addresses are coloured yellow.
Change address | Receiving address |
---|---|
Coloured yellow | Coloured green |
Used during 'send' transactions | Used during 'receive' transactions |
Used to reroute unspent transaction output | Used to receive coins into the multisig wallet |
From the transaction I did earlier, I sent 0.24 mBTC out of 0.25437 mBTC. Thus there were still 0.01437 mBTC. Fees amounted up to 0.00237 BTC, leaving the balance in my wallet as 0.012 mBTC.
CONCLUSION
In conclusion, a multisig wallet is an upgrade of normal single key crypto wallets. Multisig not only has more applications but is also more secured. More than one private key is required to sign a transaction in multisig wallet.
One good example of a multisig wallet is Electrum. On electrum mobile version, you can't access or export your private keys. The wallet is however, very affordable in terms of fees, though it records setbacks in transaction time.
From this lecture, I've learnt how to send BTC over the bitcoin chain at very low costs.
Thanks for reading.
Cc:
@sapwood