Modules

serialize.js

Canonical JSON serialization for signing and verification.

  • canonicalize(claim)
  • canonicalString(claim)

sign.js

Key generation, subject hashing, and claim creation.

  • generateKeyPair()
  • keyFingerprint(publicKey)
  • subjectHash(domain, userId)
  • subjectHashHmac(domain, userId, secret)
  • createClaim({ ... })
  • isValidClaimType(type)
  • CORE_CLAIM_TYPES

verify.js

Signature verification against a public key.

  • verifyClaim(claim, publicKey)
  • ErrorCode

Quick Start

import { generateKeyPair, createClaim, verifyClaim } from './sdk/src/index.js';

// Generate a key pair
const { privateKey, publicKey, fingerprint } = generateKeyPair();

// Create and sign a claim
const claim = createClaim({
  type: 'mir.transaction.completed',
  domain: 'marketplace.example.com',
  subject: 'a55bea0a...',
  privateKey,
  publicKey,
});

// Verify
const result = verifyClaim(claim, publicKey);
console.log(result.valid); // true

Design Constraints

Zero Dependencies

Uses only the Node.js built-in crypto module. No external packages.

Deterministic

Same inputs always produce the same canonical bytes and the same Ed25519 signature.

Conformant

Passes all 30 tests and all 6 normative test vectors. The reference implementation for interoperability.

Test Vectors Signature Model