Friday, 24 January 2025

Public key and private key

Mainly there are two use cases.

  1. encrypte message using public key. Then decrypt message using private key
  2. digitally sign message using private key. Then verify signature using public key

Here is example for use case 2. Use SSH public key and private key to do authentication for github after you upload your public key onto github server

  1. You initiate an SSH connection to the server
  2. The server chooses a random challenge (a nonce or session identifier) and sends it to you
  3. Your SSH client uses your private key to compute a digital signature over that challenge
  4. You send the signature back to the server
  5. The server uses your stored public key to verify the signature
  6. If verification succeeds, only someone with the private key could have produced it
  7. You’re granted access; if it fails, you’re rejected

Another example for use case 2 is bitcoin transaction

  1. Ower uses private key to sign the transaction
  2. The signature is verfied by others using public key (the btc address comes from public key)

No comments:

Post a Comment