Blockchain Development Part 3
In previous blockchain development part we have discussed about some problems with our HowCoin. We also fix gossip protocol in previous part. Now in this part we will discuss about authentication system in detail for our HowCoin
We have discussed in detail about gossip networks in the previous part and also discussed the authentication system in the crypto world. For the authentication system we used a cryptography system. This system consists of public and private keys. The public key is open to all but your private key is your own. No one knows about your private key but your public key is visible to everyone in this system.
These keys are encrypted by different algorithms such as ‘base64’
To make this structure we need to make another file in our system named pki.rb
This method is used to generate new keypair for newly registered users. We can generate and see keypairs by using running this file and in terminal
In this picture you can see the generated public and private keys for a new keypair.
All the messages in the crypto world are encrypted with these keypairs. We can encrypt it by sign method. This method needs private key and message to encryption and send this encrypted message to other person along with their public key
Encrypted messages are not readable; we need to make it readable by using decryption technique. For this purpose the plaintext method is used. This message needs a public key and encrypted string and decrypts it.
This method is used to validate whether the signed message is valid according to encryption rules or not.
Here you can download complete source code of each step