/blockcore-identity

JavaScript Library for Decentralized Identity on Blockcore

Primary LanguageTypeScriptMIT LicenseMIT

Blockcore Identity Library (JS)

Library that helps working with DIDs (decentralized identities) on Blockcore and the Blockcore DID Server ("did:is" DID Method).

Usage

npm install @blockcore/identity

Example usage:

const privateKey = Uint8Array.from([
  224, 238, 59, 150, 73, 84, 228, 234, 104, 62, 83, 160, 122, 31, 108, 129, 74, 29, 104, 195, 192, 81, 158, 11, 167,
  100, 217, 121, 110, 12, 178, 14,
]);

const tool = new BlockcoreIdentityTools();
const signer = tool.getSigner(privateKey);
const publicKey = tool.getSchnorrPublicKeyFromPrivateKey(privateKey);
const verificationMethod = tool.getVerificationMethod(publicKey, 1);

const identity = new BlockcoreIdentity(verificationMethod);
const didDocument = identity.document({
  service: [
    {
      id: '#blockexplorer',
      type: 'BlockExplorer',
      serviceEndpoint: 'https://explorer.blockcore.net',
    },
  ],
});

const jws = await identity.sign(signer, { version: 0, didDocument: didDocument });

Building and Testing

The library can be built using TypeScript Compiler, either directly or through npm:

npm run build

To generate and update the example documents, use this command:

npm run examples

This will update the example documents available at test/examples

Examples created by the library

did-configuration.json

did.json

(These documents are no longer generated by this library, but a prevoius version)

Resources

https://w3c.github.io/did-core/