Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@civic/did-registry

Package Overview
Dependencies
Maintainers
16
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@civic/did-registry

An on-chain protocol to provide reverse-lookup on did:sol key membership

  • 0.0.6-alpha.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
16
Created
Source

DID Registry

An on-chain protocol for registering did:sol DIDs against public keys or controller DIDs allowing for reverse-lookup of the DID from the public key or its controller.

Why

If a DID is known, it is possible to look up the public key(s) associated with it.

However, the reverse operation is not possible. Given a public key, it is not possible to find all DIDs that it controls.

This reduces the usefulness of a DID for use-cases such as key rotation, where a new public key is added to a DID, and the old one is removed. In this case, the link between the public key and the DID identifier is severed; the DID can not be derived from the new key.

Likewise, it is possible, given a DID to find other DIDs that control it, but the reverse operation is not possible.

The DID registry solves this by allowing a DID to be registered against a public key or controller DID.

How

This program defines two registry types:

KeyRegistry: A registry of DIDs controlled by a given key. ControllerRegistry: A registry of DIDs controlled by a given controller DID.

In order to create or update the key registry, the transaction must be signed by the key itself.

In order to create or update the controller registry, the transaction must be signed by a key that is an authority on the controller DID.

Does this work for non-did:sol DIDs?

No. The DID registry is specific to did:sol DIDs. This is due to the constraints around adding DIDs to the registry. The program checks that the DID is controlled by the key or controller DID. The program therefore needs access to the DID document, which is only available on-chain for did:sol DIDs.

What is the size limit of the registry?

The registry grows with the number of DIDs that are registered, up to a maximum determined by Solana for accounts (10MB).

The initial reserved size is 4 DIDs (each DID is 32 bytes).

The client auto-grows if that limit is exceeded, but a manual resize is also possible through the "resize" instructions.

Does the DID registry support non-solana keys?

Yes, it is possible to register a DID against an EVM key using the registerDidForEthAddress instruction. There is a client SDK, EthRegistry, for this purpose.

Quick Start

yarn add @civic/did-registry

Register a DID against a key, and lookup registered DIDs

import { PublicKey } from "@solana/web3.js";
import { Registry } from '@civic/did-registry';

const provider = anchor.AnchorProvider.env();
const registry = Registry.for(provider.wallet, program.provider.connection);

// Register a DID
await registry.register("did:sol:123...");

// Lookup all registered DIDs
const dids: string[] = await registry.listDIDs();

// Remove a DID
await registry.remove("did:sol:123...");

Eth Support

import { EthRegistry } from "@civic/did-registry";

const registry = new EthRegistry.forEthAddress("0x...", provider.wallet, program.provider.connection);

// Register a DID
await registry.register("did:sol:123...");

Sign with an eth key:

import { EthRegistry } from "@civic/did-registry";
import { Wallet } from "@ethersproject/wallet";

const registry = new EthRegistry.forEthAddress("0x...", provider.wallet, program.provider.connection);

// create an ethers wallet
const ethWallet = Wallet.createRandom();

// Register a DID
await registry.registerSigned("did:sol:123...", ethWallet);

Register a DID against a controller DID

import { PublicKey } from "@solana/web3.js";
import { ControllerRegistry } from '@civic/did-registry';

const controllerDID = "did:sol:123...";
const controlledDID = "did:sol:456...";

const provider = anchor.AnchorProvider.env();
const registry = ControllerRegistry.for(provider.wallet, controllerDID, program.provider.connection);

// Register a controlled DID
await registry.register(controlledDID);

FAQs

Package last updated on 12 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc