VerifyingKeyFormat

Format of the public key used for signature verification.

Format of the public key used for signature verification.

Different algorithms support different key formats.

View source ↗

Type

type VerifyingKeyFormat = 'spkiDer' | 'spkiPem' | 'pkcs1Der' | 'pkcs1Pem' | 'sec1' | 'raw';

Examples

import fs from 'fs';

// PEM format (text)
const pemKey = fs.readFileSync('./public-key.pem', 'utf8');
const config1 = {
  format: 'spkiPem',
  data: pemKey,
};

// DER format (binary)
const derKey = fs.readFileSync('./public-key.der');
const config2 = {
  format: 'spkiDer',
  data: derKey,
};

// Raw bytes (Ed25519 only)
const rawKey = new Uint8Array(32);
const config3 = {
  format: 'raw',
  data: rawKey,
};

On this page