Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
});
});
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};
}
.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'] }),
}),
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({