Skip to content

Commit f28651e

Browse files
committed
Remove stubDerived & DRY up proofValue serialization.
1 parent 4ee9352 commit f28651e

File tree

1 file changed

+5
-28
lines changed

1 file changed

+5
-28
lines changed

tests/suites/stubs.js

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -52,30 +52,6 @@ export class DeriveStub {
5252
return revealDoc;
5353
}
5454
}
55-
// Stubs the ecdsa-sd-2023 derive function
56-
export async function stubDerive({
57-
cryptosuite, document, proofSet,
58-
documentLoader, dataIntegrityProof
59-
}) {
60-
// find matching base `proof` in `proofSet`
61-
const {options: {proofId}} = cryptosuite;
62-
const baseProof = await _findProof({proofId, proofSet, dataIntegrityProof});
63-
// generate data for disclosure
64-
const {
65-
baseSignature, publicKey, signatures, labelMap, mandatoryIndexes, revealDoc
66-
} = await _createDisclosureData(
67-
{cryptosuite, document, proof: baseProof, documentLoader});
68-
69-
// create new disclosure proof
70-
const newProof = {...baseProof};
71-
newProof.proofValue = await serializeDisclosureProofValue(
72-
{baseSignature, publicKey, signatures, labelMap, mandatoryIndexes});
73-
74-
// attach proof to reveal doc w/o context
75-
delete newProof['@context'];
76-
revealDoc.proof = newProof;
77-
return revealDoc;
78-
}
7955

8056
// ecdsa-sd-2023 method that uses invalid cbor tags
8157
function serializeDisclosureProofValue({
@@ -95,10 +71,11 @@ function serializeDisclosureProofValue({
9571
// array of numbers
9672
mandatoryIndexes
9773
];
98-
const cbor = _concatBuffers([
99-
CBOR_PREFIX_DERIVED, cborg.encode(payload, {useMaps: true, typeEncoders})
100-
]);
101-
return `u${base64url.encode(cbor)}`;
74+
return serializeProofValue({
75+
prefix: CBOR_PREFIX_DERIVED,
76+
payload,
77+
typeEncoders
78+
});
10279
}
10380

10481
// ecdsa-sd-2023 test data creation function

0 commit comments

Comments
 (0)