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

in hive-108451 •  3 years ago 

Hey Steemit!



Here is my homework post for Professor @pelon53. It was a great lesson, and I hope you will enjoy reading my post.
Corsen Builders (2).png

Image made on Canva


Crypto_Academy_divider_3.png

1. Explain in detail the P2SH and P2PKH, show the differences between both directions.

Crypto_Academy_divider_3.png


P2SH


P2SH was launched on April 21 as a standard script. P2SH stands for Pay to script hash, and it is a particular type of payment in "Bitcoin script". It authorizes you to lock Bitcoins to the hash of a script, and then you have to provide the original script if you want to unlock those Bitcoin.

To put it simply, it lets you create the custom script that you can use to lock and unlock your Bitcoins

P2SH provided a method that authorized the senders to place the responsibility of paying additional network fees on the recipient rather than themselves. Before the activation of P2SH, the senders had a standardized way of implementing their custom scripts, and it was possible to customize scripts, but it was complex and time consuming for most users to write. P2SH vastly facilitated the procedure through simple-to-use script hashes and identifiable Bitcoin wallet address formats, which was incredibly effective because the old scripts were challenging to write.


P2SH Working


The locking script encompasses the hash of your custom locking script (the *" script hash" *), enclosed by the HASH160 and EQUAL opcodes:

PicsArt_12-23-03.02.16_1.jpg

Unlocking script encompasses your original locking custom script (the *"redeem script" *) proceeded by data necessary to unlock it.

PicsArt_12-23-03.28.56_1.jpg

Meaning the unlocking script above, the redeem script is a P2MS locking script itself, and the preceding signature is required to unlock it.


Advantages of P2SH



Multisig


The primary use case of P2SH is the proficiency that effortlessly supports multiple transactions. In the end, this provides additional security for a group of individuals or companies that wants to guarantee that no one steals or moves the BTC from shared wallets.


Security:


Even though the P2SH transactions usually incorporate a highly complicated set of instructions and cryptography hashing ensures that the script has the same tier of security as P2PKH.


Easier For Senders:


Another advantage is that the senders no longer need to write complex logic on behalf of recipients. A P2SH transaction is executed simply by sending a standard address configuration with '3'. There's also no need for senders to pay an extra cost for storing extra bytes corresponding to the more complex scripts on the blockchain.


SegWit and Non-SegWit Support


A private key procured by Bitcoin is used to create a wallet in P2SH. It is also known as " Nested Segwit". However, it is nowhere near as complete as Native SegWit (Bech32). P2SH is compatible with non-SegWit (P2PKH) and SegWit (Bech 32) addresses.


Computationally Efficient:


The scripts of P2SH are more petite than P2MS (Pay to multi-sig), meaning less RAM is required for the UXTO set, which elevates the speed of transaction validation.


P2PKH


P2PKH has been used in Bitcoin protocol since January 16, 2009, and this is a default script used in most of the Blockchains, meaning it is easily found.

P2PKH transactions are very similar to that of P2PK's. Both payment types require the recipient to prove the ownership of their private key if they want to receive their funds. The only difference between P2PKH and P2PK is that P2PK transactions are sent directly to the recipient's public key, while in P2PKH, the transactions are sent to the hash of the recipient's pub key. A hash is an algorithm that takes an arbitrary amount of data input, and after the intake, it produces a fixed size of enciphered text called a hash value, or just "hash."


P2PKH working


The code for P2PKH has hashed public key surrounded with opcodes in the following screenshot.

PicsArt_12-23-04.21.10_1.jpg

In order to solve the above script, the owner of the hashed public key have to provide the original public key, along with a valid signature for it.

PicsArt_12-23-04.42.23_1.jpg

In short, when this script runs:

  • The original public key is "DUP" licated and then HASH160'ed.
  • This hashed value is then compared with the hashed public key in the scriptPubKey to ensure it is EQUALVERIFY.
  • If it matches, the script continues, and the CHECKSIG checks the signature against the public key.

Difference between P2PKH and P2SH


P2PKHP2SH
*Pay to pubkey hash or P2PKH is a Bitcoin address that starts with "1" and is still compatible with Bitcoin today.Pay to script hash* or P2SH is a Bitcoin address that begins with "3".
This address format isn't segwit compatible, meaning the transactions costs a lot due to the larger size.It allows Multisig transactions. It's an upgrade from a legacy address (P2PKH).
It is most compatible as it's the original addressing scheme, the most expensive to use.It has lower fees and allows for multi-signature (multi-sig) transactions; more costly to use than bech32.


Crypto_Academy_divider_3.png

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.

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

●Explain What happens if the transaction is made using Schnorr signatures?

Crypto_Academy_divider_3.png


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


So if anyone wants to transfer any amount of BTC
to a multi-signature portfolio, 3 of the 5 addresses must be present during the transaction. For example, there are five parties, party V, party W, party X, party Y, Party Z, and they want to pay 10 BTC to the MTC. To make this transaction possible, two scripts are used ScriptSig and ScriptPubKey. ScriptSig uses a command called "OP_CHECKMULTISIG" this code will check the conditions and check if all three signatures correspond to all the keys. If they are, then the funds will be unlocked, and if they aren't, it'll be cancelled.

Once that is done now with we will have to unlock the ScriptPubKey using the SHA-256 is confirmed. If you are confused about how you get the SHA-256 hash, you can generate it from the OP_HASH160 code. Once the SHA-256 is established, now to make the transaction successful OP_HASH160 codes must be correlated with OP_EQUAL codes, and once that's done, then the transaction will be done.

WhatsApp Image 2021-12-25 at 9.42.43 PM.jpeg


Explain What happens if the transaction is made using Schnorr signatures?


Five different parties want to send their BTC, and each of these parties has a private key that they keep secret from their other members. Now each of them will derive a public key corresponding to their private key that they will share, and they will merge these public keys to make a new public key we will name it "Public key ABCDE". Each of these members needs to use their keys to sign the same transaction creating independent signatures. Now they will merge these signatures and call it "Signature ABCDE", and we only need this public key ABCDE and Signature ABCDE to make the transaction of 10 BTC.

WhatsApp Image 2021-12-25 at 9.15.39 PM.jpeg

WhatsApp Image 2021-12-25 at 9.15.49 PM.jpeg

WhatsApp Image 2021-12-25 at 9.15.56 PM.jpeg


Crypto_Academy_divider_3.png

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

Crypto_Academy_divider_3.png

Schnorr/Taproot has been making progress at an incredible pace. Moving with theoretical privacy was d scaling the idea into actual code. While many people from the community are excited about the changes, quite a lot of people find them confusing. Now you might be asking why? Because it bundles together several different technologies that have been proposed over the years, and each of them is technically and conceptually unique from each other.

Bitcoin lacks two things: scaling and privacy, but as much as this update is needed, massive updates like this are tricky and, as such, are far and few between in Bitcoin.

Now there's one thorny issue deciding what would go into the update?

"I think the biggest struggle in the process was to come up with the exact set of features to deploy at the same time,"
-Blockstream researcher Tim Ruffing told CoinDesk.

Source


What is Bitcoin Taproot upgrade?


Taproot is a soft fork that increases Bitcoin's scripts to enhance privacy, efficiency and the network's ability to process smart contracts. This upgrade is deemed the most significant Bitcoin upgrade since the segwit upgrade in 2017.

Taproot upgrade consists of 3 different distinct Bitcoin Improvement Proposal (BIP), including,

  • Taproot
  • Tapscript
  • and its core - the new digital signature scheme named Schnorr signatures.

Taproot aims to benefit the Bitcoin users, such as enhanced transactions, privacy, high security and minimum transaction fees. It also enables Bitcoin to execute a more complicated transaction, which will ultimately widen its use cases that compete with Ethereum, especially on innovative contract capabilities and supporting Decentralized Finance (Defi) and non-fungible token (NFT) on the network.


Explaining Tapscript


Tabscript is an upgraded version of the Bitcoin programming language and a collection of opcodes. Tapscript is a set of instructions for transactions that are used to specify how to be performed, and With more available space in the blocks, it enables the more straightforward addition of new features and builds on the batch verifiability of Schnorr signatures.


Schnorr Signatures


Schnorr Signatures consists of a cryptographic scheme signature that Claus Schnorr developed. Claus Schnorr was a mathematician and a cryptographer. Even though he thought he had his algorithm protected under a patent for several years, the patent ultimately expired in 2008. Among the many benefits of schnorr, it is predominantly known for its simplicity and efficiency of generating short signatures.


Crypto_Academy_divider_3.png

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.

Crypto_Academy_divider_3.png

First, to access the blockchain demo, we have to go to the link: blockchain demo

Screenshot_20211224-185232_1.png

As you can see, I have written the message "Schnorr Signature", and then we will click on sigh and get a signature.

Signature: 3046022100f325a31d9c6b14b513f5cbe317406bb11a76987bbf384e774e5cee56ba232bf10221008ead9e78a0b579898a9b9a6948c28fde638be1d887345e0645be17d98b02d7ed

Once that is done, we will verify the signature.

PicsArt_12-25-04.29.50.jpg

Now we will verify the code, and I noticed that the site's background colour changes if the signature is right and wrong. Here I verified the signature, and the background turned green, indicating that the signature matched.

Screenshot_20211224-185527_1.png

Next, I removed the three from the start to check if something different happened, and as expected, the site turned red, indicating that the signature didn't match.

Screenshot_20211224-185255_1.png


Crypto_Academy_divider_3.png

4. CONCLUSION

Crypto_Academy_divider_3.png

My closing thoughts about all this is that Taproot is widely supported and a highly anticipated upgrade brought to Bitcoin implemented along with Schnorr signatures. We can see some significant privacy scalability and security improvements. If these upgrades were to be implemented, they could generate more interest around the Lighting Network and encourage multi-sig to be more of an industry standard.

Regardless of your involvement or what you think about the Bitcoin community, these added benefits of improved privacy, efficiency, and security will most likely impact your experience with Bitcoin.

It was a great lesson, and I thank Professor @pelon53. for giving us such an amazing lesson.


Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  
Loading...