Skip to content

Commit

Permalink
Add working tests for invalid proofValue elements
Browse files Browse the repository at this point in the history
  • Loading branch information
aljones15 committed Nov 18, 2024
1 parent f32e4f5 commit 4ee9352
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/suites/algorithms-sd.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import {
encodeBs64Url,
getBs64UrlBytes
} from '../helpers.js';
import {
parseDisclosureProofValue,
serializeProofValue
} from './stubs.js';
import {expect} from 'chai';
import {getMultiKey} from '../vc-generator/key-gen.js';
import {getSuites} from './helpers.js';
Expand Down Expand Up @@ -355,5 +359,10 @@ async function _setup({
invalidProofValueHeader.proof.proofValue = `u${encodeBs64Url(invalidBuffer)}`;
credentials.set('invalidDisclosureProofHeader', invalidProofValueHeader);
const invalidProofArray = structuredClone(securedCredential);
const params = parseDisclosureProofValue({proof: invalidProofArray.proof});
invalidProofArray.proof.proofValue = serializeProofValue({
payload: [params.baseSignature, params.publicKey]
});
credentials.set('invalidProofArray', invalidProofArray);
return credentials;
}
12 changes: 12 additions & 0 deletions tests/suites/stubs.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ function serializeDisclosureProofValue({
return `u${base64url.encode(cbor)}`;
}

// ecdsa-sd-2023 test data creation function
export function serializeProofValue({
prefix = CBOR_PREFIX_DERIVED,
payload,
typeEncoders
}) {
const cbor = _concatBuffers([
prefix, cborg.encode(payload, {useMaps: true, typeEncoders})
]);
return `u${base64url.encode(cbor)}`;
}

// ecdsa-sd-2023 derive helper
async function _createDisclosureData({
cryptosuite, document, proof, documentLoader
Expand Down

0 comments on commit 4ee9352

Please sign in to comment.