Posts

Understanding CryptoGraphy - Final Part

avatar of @menoski
25
@menoski
·
0 views
·
4 min read

Hello everyone, hope you all are doing good? I'm back with the Part 5 and Final Part of this amazing series, Understanding CryptoGraphy. If you haven't read the Part 1, Part 2, Part 3 and Part 4, I strongly suggest you that by clicking here for Part 1, here for Part 2, here for Part 3 and here for Part 4. In today's article we would be looking at the practical aspect of cryptography.


Source


Keys

I will be explaining how Private and Public keys works and also how they are related in way.

From the image, you can clearly see that Public keys are generated from Private Keys.



I clicked on the button "Random" a new random Private Key was generated and because a new Private key was generated, a new Public key was also generated. Look at the image below for more understanding.



I went ahead to input a unique Private Key of 55555, and a Public key was generated from the new Private key. Look at the image below for more understanding.



Signatures

I will be explaining how we need our Private key in order to sign a transaction and also how miners verify our transactions by verifying if the Private key used is related to the Public key of that wallet.

From the message below, I inputted Menoski as the message and my Private key is needed to sign the transaction, so I inputted my Private key, 55555.



The message has been signed, which will result to the message signature created, which will have to verified by the miners of the blockchain.



As a miner, you will see the message signature of the transaction and the wallet's Public key will be displayed to verify the transaction is coming from that specific wallet. Look at the image below for more understanding.



As soon as the miners click on "Verify" and the background color changes to green, confirming that the message signature has been verified. Look at the image below for more understanding.



Transactions

When making a transaction both your public and private keys are used. When you are sending money, in your conventional online banking system, you will require to have a bank account number and receiver's account number, with your ATM pin/password, right? Same thing applies in the cryptography, you will need your Public key which will serve as from where the funds is going out from and a receiver's address where the funds is going to. And you will need your Private key as your password, to sign the transactions in order for it to be broadcasted to the network and once the transaction has been signed, a message signature will be created for the miners of the blockchain to be able verify the transaction. Look at the image below for more understanding.



As a miner, you will see the Public key of the sender and the address of the receiver, the message/funds and the most important for the miner is the "message signature" confirming that the owner of the wallet approved the transaction by using his/her Private keys. Look at the image below for more understanding.



Blockchain

We need to know how blocks are mined cryptographically and what happens, if one of the blocks details are altered.

Below is the image of valid blockchains in blockchain.



What if I changed the transaction of Block 4 from $7 to $15, what will happen to that block and other blocks.



The background color changed to red, meaning something is wrong. Why, what is wrong? The transaction signature is now invalid, same with hash of the block.

Why is Block 3 not affected and Block 5 affected? Because of the invalid transaction signature, the hash of Block 4 is also invalid too. Blockchain works by connecting the Previous hash with the hash of the current block, thus, making it immutable. So, if the hash of Block 4 is changed, that means Block 5 will be affected since, it makes use of the Previous hash, which the hash of Block 4, to creates it's own Hash. Block 3 won't be affected because the change won't affect, it's Previous Hash and it's own hash. We can make everything valid again, by mining the block. So, click on Mine.



Block 4 has been mined, hence, the background color changed to Green because the hash is now valid, but the signature is still showing red, indicating that there was a change in the details of block. Block 5 background is still Red, this is because, the previous hash on Block 5 needs to match the hash of block 4, so you will have to mine Block 5.



Now, you can clearly see how blockchain cryptography works now.

I hope you all found the article interesting and exciting. Do well to share your thoughts about the article in the comment section below. Thanks.

⚫️⚪️⚫️

Thanks For Reading

Till Next Time, Stay Safe