eth-did-resolver

0.1.1 • Public • Published

eth DID Resolver

This library is intended to use ethereum addresses as Decentralized Identifiers and wrap them in a DID Dcument

It supports the proposed Decentralized Identifiers spec from the W3C Credentials Community Group.

It requires the did-resolver library, which is the primary interface for resolving DIDs.

DID method

To encode a DID for an Ethereum address, simply prepend did:eth:

eg:

did:eth:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74

DID Document

The did resolver takes the ethereum address and wraps it into a simple DID document:

{
  '@context': 'https://w3id.org/did/v1',
  id:'did:eth:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74',
  publicKey: [{
    id: `did:eth:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74#keys-1`,
    type: 'Secp256k1VerificationKey2018',
    owner: 'did:eth:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74',
    ethereumAddress: '0xf3beac30c498d9e26865f34fcaa57dbb935b0d74'
  }]
}

Note this uses the Secp256k1VerificationKey2018 type and an ethereumAddress instead of a publicKeyHex.

Resolving a DID document

The resolver presents a simple resolver() function that returns a ES6 Promise returning the DID document.

import resolve from 'did-resolver'
import registerResolver from 'eth-did-resolver'
 
registerResolver()
 
resolve('did:eth:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74').then(doc => console.log)
 
// You can also use ES7 async/await syntax
const doc = await resolve('did:eth:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74')

/eth-did-resolver/

    Package Sidebar

    Install

    npm i eth-did-resolver

    Weekly Downloads

    4

    Version

    0.1.1

    License

    Apache-2.0

    Unpacked Size

    19.3 kB

    Total Files

    7

    Last publish

    Collaborators

    • pelleb