Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function _generateDid() {
const mockDoc = jsonld.util.clone(mockData.privateDidDocuments.alpha);
const capabilityInvocationKey = await Ed25519KeyPair.generate();
const keyFingerprint = `z${capabilityInvocationKey.fingerprint()}`;
const did = `did:v1:test:nym:${keyFingerprint}`;
// cryptonym dids are based on fingerprint of capabilityInvokation key
mockDoc.id = did;
capabilityInvocationKey.id = _generateKeyId(
{did, key: capabilityInvocationKey});
const controller = did;
capabilityInvocationKey.controller = controller;
mockDoc.capabilityInvocation[0] = {
id: capabilityInvocationKey.id,
type: capabilityInvocationKey.type,
controller: capabilityInvocationKey.controller,
publicKeyBase58: capabilityInvocationKey.publicKeyBase58
};
const authenticationKey = await Ed25519KeyPair.generate();
const keyFingerprint = `z${capabilityInvocationKey.fingerprint()}`;
const did = `did:v1:test:nym:${keyFingerprint}`;
// cryptonym dids are based on fingerprint of capabilityInvokation key
mockDoc.id = did;
capabilityInvocationKey.id = _generateKeyId(
{did, key: capabilityInvocationKey});
const controller = did;
capabilityInvocationKey.controller = controller;
mockDoc.capabilityInvocation[0] = {
id: capabilityInvocationKey.id,
type: capabilityInvocationKey.type,
controller: capabilityInvocationKey.controller,
publicKeyBase58: capabilityInvocationKey.publicKeyBase58
};
const authenticationKey = await Ed25519KeyPair.generate();
authenticationKey.id = _generateKeyId(
{did, key: authenticationKey});
authenticationKey.controller = controller;
mockDoc.authentication[0] = {
id: authenticationKey.id,
type: authenticationKey.type,
controller: authenticationKey.controller,
publicKeyBase58: authenticationKey.publicKeyBase58
};
const documentLoader = await _createDidDocumentLoader({record: mockDoc});
return {
authenticationKey, did, documentLoader, mockDoc, capabilityInvocationKey
};
}
const createEd25519Keys = async () => {
const key = await Ed25519KeyPair.generate();
return key;
};