Skip to content

Commit e59889f

Browse files
committed
Append proofValue with invalid proof header bytes.
1 parent 9417172 commit e59889f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

tests/helpers.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const require = createRequire(import.meta.url);
1616
// and gets the bytes
1717
export const getBs58Bytes = s => bs58.decode(s.slice(1));
1818
export const getBs64UrlBytes = s => bs64.decode(s.slice(1));
19+
export const encodeBs64Url = bytes => bs64.encode(bytes);
1920

2021
// Javascript's default ISO timestamp contains milliseconds.
2122
// This lops off the MS part of the UTC RFC3339 TimeStamp and replaces

tests/suites/algorithms-sd.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ import {
77
generators,
88
issueCloned
99
} from 'data-integrity-test-suite-assertion';
10-
import {createInitialVc, getBs64UrlBytes} from '../helpers.js';
10+
import {
11+
createInitialVc,
12+
encodeBs64Url,
13+
getBs64UrlBytes
14+
} from '../helpers.js';
1115
import {expect} from 'chai';
1216
import {getMultiKey} from '../vc-generator/key-gen.js';
1317
import {getSuites} from './helpers.js';
@@ -334,8 +338,17 @@ async function _setup({
334338
nonbase64ProofValue.proof.proofValue.substring(1);
335339
credentials.set('invalidProofValuePrefix', nonbase64ProofValue);
336340
const invalidProofValueHeader = structuredClone(securedCredential);
341+
// get the bytes
337342
const disclosureBytes = getBs64UrlBytes(
338343
invalidProofValueHeader?.proof?.proofValue);
339-
credentials.set('invalidDisclosureProofHeader', null);
344+
// remove the 3 byte prefix and replace with an invalid prefix
345+
const invalidBuffer = Buffer.concat(
346+
[Buffer.from([0xA1, 0x44, 0x01]), disclosureBytes.slice(3)],
347+
disclosureBytes.length
348+
);
349+
// replace the proofValue with a newer proofValue with an
350+
// invalid 3 byte header
351+
invalidProofValueHeader.proof.proofValue = `u${encodeBs64Url(invalidBuffer)}`;
352+
credentials.set('invalidDisclosureProofHeader', invalidProofValueHeader);
340353
return credentials;
341354
}

0 commit comments

Comments
 (0)