mndid
v0.0.6
Published
lifeID did encoder/decoder
Downloads
9
Readme
Multi-Network Decentralized Identifier
The lifeID platform uses pairwise decentralized identifiers ("DIDs") for people and organizations to identify themselves to one another. This repository is a suite of tools allowing anyone to create, encode, decode DIDs for any blockchain.
A lifeID DID looks like this:
"did:life:Lo3gVgN4WnXe6CnVn1zFSXGK4wL6eMJ7W1"
There are three parts to a lifeID did:
The DID prefix
did:
This indicates that you are presenting a standardized DID according to the specification outlined by the World Wide Web Consortium ("W3C").The DID method.
life:
This signals to everyone that you are presenting a DID for use on the lifeID platform.The Base58 encoded DID string.
Lo3gVgN4WnXe6CnVn1zFSXGK4wL6eMJ7W1
Base58 encoding is a way to store large integers as alphanumeric text, similar to Base64 but doesn't have the0 O i or l
because they might look ambiguous when printed or written down. MNDID library has functions to encode and decode base58 DIDs.
When decoded, a DID string includes the following parts:
The version number. Currently this is a single one byte version number it will start at 1 and can be updated in the future.
The network ID. This part of the DID describes which blockchain stores its public key. It is 4 bytes long.
The type of identity. What is the DID identifying? There are three possible values. 1 for an individual, 2 for any other kind of legal entity such as a corporation or non-profit organization, and 3 for a physical items or property.
The public key. Different blockchains use different encryption schemes, but they all require a cryptographic keys to prove ownership. It 65 bytes long.
The checksum. A SHA3-256 digest of the version number, network ID and public key. The checksum provides a way to quickly verify whether the DID is correct or has been changed in any way.
An example decoded DID:
API
This library provides the following functions for working with DIDs
createDID(didObject)
This function takes a valid DID object and returns an encoded DID wrapped in a promise
input: didObject
An object with the following fields. All are required.
didObject: {
method: string,
network: string,
version: string,
key: string
}
return value : Promise(did: string)
decodeDID(did)
This function takes a valid DID string and returns a DID object wrapped in a promise.
did
A string that is a validly formatted DID.
return value : Promise(didObject: object)
validateDID(did)
This function takes a valid DID string and returns a promise. The promise will resove to true
if and only if the DID is correctly formed.
did
A string that is a validly formatted DID.
return value : Promise(boolean)