Home / Ciberseguridad / Signing is not encrypting: the two keys that prove a message is yours

Signing is not encrypting: the two keys that prove a message is yours

Almost everyone believes that digitally signing is encrypting the message so nobody can read it. It is not. They are two cousins that often get confused: encryption seeks secrecy; signing seeks what and who. In this article we separate the wheat from the chaff and open up the engine behind digital signatures: asymmetric keys, hash functions and two very specific pieces of mathematics called RSA and ECDSA.

The problem that signing solves

When you receive a message, you need to answer three questions that encryption alone cannot answer:

  • Is it intact? Nobody has altered it along the way.
  • Is it authentic? It really was sent by whoever claims to have sent it.
  • Is it non-repudiable? The author cannot deny it afterwards.

That is where the digital signature comes in: a mathematical annex to the message that certifies those three properties as a block.

The key pair: public and private key

The signature relies on asymmetric cryptography, the kind that uses two mathematically linked keys: a private one, known only to the owner, and a public one, which could be printed on a billboard. Let us represent the private key as an a and the public one as A: the first is derived from the second, but the reverse jump is so expensive to compute that it becomes unfeasible.

That asymmetric trait — “easy in one direction and expensive in the other” — is the mathematical foundation of it all. In RSA, the public key contains the product n = p·q of two enormous prime numbers; recovering p and q from n would force you to factor an integer of thousands of bits, a problem with no known shortcut. ECDSA uses elliptic curve arithmetic, which achieves the same security with much shorter keys.

Hash: the unrepeatable digest of the message

Signing the whole message would be far too slow and would make it enormous. The solution goes through a digest or hash: a function H that turns a text of any size into a fixed-length string (for example 256 bits in SHA-256) with three decisive properties:

  • Deterministic: the same message always yields the same digest.
  • One-way: from the digest you cannot reconstruct the message.
  • Collision-resistant: finding two distinct messages with the same digest requires astronomical effort.

If a single pixel changes in a document, its SHA-256 changes completely: that is the lever that turns any alteration into something detectable.

The heart of the process, step by step

Let us put the pieces together. The signature is not encrypting the message, but rather encrypting its hash with the private key:

  1. Sign: the sender computes hash(message) and transforms it with their private key. That result is the signature s. The pair (message, s) is sent.
  2. Verify: the receiver applies the sender’s public key to s and obtains a value. In parallel, they compute hash(message) with the function of the same protocol.
  3. Decide: if both match, the signature is valid; otherwise the message or the signature has been tampered with.

Notice the key detail: only the private key knows how to produce a value that the public key decrypts correctly. Anyone can verify with the public key, but only the owner of the private one can sign. That is why a valid signature is a cryptographic proof of authorship.

RSA versus ECDSA: two ways of signing

In RSA, signing means raising the hash to the power of the private key (s = hd mod n) and verifying means raising it to the public key. Deterministic and easy to implement, but the keys must be long (3072 or 4096 bits) because of advances in factoring.

ECDSA, by contrast, is probabilistic: it produces the signature as a pair of integers (r, s) that depend on a random value k, like a unique wedge per message. It offers the same security with 256-bit keys and signs within a stable space in HTTPS; that is why the X25519 and P-256 curves dominate the modern web. Reusing the same k for two messages breaks security completely: that was the flaw that exposed PlayStation 3 keys in 2010.

What it protects and what it does not

The signature guarantees integrity, authenticity and non-repudiation of content, but it does not encrypt anything: whoever receives it can read the message without trouble. It also does not protect against replay: an attacker can re-send a valid signed message (for example, a payment order) making it happen again. Above all, it depends on the public key arriving through a trusted channel: that is what X.509 certificates and certificate authorities exist for, closing the chain with the TLS channel.

Where you see it working every day

  • TLS certificates: the server signs a random challenge to prove it holds the certificate’s private key.
  • Secure email and documents (signed PDF, S/MIME).
  • Updates and packages: signed Git commits, systemd packages and appimages verified before execution.
  • Software bill of materials and OCI container signatures in supply chains.

The next time you see a padlock in the browser bar, remember: before sending a single byte of the site, the server had to prove, with a signature, that it owned that private key. That cryptographic “handshake” is the glue that supports the trust of the entire web.