npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@blockialabs/ssi-did-key

v2.0.8

Published

A library for creating and managing DID keys in decentralized identity systems.

Downloads

85

Readme

SSI DID Key

The ssi-did-key package provides a complete implementation of the did:key method for Decentralized Identifiers (DIDs) as specified in the DID Core specification. The did:key method allows DIDs to be derived directly from cryptographic public keys, enabling self-sovereign identity without requiring external registries or resolvers.

Installation

Install the package via NPM:

npm install @blockialabs/ssi-did-key

Key Components

Core Classes

  • KeyDIDMethod: Implementation of the did:key method supporting create, resolve, and update operations
  • KeyDIDResolver: DID resolver specifically for did:key DIDs

Interfaces

  • KeyDIDPrepareOptions: Options for preparing DID creation
  • KeyDIDCompleteOptions: Options for completing DID operations

Basic Usage

1. Setup KeyDID Method and Resolver

Initialize the DID method and resolver.

import { KeyDIDMethod, KeyDIDResolver } from '@blockialabs/ssi-did-key';

// Create the DID method implementation
const keyDIDMethod = new KeyDIDMethod();

// Create the resolver
const keyDIDResolver = new KeyDIDResolver(keyDIDMethod);

2. Create a DID from a Public Key

Generate a DID directly from a cryptographic public key.

// Your public key
const publicKeyHex = '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798';

// Create the DID
const { did, didDocument } = await keyDIDMethod.create({
  publicKeyHex,
  signatureType: 'EcdsaSecp256k1Signature2019',
  keyId: 'controllerKey',
  signature: 'signature',
});

console.log('Created DID:', did);
// Output: did:key:zQ3shP2mP2UQHpB8H7J4KCk7Pg1YCVy9Q3X9ZGJGJGJGJGJ

3. Resolve a DID

Resolve any did:key DID to get its DID document.

const resolutionResult = await keyDIDResolver.resolve(
  'did:key:zQ3shP2mP2UQHpB8H7J4KCk7Pg1YCVy9Q3X9ZGJGJGJGJGJ',
);

if (resolutionResult.didDocument) {
  console.log('DID Document:', resolutionResult.didDocument);
  console.log('Resolution Metadata:', resolutionResult.didResolutionMetadata);
} else {
  console.log('Resolution Error:', resolutionResult.didResolutionMetadata.error);
}

4. Update a DID Document

Update an existing DID document with new information.

// Create an updated DID document
const updatedDocument = {
  ...didDocument,
  // Add services, verification methods, etc.
  service: [
    {
      id: `${did}#linked-domain`,
      type: 'LinkedDomains',
      serviceEndpoint: 'https://example.com',
    },
  ],
};

// Update the DID document
const updatedDIDDocument = await keyDIDMethod.update(did, updatedDocument, {
  publicKeyHex,
  signature: 'update-signature',
  keyId: 'controllerKey',
  signatureType: 'EcdsaSecp256k1Signature2019',
});

DID Key Format

The did:key method uses the following format:

did:key:<method-specific-identifier>

Where <method-specific-identifier> is a base58-encoded representation of the public key.

Integration with SSI DID Package

Using with DID Orchestrator

Integrate with the main SSI DID package for full lifecycle management.

import { DIDOrchestrator, DIDMethodRegistry, DIDResolverRegistry } from '@blockialabs/ssi-did';
import { KeyDIDMethod } from '@blockialabs/ssi-did-key';

// Setup registries
const methodRegistry = new DIDMethodRegistry();
const resolverRegistry = new DIDResolverRegistry();

// Register the key method
const keyMethod = new KeyDIDMethod();
methodRegistry.register('key', keyMethod);
resolverRegistry.register('key', keyMethod);

// Create orchestrator
const orchestrator = new DIDOrchestrator({
  methodRegistry,
  resolverRegistry,
  signatureProviders: {
    Secp256k1: secp256k1SignatureProvider,
  },
});

Building

Run nx build ssi-did-key to build the library.

Running unit tests

Run nx test ssi-did-key to execute the unit tests via Jest.

Running lint

Run nx lint ssi-did-key to check if there are lint errors.

See LICENSE.