Skip to content

Commit 4ee9352

Browse files
committed
Add working tests for invalid proofValue elements
1 parent f32e4f5 commit 4ee9352

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

tests/suites/algorithms-sd.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import {
1212
encodeBs64Url,
1313
getBs64UrlBytes
1414
} from '../helpers.js';
15+
import {
16+
parseDisclosureProofValue,
17+
serializeProofValue
18+
} from './stubs.js';
1519
import {expect} from 'chai';
1620
import {getMultiKey} from '../vc-generator/key-gen.js';
1721
import {getSuites} from './helpers.js';
@@ -355,5 +359,10 @@ async function _setup({
355359
invalidProofValueHeader.proof.proofValue = `u${encodeBs64Url(invalidBuffer)}`;
356360
credentials.set('invalidDisclosureProofHeader', invalidProofValueHeader);
357361
const invalidProofArray = structuredClone(securedCredential);
362+
const params = parseDisclosureProofValue({proof: invalidProofArray.proof});
363+
invalidProofArray.proof.proofValue = serializeProofValue({
364+
payload: [params.baseSignature, params.publicKey]
365+
});
366+
credentials.set('invalidProofArray', invalidProofArray);
358367
return credentials;
359368
}

tests/suites/stubs.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,18 @@ function serializeDisclosureProofValue({
101101
return `u${base64url.encode(cbor)}`;
102102
}
103103

104+
// ecdsa-sd-2023 test data creation function
105+
export function serializeProofValue({
106+
prefix = CBOR_PREFIX_DERIVED,
107+
payload,
108+
typeEncoders
109+
}) {
110+
const cbor = _concatBuffers([
111+
prefix, cborg.encode(payload, {useMaps: true, typeEncoders})
112+
]);
113+
return `u${base64url.encode(cbor)}`;
114+
}
115+
104116
// ecdsa-sd-2023 derive helper
105117
async function _createDisclosureData({
106118
cryptosuite, document, proof, documentLoader

0 commit comments

Comments
 (0)