How it works
Signing takes two inputs, the message and a private key, and returns a signature. Verifying takes three, the message, the signature and the public key, and returns yes or no. The check passes only if the message is byte for byte what was signed and the signature was made with the private key that matches that public key.
That gives two guarantees. Integrity: the content has not changed. Origin: whoever signed held the private key.
What it does not prove
- Secrecy. The message is not hidden. A signed license token can be read by anyone who has it.
- Freshness. A signature stays valid forever. An old signed message still verifies, which is why a signed license token carries its own
iatandrefresh_bytimes. - Who the key holder is. A bare signature proves possession of a key, not a name. Binding a key to a named publisher takes a certificate, as in code signing.
Example: one character changes everything
This Node.js script signs a token body with Ed25519, then checks the original, a tampered payload and a one-character edit.
import { generateKeyPairSync, sign, verify } from 'node:crypto';
const { publicKey, privateKey } = generateKeyPairSync('ed25519');
const payload = JSON.stringify({ lid: 1, pid: 1, valid: true });
const body = 'sgt1.' + Buffer.from(payload).toString('base64url');
const sig = sign(null, Buffer.from(body), privateKey);
console.log(verify(null, Buffer.from(body), publicKey, sig)); // true
const flipped = 'sgt1.' + Buffer.from(payload.replace('true', 'false')).toString('base64url');
console.log(verify(null, Buffer.from(flipped), publicKey, sig)); // false
const oneChar = body.slice(0, -1) + (body.endsWith('A') ? 'B' : 'A');
console.log(verify(null, Buffer.from(oneChar), publicKey, sig)); // false
Output: true, false, false. Changing valid from true to false breaks the signature, and so does changing a single character at the end. A buyer cannot edit an expired license into a valid one.
One practical rule: verify the bytes exactly as received, then parse. If you parse the JSON and serialize it again before checking, whitespace or key order may differ and a genuine signature fails.
Digital signature versus MAC versus electronic signature
| Digital signature | MAC (for example HMAC) | Electronic signature | |
|---|---|---|---|
| Keys | Private signs, public verifies | One shared secret | Not a key scheme |
| Who can verify | Anyone with the public key | Only holders of the secret | Not applicable |
| Where it fits | Software on customer machines | Two servers that trust each other | Recording a person’s agreement to a document |
A message authentication code is smaller and faster, but whoever can verify one can also forge one. See public-key cryptography for why that rules it out inside a shipped app. An electronic signature is a legal term for agreeing to a document and is a different subject from the cryptography on this page.
How Clavem handles it
Clavem signs the ASCII text sgt1.<payload> with the product’s Ed25519 private key. The signature is 64 bytes, base64url encoded, and it is the third part of the token. Your app verifies it with the product’s public key before it reads any claim. The offline verification guide shows the steps in JavaScript, Swift, Rust, PHP and Python.
Questions
Does a digital signature hide the message?
No. The message stays readable. A signature adds proof of origin and integrity; encryption is a separate step.
Is a digital signature the same as an electronic signature?
No. An electronic signature is a legal idea, a person's recorded agreement, and may use no cryptography. A digital signature is a cryptographic operation on data.