How to use the jsonld-signatures.verify 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.

github decentralized-identity / github-did / packages / lib / src / v2 / func / verifyWithResolver.js View on Github external
const verifyWithResolver = async (signedData, resolver) => {
  const verificationMethod = signedData.proof.verificationMethod
    ? signedData.proof.verificationMethod
    : signedData.proof.creator;
  const doc = await resolver.resolve(verificationMethod);

  const didPublicKey = doc.publicKey.find(k => {
    return k.id == verificationMethod;
  });

  if (didPublicKey.type === "Ed25519VerificationKey2018") {
    const result = await jsigs.verify(signedData, {
      documentLoader: wrappedDocumentLoader({
        //args that are needed in the wrapper.. such as zcaps
      }),
      suite: new Ed25519Signature2018({
        key: new Ed25519KeyPair(didPublicKey)
      }),
      purpose: new AssertionProofPurpose({ controller: doc })
    });

    return result.verified;
  }

  return OpenPgpSignature2019.verify({
    data: signedData,
    signatureAttribute: "proof",
    publicKey: getPublicKeyFromDIDDoc(doc, verificationMethod)
github digitalbazaar / vc-js / lib / vc.js View on Github external
.map(c => {
      const credential = JSON.parse(JSON.stringify(c));
      credential['@context'] = presentation['@context'];
      return verify({credential, documentLoader, ...options});
    }));

  const allCredentialsVerified = credentialResult.every(r => r.verified);

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

  const presentationResult = jsigs.verify(presentation, {purpose, documentLoader, ...options});

  return {
    verified: (presentationResult.verified && allCredentialsVerified),
    results: [].concat([presentationResult, credentialResult]),
    error: presentationResult.error
  };
}
github digitalbazaar / vc-js / lib / vc.js View on Github external
return {
      verified: false,
      results: [{credential, verified: false, error}],
      error
    };
  }

  const documentLoader = options.documentLoader || defaultDocumentLoader;

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

  return jsigs.verify(credential, {purpose, documentLoader, ...options});
}

jsonld-signatures

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

BSD-3-Clause
Latest version published 1 month ago

Package Health Score

79 / 100
Full package analysis

Similar packages