How to use the jsonld-signatures.suites 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 / vc-js / tests / 10-verify.spec.js View on Github external
before(async () => {
  // Set up the key that will be signing and verifying
  keyPair = await Ed25519KeyPair.generate({
    id: 'https://example.edu/issuers/keys/1',
    controller: 'https://example.com/i/carol'
  });

  // Register the controller document and the key document with documentLoader
  contexts['https://example.com/i/carol'] = assertionController;
  contexts['https://example.edu/issuers/keys/1'] = keyPair.publicNode();

  // Add the key to the Controller doc (authorizes its use for assertion)
  assertionController.assertionMethod.push(keyPair.id);

  // Set up the signature suite, using the generated key
  suite = new jsigs.suites.Ed25519Signature2018({
    verificationMethod: 'https://example.edu/issuers/keys/1',
    key: keyPair
  });
});
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 poetapp / poet-js / src / Interfaces.ts View on Github external
.required()
    .uri({
      scheme: ['po.et', 'http', 'https', 'did', 'data'],
    }),
  issuanceDate: Joi.string()
    .required()
    .isoDate(),
  type: Joi.string()
    .required()
    .only([ClaimType.Identity, ClaimType.Work]),
  claim: Joi.object().required(),
}

const signatureSchema = {
  '@graph': Joi.object().keys({
    '@type': Joi.string().only(Object.keys(JSONLD_SIGS.suites).map(suite => `sec:${suite}`)),
    'http://purl.org/dc/terms/created': Joi.object().keys({
      '@type': Joi.string().uri(),
      '@value': Joi.string()
        .required()
        .isoDate(),
    }),
    'http://purl.org/dc/terms/creator': Joi.object({
      '@id': Joi.string()
        .required()
        .uri({ scheme: ['po.et', 'http', 'https', 'did', 'data'] }),
    }),
    'dc:creator': Joi.object({
      '@id': Joi.string()
        .required()
        .uri({ scheme: ['po.et', 'http', 'https', 'did', 'data'] }),
    }),
github decentralized-identity / github-did / packages / lib / src / v2 / func / verifyWithResolver.js View on Github external
const getPublicKeyFromDIDDoc = require("./getPublicKeyFromDIDDoc");
const OpenPgpSignature2019 = require("@transmute/openpgpsignature2019");
const wrappedDocumentLoader = require("./wrappedDocumentLoader");

const jsigs = require("jsonld-signatures");
const { Ed25519Signature2018 } = jsigs.suites;
const { AssertionProofPurpose } = jsigs.purposes;
const { Ed25519KeyPair } = require("crypto-ld");

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({

jsonld-signatures

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

BSD-3-Clause
Latest version published 1 year ago

Package Health Score

58 / 100
Full package analysis