Dev Helpers
← Back

Verify an Ed25519 signature

Verify an Ed25519 signature using Node.js.

Open this example in the interactive library

Source code

import {
  createHash,
  createHmac,
  randomUUID,
  randomBytes,
  timingSafeEqual,
  generateKeyPairSync,
  sign,
  verify,
  createSecretKey,
} from "node:crypto";
console.log(
  (() => {
    const { privateKey, publicKey } = generateKeyPairSync("ed25519");
    const data = Buffer.from("demo");
    return verify(null, data, publicKey, sign(null, data, privateKey));
  })(),
);

Sample output

true