Skip to main content

Command Palette

Search for a command to run...

How Digital Signatures Ensure Data Integrity?

Verifying Authenticity in the Digital World

Updated
โ€ข3 min read
How Digital Signatures Ensure Data Integrity?
F

Principal Technical Consultant at GeekyAnts.

Bootstrapping our own Data Centre services.

I lead the development and management of innovative software products and frameworks at GeekyAnts, leveraging a wide range of technologies including OpenStack, Postgres, MySQL, GraphQL, Docker, Redis, API Gateway, Dapr, NodeJS, NextJS, and Laravel (PHP).

With over 9 years of hands-on experience, I specialize in agile software development, CI/CD implementation, security, scaling, design, architecture, and cloud infrastructure. My expertise extends to Metal as a Service (MaaS), Unattended OS Installation, OpenStack Cloud, Data Centre Automation & Management, and proficiency in utilizing tools like OpenNebula, Firecracker, FirecrackerContainerD, Qemu, and OpenVSwitch.

I guide and mentor a team of engineers, ensuring we meet our goals while fostering strong relationships with internal and external stakeholders. I contribute to various open-source projects on GitHub and share industry and technology insights on my blog at blog.faizahmed.in.

I hold an Engineer's Degree in Computer Science and Engineering from Raj Kumar Goel Engineering College and have multiple relevant certifications showcased on my LinkedIn skill badges.

๐Ÿง What is a Digital Signature?

A digital signature is a cryptographic technique that ensures the authenticity, integrity, and non-repudiation of digital messages or documents.

When you digitally sign a document, you are providing a unique fingerprint that proves:
โœ” The message is from you (Authentication).
โœ” The message was not altered in transit (Integrity).
โœ” The sender cannot deny signing it (Non-Repudiation).

๐Ÿ”‘ How Do Digital Signatures Work?

A digital signature is created using asymmetric encryption (Public Key Cryptography). It involves:
1๏ธโƒฃ Hashing the message (to create a unique fingerprint).
2๏ธโƒฃ Encrypting the hash with the senderโ€™s private key.
3๏ธโƒฃ Sending the message & signature to the receiver.
4๏ธโƒฃ Verifying the signature using the senderโ€™s public key.

๐Ÿ“Œ Step-by-Step Breakdown of Digital Signature Process

1๏ธโƒฃ Message Hashing:

  • The sender applies a hashing algorithm (e.g., SHA-256) to the original message.

  • This creates a fixed-length unique hash (fingerprint).

2๏ธโƒฃ Signing the Hash:

  • The sender encrypts the hash using their private key.

  • This encrypted hash becomes the digital signature.

3๏ธโƒฃ Message Transmission:

  • The original message + digital signature are sent to the receiver.

4๏ธโƒฃ Signature Verification:

  • The receiver decrypts the signature using the senderโ€™s public key.

  • The receiver hashes the received message using the same algorithm.

  • If the hashes match, the message is authentic and unchanged!

๐Ÿ” Why Use Digital Signatures?

โœ… Prevents Tampering โ€“ Ensures the message wasnโ€™t altered.
โœ… Proves Authenticity โ€“ Verifies the senderโ€™s identity.
โœ… Ensures Non-Repudiation โ€“ The sender cannot deny sending the message.

๐Ÿ”น Digital Signatures vs Electronic Signatures

FeatureDigital Signature โœ…Electronic Signature โœ
SecurityHigh (uses cryptography)Low (image/text-based)
VerificationCan be mathematically verifiedUsually cannot be verified
LegalityStrong legal backingVaries by jurisdiction
Use CaseSecure documents, software signingOnline contract approvals

๐Ÿ“Œ Digital Signatures are cryptographically secured, whereas Electronic Signatures are often just images of handwritten signatures.

๐ŸŒ Where Are Digital Signatures Used?

๐Ÿ“Œ Software Distribution โ€“ Ensures apps & updates come from a trusted source.
๐Ÿ“Œ Secure Email (PGP, S/MIME) โ€“ Verifies sender authenticity.
๐Ÿ“Œ Blockchain & Cryptocurrency โ€“ Used for secure transactions.
๐Ÿ“Œ Legal Documents (e.g., DocuSign) โ€“ Provides legal validity.

๐Ÿ› ๏ธ How to Create a Digital Signature in Node.js?

Want to see a digital signature in action? Hereโ€™s an example using RSA encryption in Node.js with the built-in crypto

const crypto = require('crypto');

// Generate RSA Key Pair
const { publicKey, privateKey } = crypto.generateKeyPairSync('rsa', {
  modulusLength: 2048,
});

// Original Message
const message = "Secure Message";

// Create Digital Signature
const sign = crypto.createSign('SHA256');
sign.update(message);
sign.end();
const signature = sign.sign(privateKey, 'hex');

console.log("Signature:", signature);

// Verify the Signature
const verify = crypto.createVerify('SHA256');
verify.update(message);
verify.end();

const isValid = verify.verify(publicKey, signature, 'hex');
console.log(isValid ? "โœ… Signature is valid!" : "โŒ Signature is invalid!");

This Node.js script:
โœ… Generates RSA key pairs
โœ… Creates a digital signature for a message
โœ… Verifies the signature using the public key

๐Ÿš€ Final Thoughts

Digital Signatures are essential for security, providing:

  • Authenticity โ€“ Verifies the sender.

  • Integrity โ€“ Ensures data wasnโ€™t altered.

  • Non-Repudiation โ€“ The sender cannot deny signing.

Would you like a tutorial on how to implement digital signatures in AWS KMS or OpenSSL? Letโ€™s discuss in the comments! ๐Ÿ‘‡


About Me ๐Ÿ‘จโ€๐Ÿ’ป

I'm Faiz A. Farooqui. Software Engineer from Bengaluru, India.
Find out more about me @ faizahmed.in

Mastering Encryption: A Practical Guide for Developers

Part 8 of 13

Learn encryption fundamentals, from Symmetric vs Asymmetric Encryption to Envelope Encryption and AWS KMS implementation. Clear explanations, real-world use cases, and easy-to-follow diagrams to help developers secure their data.

Up next

How TLS/SSL Encryption Protects the Internet?

The Backbone of Secure Web Communication