Skip to content

Commit

Permalink
fix createCryptosuite structure
Browse files Browse the repository at this point in the history
  • Loading branch information
wes-smith committed Feb 1, 2024
1 parent 9aaa695 commit 4ee0cd6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
8 changes: 4 additions & 4 deletions lib/sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import {concat} from './helper.js';
import {createVerifier} from './createVerifier.js';

//TODO - need two different kinds?
export function createCryptosuite(extraInformation)
export function createCryptosuite({extraInformation=''}={})
{
const additionalHash = extraInformation;
const options = {extraInformation};
return {
name,
requiredAlgorithm,
createVerifier,
createVerifyData: _createSignData,
additionalHash
options
};
}

Expand All @@ -30,7 +30,7 @@ async function _createSignData({

const options = {documentLoader};
const proofHash = await hashCanonizedProof({document, proof, options});
const externalHash = cryptosuite.additionalHash;
const externalHash = cryptosuite.options.extraInformation;
const docCanon = await canonize(document);

const hasher = createHasher();
Expand Down
39 changes: 20 additions & 19 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,33 @@ const documentLoader = loader.build();

// create the unsigned credential
const unsignedCredential = {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/vdl/v1",
"https://w3id.org/vdl/aamva/v1"
],
"type": [
"VerifiableCredential",
"Pdf417DataIntegrityCredential"
],
"issuer": "pdf417:issuer",
"credentialStatus": {
"type": "Pdf417StatusList",
"index": 283749
'@context': [
'https://www.w3.org/2018/credentials/v1',
{
'@protected': true,
AlumniCredential: 'urn:example:AlumniCredential',
alumniOf: 'https://schema.org#alumniOf'
},
"credentialSubject": {
"type": "Pdf417Barcode",
}
};
'https://w3id.org/security/data-integrity/v2'
],
id: 'urn:uuid:98c5cffc-efa2-43e3-99f5-01e8ef404be0',
type: ['VerifiableCredential', 'AlumniCredential'],
issuer: controller,
issuanceDate: '2010-01-01T19:23:24Z',
credentialSubject: {
id: 'urn:uuid:d58b2365-0951-4373-96c8-e886d61829f2',
alumniOf: 'Example University'
}
};


let utf8Encode = new TextEncoder();
const additionalHash = utf8Encode.encode("6d721ae5d334cead832a8576bdd24d9a");
const extraInformation = utf8Encode.encode("6d721ae5d334cead832a8576bdd24d9a");

// create suite
const suite = new DataIntegrityProof({
signer: keyPair.signer(),
cryptosuite: createCryptosuite(additionalHash)
cryptosuite: createCryptosuite({extraInformation})
});

// create signed credential
Expand Down

0 comments on commit 4ee0cd6

Please sign in to comment.