SPOKUP DIGITAL · Tutorial

How to Sign and Verify a Claim with Ed25519

Create a keypair, sign a JSON claim, publish the public key and let anyone verify it, in PHP or Node.js.

Direct answer

Ed25519 signing proves a published claim has not been altered since it was signed and that the holder of the private key signed it. It does not prove the claim is true. Generate a keypair, sign the exact JSON bytes, publish the signature and public key, and verify with the same bytes.

Browser voice narration. No pre-recorded audio file is used.
Read the full transcript
Ed25519 signing proves a published claim has not been altered since it was signed and that the holder of the private key signed it. It does not prove the claim is true. Generate a keypair, sign the exact JSON bytes, publish the signature and public key, and verify with the same bytes.
Before you start
Time needed: about 20 minutes. Cost: free. Limitation: a valid signature proves integrity and key control only, not that the content is accurate or independently audited.
PHP 7.2+ with the sodium extension, or Node.js 16+
A JSON claim you control
A safe place to keep the private key (never publish it)
Steps
Write the claim. Keep it small and factual, for example {"id":"cs-001","metric":"Organic sessions","statement":"...","basis":"GA4"}.
Serialise exactly once. Produce the JSON text one time and sign those exact bytes. Any re-serialisation changes the bytes and breaks verification.
Generate a keypair. Create an Ed25519 keypair. Store the secret key privately and publish only the public key.
Sign. Create a detached signature over the bytes and encode it as base64.
Publish. Publish the exact signed string, the signature, the public key and the algorithm name.
Verify. Anyone verifies the signature against the exact signed string and public key.
PHP (libsodium)
Node.js
Expected output and limits
You get a 64-byte signature (88 base64 characters) and a true result when verifying the unchanged message. Changing one character makes verification fail. Spokup’s public ledger works this way; see the ledger and the independent co-signature process.
Does a valid signature mean the claim is true?
No. It proves integrity and that the key holder signed it.
Why sign the exact string?
Re-serialising JSON can change spaces or key order and break verification.
Where do I keep the private key?
In a secrets store, never in the website or a public repository.
What is a co-signature?
A second signature from an independent party who has reviewed the evidence.
Is Ed25519 secure?
It is a widely used modern signature scheme; security depends on keeping the private key secret.

Before you start

Time needed: about 20 minutes. Cost: free. Limitation: a valid signature proves integrity and key control only, not that the content is accurate or independently audited.

  • PHP 7.2+ with the sodium extension, or Node.js 16+
  • A JSON claim you control
  • A safe place to keep the private key (never publish it)

Steps

  1. Write the claim

    Keep it small and factual, for example {"id":"cs-001","metric":"Organic sessions","statement":"...","basis":"GA4"}.

  2. Serialise exactly once

    Produce the JSON text one time and sign those exact bytes. Any re-serialisation changes the bytes and breaks verification.

  3. Generate a keypair

    Create an Ed25519 keypair. Store the secret key privately and publish only the public key.

  4. Sign

    Create a detached signature over the bytes and encode it as base64.

  5. Publish

    Publish the exact signed string, the signature, the public key and the algorithm name.

  6. Verify

    Anyone verifies the signature against the exact signed string and public key.

PHP (libsodium)

$kp     = sodium_crypto_sign_keypair();
$secret = sodium_crypto_sign_secretkey($kp);
$public = sodium_crypto_sign_publickey($kp);
$message = json_encode($claim, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$sig = sodium_crypto_sign_detached($message, $secret);
echo base64_encode($sig);
// Verify
var_dump(sodium_crypto_sign_verify_detached($sig, $message, $public));

Node.js

import { generateKeyPairSync, sign, verify } from 'node:crypto';
const { publicKey, privateKey } = generateKeyPairSync('ed25519');
const message = Buffer.from(JSON.stringify(claim));
const signature = sign(null, message, privateKey);
console.log(signature.toString('base64'));
console.log(verify(null, message, publicKey, signature)); // true

Expected output and limits

You get a 64-byte signature (88 base64 characters) and a true result when verifying the unchanged message. Changing one character makes verification fail. Spokup’s public ledger works this way; see the ledger and the independent co-signature process.

Common questions

Does a valid signature mean the claim is true?

No. It proves integrity and that the key holder signed it.

Why sign the exact string?

Re-serialising JSON can change spaces or key order and break verification.

Where do I keep the private key?

In a secrets store, never in the website or a public repository.

What is a co-signature?

A second signature from an independent party who has reviewed the evidence.

Is Ed25519 secure?

It is a widely used modern signature scheme; security depends on keeping the private key secret.

Cite this page

Spokup Digital cannot guarantee rankings, AI citations, media outcomes or revenue. See the research and editorial policies for how this page was produced and how corrections are handled.

Advertising & media

Full-service advertising, global media buying and PR

Strategy, creative, TV, out-of-home, digital and earned media for mass-consumer and enterprise brands.

Global offices

Offices in 190 countries

Find your market: every country page lists the local office address, WhatsApp Business and callback options.

Browse the countries directory

Free tools

Eight free tools and calculators for B2B marketing teams

Instant SEO & GEO audit, budget and ROAS models, readability and accessibility checks. Nothing you enter is stored.

Start from the problem

Challenges we solve

The five website complaints we hear most, each with a diagnosis and a plan.

Our own software

Proprietary platforms: Qavla AI and RYD Taxi

We build and run products as well as websites.