@trustalliance/key
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-alpha.26 • Public • Published

ExpTrustAlliance Logo

TrustAlliance Key SDK 0.0.1-alpha.6 TrustAlliance Key SDK 0.0.1-alpha.6 Node Version Lerna

TrustAlliance DID Key SDK

Implementation of JSON Web Key 2020 https://w3c-ccg.github.io/lds-jws2020/

Based on https://github.com/w3c-ccg/lds-jws2020

IMPORTANT!

  • This is a minimum viable product suite with limited functionality.
  • Please do not use this for production
  • This is a part of SDKs for Verifiable Credentials, Verifiable Credential Presentations, DID Keys, Self Sovereign Identity and Decentralised Identifiers

Installation

yarn install

Trackback Key

Architecture

Usage

importing DID builder and resolver

ES Modules import

import { JsonWebKey2020 } from '@trustalliance/key'

CommonJS import

const { JsonWebKey2020 } = require('@trustalliance/key');

Example

Generate keypair

const keyPair = await JsonWebKey2020.generate();

// {
//   id: 'did:trustalliance:key:...-pXbFqo#...-pXbFqo',
//   type: 'JsonWebKey2020',
//   controller: 'did:trustalliance:key:...-pXbFqo',
//   publicKeyJwk: {
//     crv: 'Ed25519',
//     x: 'THLsqR-...-3FDg',
//     kty: 'OKP',
//     alg: 'EdDSA',
//   },
//   privateKeyJwk: {
//     crv: 'Ed25519',
//     d: '..-URkyPqyYhTc',
//     x: 'THLsqR-...-3FDg',
//     kty: 'OKP',
//     alg: 'EdDSA',
//   },
// }

Sign messages

const signer = keyPair.signer();
const signature = await signer.sign({message:"test"});

Verify signature

const message = {...}

const signer = keyPair.signer();
const signature = await signer.sign(message);

const verifier = keyPair.verifier();
const verified = await verifier.verify({ data: message, signature });

// true / false

Dependencies (4)

Dev Dependencies (3)

Package Sidebar

Install

npm i @trustalliance/key

Weekly Downloads

0

Version

0.0.1-alpha.26

License

GPL-3.0-or-later

Unpacked Size

129 kB

Total Files

57

Last publish

Collaborators

  • trustalliance