diff --git a/src/vc/vc.controller.ts b/src/vc/vc.controller.ts index ac887d1..747836a 100644 --- a/src/vc/vc.controller.ts +++ b/src/vc/vc.controller.ts @@ -18,6 +18,12 @@ export class VcController { return this.VcService.sign(body.DID, body.payload); } + + @Post('/multi-sign') + multiSign(@Body() body: any) { + return this.VcService.multiSign(body.signerDIDs, body.toSign); + } + @ApiOperation({ summary: 'Verify a signed VC' }) @Post('/verify') verify(@Body() body: VerifyJsonDTO) { diff --git a/src/vc/vc.service.ts b/src/vc/vc.service.ts index 8accc38..30ace10 100644 --- a/src/vc/vc.service.ts +++ b/src/vc/vc.service.ts @@ -13,6 +13,26 @@ export default class VcService { private readonly vault: VaultService, ) {} + + async multiSign(signerDIDs: string[], toSign: string) { + try { + for (let i = 0; i < signerDIDs.length; i++) { + const signedResult = await this.sign(signerDIDs[i], toSign); + toSign['proof'] = { + proofValue: signedResult.signed, + created: new Date().toISOString(), + type: process.env.SIGNING_ALGORITHM, + verificationMethod: signerDIDs[i], + proofPurpose: 'assertionMethod', + } + } + + return toSign; + } catch (err) { + throw new InternalServerErrorException(`Error in multi signing the document`); + } + } + async sign(signerDID: string, toSign: string) { let did: Identity; try {