How to use the crypto-ld.LDKeyPair.from 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 / tests / veres-one / veres-did-doc.spec.js View on Github external
it('should add/remove a public key node from the DID Doc', async () => {
      await didDoc.importKeys(exampleKeys);

      const authSuite = didDoc.doc[constants.SUITES.authentication][0];
      const authKey = authSuite.publicKey[0];

      didDoc.removeKey(authKey);

      // Check to make sure key is removed
      expect(authSuite.publicKey).to.eql([]);
      expect(didDoc.keys[keyId]).to.not.exist();

      // Now re-add the key
      const suiteId = `${did}#auth-suite-1`;

      const key = await LDKeyPair.from(exampleKeys[keyId]);
      await didDoc.addKey({suiteId, key});

      expect(authSuite.publicKey).to.eql([key.publicNode({owner: did})]);
      expect(didDoc.keys[keyId]).to.eql(key);
    });
  });
github digitalbazaar / did-cli / lib / drivers / veres / ed25519-key-add.js View on Github external
module.exports = async options => {
  const {
    did, private: privateKeyBase58, public: publicKeyBase58,
    purpose: proofPurpose
  } = options;
  logger._debug(options, 'ed25519-key-add', {did});
  const privateDidDocument = await helpers.getSynchronizedDid(options);
  // create the key
  // TODO: implement passphrase
  const keyPair = await LDKeyPair.from({
    controller: did, privateKeyBase58, publicKeyBase58,
    type: 'Ed25519VerificationKey2018'
  });

  keyPair.id = privateDidDocument.generateKeyId({did, keyPair});
  if(keyPair.id in privateDidDocument.keys) {
    throw new Error('The key already exists.');
  }

  // activate a JSON patch observer which will be resolved in _send.
  privateDidDocument.observe();
  privateDidDocument.addKey({key: keyPair, proofPurpose});

  logger._log(options, 'DID local update successful.');

  await _send(
github digitalbazaar / did-io / lib / methods / veres-one / veres-did-doc.js View on Github external
async importKeys(data = {}, options = {}) {
    for(const keyData of Object.values(data)) {
      const key = await LDKeyPair.from(keyData,
        {injector: this.injector, ...options});
      this.keys[key.id] = key;
    }
  }

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

48 / 100
Full package analysis