Taproot and Schnorr Signatures - Crypto Academy / S5W6 - Homework post for pelon53.

in SteemitCryptoAcademy3 years ago (edited)

Taproot and Schnorr Signatures.jpg

Greetings everyone and welcome to a new week of Steemit Crypto Academy. This week's lesson is on Taproot and Schnorr Signatures. In this post, I would be handling the tasks given by the professor.


C3TZR1g81UNaPs7vzNXHueW5ZM76DSHWEY7onmfLxcK2iQHSwbRLQhAJnn1Rq47VEsGENvLfeFFQfbqGBnTRNq3H3b3QiczV4vnCy9H8vWhfVEZCG64DAaz.png

P2SH and P2PKH

The P2SH and P2PKH are both algorithms that are used to generate transactions in the Bitcoin network. These algorithms are similar, yet so different from each other.


P2PKH

P2PKH is the short form for Pay-to-Pubkey Hash. It is the oldest format of Bitcoin wallet address, making it the most common address type in the Bitcoin network. P2PKH is identified with wallet addresses that start with "1". The P2PKH requires just the key hash as the BTC address and a private key as the digital signature to unlock the funds in the transaction.

Let's take an example. Mr A wants to send some BTC to Mr B. Mr B would send his wallet address to Mr A. The wallet address is the ScriptPubKey. Mr A sends the BTC to Mr B and signs with his private key to approve the transaction. For Mr B to have access to the BTC he received, he must provide his own private key as the ScriptSig to unlock the funds.


P2SH

The P2SH is an algorithm for generating transactions, that supports multi-signatures to approve transactions. It is the same as the P2PKH as the ScriptSig and ScriptPubKey is required for a transaction to be successful. The wallet format for the P2SH starts with "3".

Let's take an example for a transaction that requires multisig. For a company to send BTC to an individual for services provided, the requirement for the transaction would be m of n signatures (i.e m=required signatures for transaction, and n=total number of signatures for the wallet). The transaction can only be completed if m of n signatures approve of the transaction.


C3TZR1g81UNaPs7vzNXHueW5ZM76DSHWEY7onmfLxcK2iQHSwbRLQhAJnn1Rq47VEsGENvLfeFFQfbqGBnTRNq3H3b3QiczV4vnCy9H8vWhfVEZCG64DAaz.png

Differences between P2SH and P2PKH

  • P2PKH stands for Pay-to-Pubkey-Hash while P2SH stands for Pay-toScript-Hash.

  • The wallet format for P2PKH starts with 1, while the wallet format for P2SH starts with 3.

  • P2SH supports multisig while P2PKH does not support multisig.

  • Commissions on the P2PKH are higher than commissions on the P2SH.

  • Transactions with the P2PKH are faster than transactions with the P2SH.


C3TZR1g81UNaPs7vzNXHueW5ZM76DSHWEY7onmfLxcK2iQHSwbRLQhAJnn1Rq47VEsGENvLfeFFQfbqGBnTRNq3H3b3QiczV4vnCy9H8vWhfVEZCG64DAaz.png

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


Use the ScriptSig and the ScriptPubKey to explain the steps that are followed

There are five keys in the multisig portfolio. The ScriptSig requires 3 signatures from the 5 keys in order to confirm the transaction. As the 3 signatures are provided, the program OP_CHECKMULTISIG becomes activated.

Screenshot_20211225-134611.png

The image above illustrates the actions of the ScriptSig in a multisig transaction. As the three signatures are provided, the OP_CHECKMULTISIG would verify that the provided signatures correspond with the five signatures in the multisig portfolio.

The OP_CODE is responsible for generating the SHA-256 and RIPEMD-160 Hash. This code also compares the generated hash to the ScriptPubKey to determine if it corresponds withe the ScriptSig. The function OP_EQUAL is activated if the hash corresponds to the ScriptSig. The 10BTC is then unlocked by the OP_EQUAL function.

Screenshot_20211225-144342.png



"Explain what happens if the transaction is made using Schnorr Signature"

The Schnorr signature makes it possible for the multisig portfolio to make the 10BTC transaction with only one signature.

Screenshot_20211225-151216.png

The image above illustrates the use of Schnorr signature in the transaction. The transaction requiring three out of five signatures was completed with just one signature. The Schnorr signature makes it possible for one signature to be generated and used in the multisig portfolio. As the signature is used to confirm the transaction, the MTC company receives the 10BTC that was sent.


C3TZR1g81UNaPs7vzNXHueW5ZM76DSHWEY7onmfLxcK2iQHSwbRLQhAJnn1Rq47VEsGENvLfeFFQfbqGBnTRNq3H3b3QiczV4vnCy9H8vWhfVEZCG64DAaz.png

Why do you think that Taproot and Schnorr firms will help the privacy of the Bitcoin network? Explain

The Taproot is an upgrade to Bitcoin that was implemented on November 14, 2021. It aims at improving privacy, security and scalability in the Bitcoin network by increasing efficiency. The Taproot would make it difficult to differentiate transactions made with the P2PKH, P2SH and other formats. Much information on transactions would not be revealed on the blockchain with the use of taproot. This improves privacy because anonymity is created during transactions.

Schnorr firms provides privacy and this works hand in hand with Taproot. Schnorr firms make it possible for Bitcoin transactions with multisig requirements to be executed with just a single signature. With the Schnorr firms, the transaction would be recorded on the blockchain as a transaction with a single signature.

On this note, Taproot and Schnorr firms would help the privacy of Bitcoin because:

  • Less data would be recorded on the blockchain

  • Multisig transactions would be completed with one signature

  • Low transaction fees would reduce the data on the blockchain.


C3TZR1g81UNaPs7vzNXHueW5ZM76DSHWEY7onmfLxcK2iQHSwbRLQhAJnn1Rq47VEsGENvLfeFFQfbqGBnTRNq3H3b3QiczV4vnCy9H8vWhfVEZCG64DAaz.png

Practical Work with Blockchain Demo

The first step is to go to the Blockchain Demo site. After that, I inputted the "Schnorr Signatures" as the message and clicked on sign. The signature for the message was given immediately. The signature is 3044022072e9fd6f5f6996c2b820d8932258fcb1a146a6cccb55a57812ba46cecb9f6dfb0220419b1c85b6427a924127dcc02b188399dfe77827eb555e121af8d1db93708ae9.

Snapchat-590117869.jpg

I switched over to the "verify" tab and inputted the signature. I clicked on "verify" afterwards. The screen was highlighted with a green colour, indicating that the signature I inputted matches the signature for the message.

Snapchat-1727188383.jpg

In this step, I deleted the first letter from the message. I went on to input the signature I generated from the initial message and clicked on "verify". The screen was highlighted with red which indicates that the signature does not match with the current message (i.e chnorr Signatures).

Snapchat-844048156.jpg

This is an illustration of transaction in real life. If the generated hash does nor correspond with the ScriptSig, then the transaction cannot be completed. This helps in preventing scams like double spending because the hash for every transaction is different.

NOTE: All images used in this question are gotten from the Blockchain Demo site


C3TZR1g81UNaPs7vzNXHueW5ZM76DSHWEY7onmfLxcK2iQHSwbRLQhAJnn1Rq47VEsGENvLfeFFQfbqGBnTRNq3H3b3QiczV4vnCy9H8vWhfVEZCG64DAaz.png

Conclusion

The P2SH and P2PKH are both wallet formats used for the BTC network. The P2PKH is also known as legacy address because it is the oldest format. It also facilitates fast transactions in the network.

On the other hand, P2SH supports multisig transactions. This makes transactions requiring multiple signatures to be approved on the network.

With the introduction of Schnorr Signatures, the multisig transactions can be approved with a single signature. This improves privacy, scalability and efficiency in the blockchain.

Cc: @pelon53

Sort:  
Loading...

Coin Marketplace

STEEM 0.18
TRX 0.13
JST 0.030
BTC 58119.97
ETH 3054.21
USDT 1.00
SBD 2.26