How to use the crypto-ld.LDKeyPair.generate function in crypto-ld

To help you get started, we’ve selected a few crypto-ld examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github digitalbazaar / did-io / lib / methods / veres-one / veres-did-doc.js View on Github external
// Generate a capabilityInvocation key, to base the DID URI on
    const invokeKey = await LDKeyPair.generate(keyOptions);
    const did = this.generateId({keyPair: invokeKey, didType, env});
    this.doc.id = did;

    // Generate an authentication key pair and suite
    const authKey = await LDKeyPair.generate(keyOptions);
    authKey.id = `${did}#authn-key-1`;
    this.doc[constants.SUITES.authentication] = [
      this.generateSuite({key: authKey, suiteId: `${did}#auth-suite-1`})
    ];
    this.keys[authKey.id] = authKey;

    // Generate a capabilityDelegation key pair and suite
    const delegateKey = await LDKeyPair.generate(keyOptions);
    delegateKey.id = `${did}#ocap-delegate-key-1`;
    this.doc[constants.SUITES.capabilityDelegation] = [
      this.generateSuite({key: delegateKey, suiteId: `${did}#delegate-suite-1`})
    ];
    this.keys[delegateKey.id] = delegateKey;

    // Generate a capabilityInvocation suite (from an earlier generated key)
    invokeKey.id = `${did}#ocap-invoke-key-1`;
    this.doc[constants.SUITES.capabilityInvocation] = [
      this.generateSuite({key: invokeKey, suiteId: `${did}#invoke-suite-1`})
    ];
    this.keys[invokeKey.id] = invokeKey;
  }
github digitalbazaar / did-io / tests / veres-one / veres-did-doc.spec.js View on Github external
it('should generate a nym type did', async () => {
      const didDoc = new VeresOneDidDoc({keyType, didType: 'nym', injector});
      const keyOptions = {
        type: keyType, injector: didDoc.injector, passphrase: null
      };

      const keyPair = await LDKeyPair.generate(keyOptions);
      const did = didDoc.generateId({keyPair, env: 'dev'});

      expect(did).to.match(/^did:v1:test:nym:.*/);
    });
  });

crypto-ld

A Javascript library for generating and performing common operations on Linked Data cryptographic key pairs.

BSD-3-Clause
Latest version published 2 years ago

Package Health Score

51 / 100
Full package analysis