Skip to content
This repository has been archived by the owner on May 13, 2019. It is now read-only.

uport-project/eth-did-resolver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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')

About

DID resolver for Ethereum Addresses

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published