How to use the jsonld-signatures.sign function in jsonld-signatures

To help you get started, we’ve selected a few jsonld-signatures 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-cli / lib / driver-veres.js View on Github external
sign: ['ledgerEvent', (results, callback) => {
      const privateKeyPem =
        pki.privateKeyToPem(results.generateKeyPair.privateKey);

      // sign the DID Document
      jsigs.sign(results.ledgerEvent, {
        algorithm: 'LinkedDataSignature2015',
        privateKeyPem: privateKeyPem,
        creator: did + '/keys/1'
      }, (err, result) => {
        if(err) {
          return callback(err);
        }
        callback(null, result);
      });
    }],
    postDidDocument: ['pow', 'sign', (results, callback) => {
github digitalbazaar / vc-js / lib / vc.js View on Github external
const documentLoader = options.documentLoader || defaultDocumentLoader;

  const {controller, domain} = options;
  const purpose = options.purpose || new CredentialIssuancePurpose({
    controller,
    domain
  });

  // run common credential checks
  const {credential} = options;
  if(!credential) {
    throw new TypeError('"credential" property is required for issuing.');
  }
  _checkCredential(credential);

  return jsigs.sign(credential, {purpose, documentLoader, ...options});
}
github digitalbazaar / vc-js / tests / 10-verify.spec.js View on Github external
async function _generateCredential() {
  const mockCredential = jsonld.clone(mockData.credentials.alpha);
  const {authenticationKey, documentLoader} = await _generateDid();
  const {Ed25519Signature2018} = jsigs.suites;
  const {AuthenticationProofPurpose} = jsigs.purposes;
  testLoader.addLoader(documentLoader);
  const credential = await jsigs.sign(mockCredential, {
    compactProof: false,
    documentLoader: testLoader.documentLoader.bind(testLoader),
    suite: new Ed25519Signature2018({key: authenticationKey}),
    purpose: new AuthenticationProofPurpose({
      challenge: 'challengeString'
    })
  });
  return {credential, documentLoader};
}
github digitalbazaar / vc-js / tests / 10-verify.spec.js View on Github external
async function _generatePresentation({challenge, domain}) {
  const mockPresentation = jsonld.clone(mockData.presentations.alpha);
  const {authenticationKey, documentLoader: dlp} = await _generateDid();
  testLoader.addLoader(dlp);
  const {Ed25519Signature2018} = jsigs.suites;
  const {AuthenticationProofPurpose} = jsigs.purposes;
  const {credential, documentLoader: dlc} = await _generateCredential();
  testLoader.addLoader(dlc);
  mockPresentation.verifiableCredential.push(credential);
  const presentation = await jsigs.sign(mockPresentation, {
    compactProof: false,
    documentLoader: testLoader.documentLoader.bind(testLoader),
    suite: new Ed25519Signature2018({key: authenticationKey}),
    purpose: new AuthenticationProofPurpose({challenge, domain})
  });
  return {presentation};
}
github digitalbazaar / vc-js / lib / vc.js View on Github external
for(const c of presentation.verifiableCredential) {
    const credential = JSON.parse(JSON.stringify(c));
    credential['@context'] = presentation['@context'];
    _checkCredential(credential);
  }

  const documentLoader = options.documentLoader || defaultDocumentLoader;

  const {controller, domain, challenge} = options;
  const purpose = options.purpose || new CredentialIssuancePurpose({
    controller,
    domain,
    challenge
  });

  return jsigs.sign(presentation, {purpose, documentLoader, ...options});
}

jsonld-signatures

An implementation of the Linked Data Signatures specifications for JSON-LD in JavaScript.

BSD-3-Clause
Latest version published 12 months ago

Package Health Score

67 / 100
Full package analysis