Crypto Academy Season 3 | Advanced course - Task 5: Multisig Wallet(Electrum)-- "m of n" Combinations
A wallet is a dApp on top of Blockchain to enable you to send/receive and/or manage your crypto assets. All of us are familiar with a wallet and sending a transfer to another peer is a very basic necessity/use-case in the crypto ecosystem.
In Week 3 we covered how to send multiple outputs in a single click. So when we consider a transaction, the various parameters we come across are input, output(s), Txn ID, etc. To make a transfer we need to sign it.
This week we will discuss in detail about Mutlisig wallet and will practically explore sending a transaction which would require multiple signatures to broadcast it. We will keep it central to BTC(Electrum Multisig Wallet).
In general, a transaction requires the sender(owner of the private key) to sign it and broadcast it to the network. When we say this, we refer to a single owner who has exclusive access to the fund. So technically only one private key is needed to sign & broadcast a transaction.
By contrast, a Multi-signature wallet is one that requires two or more signatures to sign and broadcast, so technically here you need two or more private keys to sign the transaction.
A Multisig wallet generally comes in "m of n" combinations where:-
- m refers to the number of signatures or authorization
- n refers to the number of cosigners
"m of n" combinations can be 2 of 3, 3 of 5, 5 of 7, and so on.
For spending in a Multisig wallet[m of n] you need at least m signatures to broadcast a transaction.
For instance, in a 2 of 3 wallet, you need 2 out of three cosigners to sign that transaction and broadcast it to the network. In other words, we can say at least 2 out of 3 co-owners must agree to spend.
Single key, Mutlisig & Use-Case
A single key wallet always has a very limited and restricted business use-case, mostly signifies an individual owner of the wallet.
Multisig wallet brings a wide variety of business-use to the table and in addition to that, the use-case of a Multisig wallet can also make an individual owner more secure, as a Multisig wallet can also be used like 2-factor authenticator(in a decentralized way) just like the OTP, 2 FA in centralized Exchange Wallet.
A single key wallet can be easy prey for malicious elements with phishing attacks, whereas a multisig wallet shields the owner(s) from such risks. Because the malicious elements have to hack "m" nos of keys to spend the fund.
From an organization/business perspective, a single key wallet is undesirable as that could be a single point failure. Further, with a single key wallet, the execution of distributed decision-making process is not possible.
From the security point of view, A Multisig wallet always adds an additional layer of security to the funds.
For organizations, a Multisig wallet can be used to reach a consensus.
So the potential use-cases of Multisig wallet are:-
With [2 of 3] Multisig wallet the buyer and seller can trade in a decentralized way for the exchange of goods/services, they can bring in a third party as arbiter into the loop, only in the case of a dispute.
- If the Buyer and Seller agree, then they can easily spend the fund in a 2 of 3 Multisig wallet
- In the case of a dispute, either arbiter, and the buyer or arbiter and the seller can spend the fund
(2) Joint Account in Family
Husband, Wife, Kid (or any other Members) can create a [m of n] Multisig wallet for the Family, and they can spend based on the collective decision within the family.
(3) Additional Layer of Security
By default, a Multisig wallet enhances the security features as multiple keys are required to spend the fund. So apart from being an Enterprise solution, it has its use for the individual owners too.
Setting up a 2 of 3 Multisig wallet can act as Two-Factor Authentication.
- Wallet 1- Desktop
- Wallet 2- Smartphone
- Wallet 3- Paper Wallet(Offline)
So every time a user needs to spend, it requires to sign it from at least two wallets. So he/she has to sign it both on the desktop and Smartphone. In case, he lost his Smartphone, he can use a paper wallet or should restore the wallet to a fresh device.
(4) Consensus/Decision Making
Let's say a company has 7 board of directors, and as per the constitution of the company, 5 out of 7 need to sign to reach a consensus.
So they can set up a [5 of 7] Multisig wallet and only when the majority agrees(at least 5 out of 7) they can spend the fund. So it will be more fair and transparent for the business process too.
How does it work
Contruct a Multisig Wallet
Send a Transaction using [2 of 3] Multisig Wallet
Setting up of a 2 of 3 Multi-sig wallet
Some of the best and reliable Multisig wallets are Electrum, Coinbase, Bitgo, etc, but we will practically explore it in Electrum today.
Click on Window Installer (for Windows 7 and higher). For Android it is available on Google Playstore,(you can also download it from here).
After the download is completed, install it.
Then go to File, create a New Wallet file. Name it as Wallet file-1(or Cosigner 1). Click on Next.
Select the Wallet Type-- Multisignature Wallet. Click on Next.
Now specify the combination (m of n-- Signature/Co-signer), as we are setting up a 2 of 3 Multisig wallet, there will be 3 co-signers and a minimum of 2 signatures needed to spend. Adjust the slider to set 3 co-signer and 2 signatures. Click on Next.
Select Create a new seed. Click on Next.
Now it will display the seed key, write down the 12 words phrase(seed key) on your notebook/diary/paper, keep it safe, preferably offline. Click on Next.
Confirm the seed key by entering the 12 words phrase in the correct order. Click on Next.
Now it displays the MPK(Master Public Key). It always starts with the letter Z. Copy the MPK, and share it with your co-signers. Click on Next.
You are not done yet, Now you need to follow up with your co-signers to receive the MPKs. As we are setting up a [2 of 3] Multisig wallet, you need the other two MPKs from your cosigners to construct this Multisig wallet.
So basically your Co-signer will repeat the process as we did until now and they will also ask you for the MPK to construct 2 of 3 Multisig wallet. Never share the seed key. You only need to share the MPK with your co-singers.
You should also note down your MPK as well as the MPKs of your co-signers on a piece of paper, or you can also print it.
Now it will ask you to add the co-signers( 2 of 3). You can add them by entering their MPKs. For that select Enter Cosigner Key. Click on Next.
Now paste the MPK of your Cosigner in the designated box. Click on Next.
Again it will ask you to enter the MPK of the Cosigner(3 of 3). Simply paste the MPK of the third Co-signer in the designated box. Click on Next.
Now set a password to encrypt the Wallet keys. Click on Next.
You are good to go now. Your [2 of 3] Multisig wallet has been constructed.
Important Note- You Cosigners have to follow the same process to construct the [2 of 3] Multisig wallet.
Now the very first thing you should do is to check whether the receiving address is showing as same in all three wallets or not. Ask your co-signers to verify the Address.
You should generate New Address first, for that click on the Receive tab, then set Expiry as Never. Generate New Address.
Now ask your Cosigners to do the same and cross-check whether the receiving Address is the same or not. It should be the same for all three cosigners.
If you click on Receive Tab, you can notice a number of addresses with two types: Receiving & Change. Always share an address with Type as Receiving, the Change Addresses are for the internal purpose of the wallet.
What is the difference between "Receiving" & "Change Addresses"?
Let's say there are three receiving addresses in your wallet with three different amounts, 0.1 BTC, 0.2 BTC, and 0.15 BTC. And you want to send 0.4 BTC to someone, and in three addresses you have a total of (0.1+0.2+0.15) BTC means 0.45 BTC.
So when you send 0.4 BTC to someone, it will send the entire 0.1 BTC(of Address 1), the entire 0.2 BTC (of Address 2), and 0.1 BTC of 0.15 BTC(of Address 3).
But it does not happen like that. Recall the double-spending issue. In Bitcoin, it prevents you to spend unspent transaction outputs partially.
So technically what happens, when you spend a UTXO, it becomes an input for a new transaction and now it can be sent to a number of outputs, but it has to be spent in full. So what Electrum will do is that it will send the 0.4 BTC to the designated address entered by you, and then for the remaining 0.05 BTC it will create another Address within the wallet, which is known as Change Address.
You have nothing to do with Change Addresses, just leave them as they are; they will be utilized as another input when you make the next transaction.
UTXO- Unspent Transaction Output.
Let me explain in the simplest possible way. Let's say you walked down to a Superstore to buy the essential commodities. The billing amount is 450 INR. You hand out a 500 INR denomination at the billing counter, which means you can not divide a denomination of 500, that has to be spent in full, in return, the cashier will return a change of 50 INR to you(because the billing amount is only 450 INR).
So the 500 INR is the UTXO here, it has to be spent in full. Depending on the billing amount, the Sender will receive a change of 50 INR. So 50 INR is the change address here.
Close the wallet. Open it again.
Go to File. Click on Open. Select Wallet_1(or Cosigner-1). If you have named it differently, then accordingly select yours.
Enter the Password, Click on Next.
So now we would perform a transaction from Multisig Wallet[2 of 3]. Please note that at least 2 signatures are needed to spend.
Click on the Send tab, enter the recipient Address(output Address) against "Pay to".
Then enter Amount in mBTC.(I have a balance of 0.33585 mBTC, and I will send 0.27 mBTC, so I am sending a partial amount)
Click on Pay.
Now you need to Enter the password to Send. Click on Send.
You can also adjust the fee by clicking Advanced, and set the rate per byte you are willing to pay for this transaction.
Now pay attention to the Outputs. Interestingly I entered only one output, but here it is displaying two outputs, however, it has earmarked one as yellow and specified as Change Address. That means the UTXO of 0.33585 mBTC will be spent in full and via a change Address, Electrum will route the partial amount back to my Wallet.
You are not done yet, recall it's a [2 of 3] Multisig wallet, so you need one more signature at least. So first export this Transaction to File. Click on Export to File, and save it. (Alternatively, you can also Copy to Clipboard, or use QR code)
We will go to Wallet_2(or Cosigner 2) now.
Click on File, then Open, then select Wallet_2. Enter the password, Click on Next.
Now from Wallet_2(Cosigner 2) click on Tool, then Load Transaction, from File. Then select the transaction file, click on Open.
You can now sign this transaction, pay attention to the status on top left, it's showing as partially signed with (1/2), 1 signifies one co-signer has already signed, 2 means at least 2 signatures are needed to broadcast this transaction, so now, you can proceed to Sign it. Click on Sign.
Enter the password, Click on OK. Status changed to Signed now. Finally, click on Broadcast.
Now click on the Addresses tab, you can notice a Change Address is reflecting the remaining balance of your wallet.
Go to Block explorer now(Blockchain.com or Blockchair) and input the transaction ID or Address.
Now you will notice that the input is one but the outputs are two, you must be wondering how come another output get into the picture whereas I entered only one output, the second one is the Change Address automatically created by Electrum to route the remaining balance back to your wallet again because UTXO can't be spent partially.
Backup Seed & Export Private Keys of Individual Addresses
Open your Electrum Wallet.
For Seed-- Click on Wallet, then Seed, then enter Password, Click on OK.
Export Private Keys
Click on Wallet, then Private Keys, then Export, enter Password, Click on OK.
Please note that in a standard HD wallet, all the private keys are rooted to a single seed key.
mBTC= One thousandth of BTC, so 1 BTC= 1000 mBTC
Homework Task (Season 3/Week-5)
(1) What is a Multi-sig wallet? How is it different from a Single key wallet? What are the different uses of a Multisig wallet?
(2) Download, install & set up a 2-of-3 BTC Multisig wallet(Electrum)? What is the difference between Seed key and MPK? Would you share the seed key or MPK with your co-signer and Why? (Screenshots Needed)
(3) How many different "m of n combinations" Multisig wallet you can construct in Electrum? How do you Export your Seed & Private Key(Electrum) in a Multi-sig wallet? (Screenshots needed)
(4) Perform a real transaction(Send BTC) to another Address using a 2 of 3 Multisig wallet? (You can perform a micro-transaction for this Task, also send a partial amount to demonstrate your experience with Change Address, screenshots needed).
(5) What is the difference between Receiving Address & Change Address? Demonstrate your experience with a Change Address?
Please note that BTC transaction fee is not that high(that is expensive only when you use Centralized Exchanges), So I would suggest you using ChanngeNOW to exchange your Altcoin to BTC if you don't have BTC(It is indeed very cost-effective, costs less than $0.4 for 15 USD worth exchange).
Further, ChangeNOW might not support a Multisig wallet address, in that case first create a standard wallet in Electrum, and then use that address for the exchange in ChangeNOW. From the standard address, you can transfer the BTC to your Multisig wallet. Then you can perform the transactions for this Task. If you still need any help on this, join me in the comment section.
- Your article should be at least 300 words.
- It is always better to gain sufficient user experience before submitting your article.
- Refrain from spam/plagiarism. This task requires screenshot(s) of your own experience. Use images from copyright-free sources and showcase the source, if any.
- This homework task will run until 31st July'2021, Time- 11:59 PM UTC.
- Users having a reputation of 60 or above, and having a minimum SP of 500(excluding any delegated-in SP) are eligible to partake in this Task. (Must not be powering it down)
- Add tag #sapwood-s3week5 #cryptoacademy in your post and should be among the first five tags. You can also use other relevant tags like #electrum #wallet #multisig #blockchain or any other relevant tag. And also make sure you post in the Steemit Crypto Academy community.
- Those who include the real transactions/screenshots will score better.
- Always hide sensitive info.
(Please feel free to join the comment section if you have any doubt on Homework-Task)