How do digital signatures work


1. For example : data is sensitive like below: 
{
      "from": "James",
      "to" : "Bob" ,
      "bankAccountNumber": 098759438583593,
      "transferTo" : 023759837463253,
      "value" : 1000,
      "ccy" : "USD"
}

The problem is that if I want to transfer this data from VietComBank to TechComBank to make a transaction between James and Bob

If this data is transferred as raw data, it means that the middle man could edit the data and continue transfer the edited data to the destination

Look at this flow:  VietComBank ---> Middle man ---> TechComBank
I suppose that if the middle man edited transferTo and to to another bank account of hacker

If this happens that is so terrible.


So Software engineers were born to fix this problem. They will give the VietComBank a private key and TechComBank a public key

VietComBank before sending the sensitive data, they need to hash the data to generate hashed data --> after that they need to encrypt the hashed data with private key to generate a signature digital.

For example:
{
data: {
      "from": "James",
      "to" : "Bob" ,
      "bankAccountNumber": 098759438583593,
      "transferTo" : 023759837463253,
      "value" : 1000,
      "ccy" : "USD"
},

signature_digital: "uhf37hqjhas73hharw76q8uwrqwjh342g"
}
They need to transfer both the data and the signature in one request to TechComBank

When TechComBank recieved the data and the signature, they will decrypt the signature with the public key to see the first hashed data. Next step they will hash the recieved data to generate the second hashed data. Next step they will compare the first hashed data and the second hashed data. If both is equals to each others --> The data is not modified by the middle man 

P/S: You can use RSA algorithm
https://www.novixys.com/blog/how-to-generate-rsa-keys-java/

The solution is great.

Comments

Popular posts from this blog

Fixing the DeepSpeed Import Error While Fine-Tuning the Qwen Model

Amazon Linux 2023 - User data configuration for launch templates to connect to the EKS cluster

How to create ISM policy and rotate logs in opensearch