@trustalliance/key
v0.0.1-alpha.26
Published
TrustAlliance key SDK
Downloads
4
Maintainers
Readme
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
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