Introduction
Hello Crypto Lovers,
Season greetings to you all and Happy new year in advance. This week marks the sixth week in week 5 at the academy. I am Kehinde Micheal and my username is @msquaretwins here on this great platform. I have gone through the lecture presented by Professor @pelon53 on "Taproot and Schnorr firms" in the intermediate class. Therefore, in this post, I will be answering the questions posted in the homework section. Happy reading!
1. Explain in detail the P2SH and P2PKH, show the differences between both directions.
Bitcoin has so many great feature and this makes it very popular and well known among many other cryptocurrencies. The nature of this cryptocurrency helps users to predetermine how they want to spend their fund because of the opportunity given to user to set how their fund can be used on the system. In blockchain, crypto assets are kept in a wallet. Wallet in this case acts as bank account in the traditional system of transaction. Before any transaction can be made, owner of the wallet will have to sign the transaction with a private key to his wallet. This means that a key is used to unlock the wallet and there after, it is locked with a lock.
There are two types of scripts that are used in sending and receiving crypto asset on bitcoin network. They are scriptSig and Scriptpubkey. The scriptSig can be regarded as a key and the Scriptpubkey as the lock which help in locking of fund after verification of transaction by the ScriptSig. Both P2SH and P2PKH are both features of Bitcoin script which are called Bitcoin address format.
What is P2SH?
P2SH means Pay To Script Hash. It is a Bitcoin address format that was created when the bitcoin block reached Block 173805 on the blockchain network. Before the creation of P2SH, P2PK (Pay To Public Key) and P2PKH (Pay To Public Key Hash) were the only available bitcoin address format. P2SH uses script function that often include either P2PKH or P2PK payment plus a script.
In P2SH, When a sender initiate a transaction, the crypto asset is blocked by the Hash with which the script is made. The output of the transaction is then broadcasted to the blockchain network. Then the block miners would run the script that is broadcasted and if the result is true, the output script will be sent to the respective recipient. The receiver on his side will have to provide the script that the sender used to create the hash and this must comply with the condition of the hash.
More so, the transaction that is made on bitcoin network are coded as sequence of instruction which are often called script and this series of instruction give directive of how each user will spend their crypto asset. P2SH bitcoin address format start with 3. For instance, this address wittwn below is an example of P2SH bitcoin address format –3m45j2WrWXC9GDsTjopfsdopneMhraGFTf. P2SH is mostly used for multisig addresses which will help to identify that multisig signature are required to validate a transaction. One of the importance of P2SH address format is that users can use it to send crypto asset to P2PKH and bech32 bitcoin addresses format.
P2SH also allow sender to placed the onus of paying network fee on the receiver instead of him paying it.
What is P2PKH?
P2PKH means Pay To Public Key Hash. This means pay to the receiver public key hash. It is a bitcoin script that lock crypto fund to the hash of public key. It is the most commonly used bitcoin address. The address that use P2PKH starts with 1 instead of 3 as in P2SH. In P2PKH, the public key is made not to be visible to the public only the hash is visible.
In P2PKH, the users will be required to supply a signature from his private key and public key. Then the signature and the public key is then used to check if the output is correct with the public key hash. Then if this is correct, the fund will be send to the recipient. The holder must provide the public key hash and the private key before the money can be spent.
Let's take a look at this illustration to get to know how P2PKH works. Let's assume that A want to send 0.1BTC to B. A will ask B to send his bitcoin address. Then A will initiate the transaction and the send it. The output of A's transaction will be broadcasted to the blockchain as PubkeyScript. Then the 0.1BTC will appear in the B wallet address. Then for B to spend the money, he has to provide a proof that he owns the fund by creating a "scriptSig" with Public key and his signature.
Difference between P2SH and P2PKH
P2SH | P2PKH |
---|---|
The address format in P2SH start with 3 | The address format in P2PKH Start with 1 |
P2SH address can be used for Multisig transaction | P2PKH can not be used for multisig transaction. |
The sender used the hash of scripts to lock the fund in transaction with P2SH | The fund is locked to the hash of public key |
The transaction fee is not as expensive as that of when P2PKH | The transaction done with P2PKH is more expensive. |
It has a feature where senders can put the charge or network fee on the recipient of the fund instead of paying themselves | This does not happen with P2PKH address format. |
2. It is required to transfer 10 BTC that belong to a 3 of 5 multi-signature portfolio, to the MTC company, for the purchase of some equipment.
(a). Use the ScriptSig and the ScriptPubKey to explain the steps that are followed.
Firstly, I will explain the steps that is required to transfer 10BTC that belongs to 3of 5 multi signature portfolio using the Scriptsig and the scriptpubkey. The transaction of 10 BTC that belong to a 3 of 5 multi-signature portfolio to the MTC company implies that 5 addresses are present in the transaction and 3 of them must sign the transaction. The signing of the transaction can be done by any three of them.
For instance, let's assume that 5 individuals, User 1, user 2, User 3, User 4 and User 5 want to send the 10BTC to MTC company, they all have their private key with them, but only 3 of them will be allowed to sign their transaction. This is where the ScriptSig comes in. The scripsig is used to unlock the fund and this will confirm that the three users that signed the transaction hold the key that correlate to the remaining keys that are related to the transaction. At the confirmation of the transaction by a OP_CHECKMULTISIG, the bitcoin asset is then unlocked.
Then the next step is the use scriptpubkey. The of SHA-256 hash will be created by OP_HASH160 and this will confirm that the public key hash created is related to the scriptsig. At the confirmation of SHA-256, the fund will then be sent to the MTC company.
The image uploaded below clearly shows the illustration of ScriptSig and the ScriptPubKey in explaining the 3 of 5 multi-signature portfiolio.
(b) Explain What happens if the transaction is made using Schnorr signatures?
If the transaction done in question a above is to be done using schnorr, the 5 users will combine their private keys and a new but just one key will be generated. This new generated will thwn be used to sign the transaction instead of the 3 signature. The use of schnorr signature for this transaction will help to keep the private keys involved secret since only one key will be used to unlock the fund.
The image uploaded below shows what happened in schnorr signature.
As seen in the screenshot uploaded above, the give private keys are merged together to form a schnorr key which is then uses to unlock the transaction.
3. Why do you think that Taproot and Schnorr firms will help the privacy of the Bitcoin network? Explain.
Since inception of bitcoin in 2009, many development have been done to make sure that bitcoin blockchain keep serving the users at it maximum. Although, bitcoin has face some issues especially the issue of privacy or security in the past but continual effort of the developers in solving the privacy issue has been applauded by my crypto communities. One of the technology that is built to solve the issue of privacy in bitcoim blockchain is Taproot which comes along with what is called schnorr.
Taproot is a new technology that is incorporated to bitcoin on the 14th of November, 2021. The taproot signature also comes with Schnorr signatures. The technology is developed to improve the scalability of botcoin as well as increase the privacy and security.
When a user, say user A wants send 2 BTC to someone, he will collect the wallet address of the recipient and fill the detail and then send the transaction. The transaction is validated by the use of sender's private key. Then the transaction is broadcasted to the blockchain network. The miners then verify the transaction by the use of generated public key.
But there is always an issue if the 2BTC to be sent is not own by an individual. Which means certain number of people that have the keys associated with the fund will have to sign the transaction through multi signature. In this case, there is always a delay in executing the transaction and the size of the transaction data is always too large. This is where schnorr signature, an implementation that cane with taproot comes in.
With the use of Schnorr signature, all the require keys in transaction that involves multi signature are merged together to become what is known as schnorr key. Then only the schnorr key is used to unlock the fund and this makes it easy to be very fast. Apart from the high scalability that comes with the use of taproot and Schnorr, privacy and security are also improved. This is because, instead of unlocking of fund with multiple keys, only one key is used and this enhance the privacy and security.
More so, schnorr and taproot improve the security and privacy in the sense that users do not need to display all the scripts, the script with which the transaction is signed is only the script they are required to present, and the others are kept secret.
4. Using the Blockchain Demo, write exactly the following message: Schnorr Signatures, generate the message signature and verify the message. Then delete the first character from the message signature and check again. What happened? Explain. Screenshots required.
• For this question, I entered the site for demo transaction developed by Andersbrownworth.
• The the site appeared for me as displayed below. I clicked the sign section as indicated by a red box. Then I wrote "Schnorr Signatures" on the message box and finally I vlicked "sign" button as indicated by a black box in the screenshot below.
By signing the transaction tith the Private key: 9892574030048152125730163045967226039892200411134790016162860305946136429833, the message signature was generated for me. The message signature is: 304502206d8bb96a7885624183b9d276668befa0ae8fb2fa9fd978ea6f29802e8a07c249022100de814198e376e0728b20a9eb07323046ce2f4f96bb9a1aa7e9ed87a6e00620e2
• Then I proceeded to verify the message by clicking the verify section as indicated by a black arrow in the screenshot below. Then I clicked the verify button as indicated by a black box in the screenshot below
Then, the background of the message turned to green as seen in the screenshot below. This shows that the authenticity of the signing of the message with private and the verification with public key. This shows that the code is true.
Removing the first character of the Message Signature
I deleted the first character from the message signature to see what will happen to the verification.
Previous Message signature: 304502206d8bb96a7885624183b9d276668befa0ae8fb2fa9fd978ea6f29802e8a07c249022100de814198e376e0728b20a9eb07323046ce2f4f96bb9a1aa7e9ed87a6e00620e2
New Message Signature: 04502206d8bb96a7885624183b9d276668befa0ae8fb2fa9fd978ea6f29802e8a07c249022100de814198e376e0728b20a9eb07323046ce2f4f96bb9a1aa7e9ed87a6e00620e2
As we can see, "3" which is the first character in the previous message signature was removed and then and the rest becomes the new message signature as seen in the picture uploaded below. Then I clicked verify button as indicated by a black box in the screenshot.
When I clicked the verify button in the above picture, the background of the message turned to red and this indicate that the message signature is not the same as that used in signing the transaction.
Conclusion
This post has explained the benefits and advantages derivable from Taproot and Schnorr which is the new upgrade in the Bitcoin ecosystem. This new upgrade has been established to be capable of improving Bitcoin scalability, security and privacy. Therefore, with this new upgrade I see Bitcoin ecosystem hosting many smart contracts and DApps on their network, and this in turns will increase the number of Bitcoin users.
I also explained the two most popular Bitcoin address format in this post. I also explained the difference between the two. Also, I demonstrated with necessary screenshot the signing of message and verifying of the message on a demo website by Andersbrownworth. Special thanks to Professor @pelon53 for this great and awesome lecture.
Thank you for reading.
cc: @pelon53
Congratulations @msquaretwins 🎉 on achieving the 65 Rank after doing hard work. Now, you can participate in advance course. I really appreciate your work that you have done so far.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you so much @noshi. I appreciate your congratulatory message.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit