From 9ed3574c26568a601fb110910643aa1427457858 Mon Sep 17 00:00:00 2001 From: Maycon Mello Date: Mon, 23 Mar 2026 12:40:10 -0300 Subject: [PATCH 1/2] Make attributesToReveal optional to support default presentation generation --- .../verification-flow/bbs-plus-valid.test.ts | 72 +++++++++++++++++++ packages/core/src/verification-controller.ts | 13 +++- .../wasm/src/services/credential/service.ts | 4 +- 3 files changed, 86 insertions(+), 3 deletions(-) diff --git a/integration-tests/verification-flow/bbs-plus-valid.test.ts b/integration-tests/verification-flow/bbs-plus-valid.test.ts index 713c148e..2627fe6c 100644 --- a/integration-tests/verification-flow/bbs-plus-valid.test.ts +++ b/integration-tests/verification-flow/bbs-plus-valid.test.ts @@ -147,5 +147,77 @@ describe('BBS+ presentations', () => { expect(verificationResults.verified).toBe(true); }); + it('should generate presentation without explicit attributesToReveal', async () => { + const wallet: IWallet = await getWallet(); + const controller = await createVerificationController({ + wallet, + }); + + const proofRequest = { + qr: 'https://creds-example.dock.io/proof/d3c0c23e-efb5-41fc-a8a9-6213507f419a', + id: 'd3c0c23e-efb5-41fc-a8a9-6213507f419a', + name: 'BasicCredential Template', + nonce: '08ec5ca2e2446b50b25a55e1b6b21f2b', + created: '2023-10-02T21:30:55.851Z', + updated: '2023-10-02T21:30:55.851Z', + verified: false, + response_url: `/proof-requests/d3c0c23e-efb5-41fc-a8a9-6213507f419a/send-presentation`, + request: { + id: '1cf6a349-f1d3-42f7-b751-8de7fb5fde6c', + input_descriptors: [ + { + id: 'Credential 1', + name: 'Basic Credential (Biometrics)', + purpose: 'Basic Credential with proof of biometrics', + constraints: { + fields: [ + { + path: ['$.expirationDate'], + }, + { + path: ['$.type'], + }, + { + path: [ + '$.issuer.id', + '$.issuer', + '$.vc.issuer.id', + '$.vc.issuer', + '$.iss', + ], + }, + ], + }, + }, + ], + }, + type: 'proof-request', + }; + + await controller.start({ + template: proofRequest, + }); + + // No attributesToReveal specified - let PEX template handle it + controller.selectedCredentials.set(credential.id, { + credential: credential, + }); + + const presentation = await controller.createPresentation(); + + const verificationResults = await credentialService.verifyPresentation({ + presentation, + options: { + compactProof: true, + resolver: blockchainService.resolver, + challenge: proofRequest.nonce, + unsignedPresentation: true, + domain: 'dock.io', + }, + }); + + expect(verificationResults.verified).toBe(true); + }); + afterAll(() => closeWallet()); }); diff --git a/packages/core/src/verification-controller.ts b/packages/core/src/verification-controller.ts index 0aa94aaa..ef499f14 100644 --- a/packages/core/src/verification-controller.ts +++ b/packages/core/src/verification-controller.ts @@ -24,6 +24,12 @@ export enum VerificationStatus { type CredentialId = string; type CredentialSelection = { credential: any; + /** + * Optional list of credential attributes to reveal in the presentation. + * When omitted, the credential-sdk automatically determines which attributes + * to reveal based on the PEX (Presentation Exchange) template requirements. + * This allows generating a default presentation without manual attribute selection. + */ attributesToReveal?: string[]; }; type CredentialSelectionMap = Map; @@ -192,11 +198,14 @@ export function createVerificationController({ } if (bbsKvacSelections.length > 0) { + // When attributesToReveal is undefined, the credential-sdk will automatically + // determine which attributes to reveal based on the PEX template requirements. + // This enables generating a default presentation without manual attribute selection. const credentialsWithWitness = await Promise.all( bbsKvacSelections.map(async sel => ({ credential: sel.credential, witness: await credentialProvider.getMembershipWitness(sel.credential.id), - attributesToReveal: sel.attributesToReveal || [], + attributesToReveal: sel.attributesToReveal, })), ); @@ -221,7 +230,7 @@ export function createVerificationController({ credentials: credentialsWithWitness.map(c => ({ credential: c.credential, witness: c.witness, - attributesToReveal: [...(c.attributesToReveal || []), 'id'], + attributesToReveal: c.attributesToReveal, })), }); diff --git a/packages/wasm/src/services/credential/service.ts b/packages/wasm/src/services/credential/service.ts index b9363238..00760d1d 100644 --- a/packages/wasm/src/services/credential/service.ts +++ b/packages/wasm/src/services/credential/service.ts @@ -766,7 +766,9 @@ class CredentialService { const attributesToSkip = descriptorBounds[idx] ? descriptorBounds[idx].map(bound => bound.attributeName) : []; - const filteredAttributes = attributesToReveal.filter( + // attributesToReveal may be undefined when using default presentation generation, + // in which case only PEX-required attributes will be revealed + const filteredAttributes = (attributesToReveal || []).filter( attribute => !attributesToSkip.includes(attribute) && !shouldSkipAttribute(attribute), ); const _pexRequiredAttributes = pexRequiredAttributes[idx] || []; From 4d74e4e553189dc72429123a7e586cd82974f792 Mon Sep 17 00:00:00 2001 From: Maycon Mello Date: Mon, 23 Mar 2026 13:42:44 -0300 Subject: [PATCH 2/2] Fix bbs-plus test proof request to match test credential fields --- .../verification-flow/bbs-plus-valid.test.ts | 122 ++++++------------ 1 file changed, 39 insertions(+), 83 deletions(-) diff --git a/integration-tests/verification-flow/bbs-plus-valid.test.ts b/integration-tests/verification-flow/bbs-plus-valid.test.ts index 2627fe6c..7fe223c5 100644 --- a/integration-tests/verification-flow/bbs-plus-valid.test.ts +++ b/integration-tests/verification-flow/bbs-plus-valid.test.ts @@ -72,54 +72,51 @@ const credential = { }, }; +const proofRequest = { + qr: 'https://creds-example.dock.io/proof/d3c0c23e-efb5-41fc-a8a9-6213507f419a', + id: 'd3c0c23e-efb5-41fc-a8a9-6213507f419a', + name: 'BasicCredential Template', + nonce: '08ec5ca2e2446b50b25a55e1b6b21f2b', + created: '2023-10-02T21:30:55.851Z', + updated: '2023-10-02T21:30:55.851Z', + verified: false, + response_url: `/proof-requests/d3c0c23e-efb5-41fc-a8a9-6213507f419a/send-presentation`, + request: { + id: '1cf6a349-f1d3-42f7-b751-8de7fb5fde6c', + input_descriptors: [ + { + id: 'Credential 1', + name: 'Basic Credential (Biometrics)', + purpose: 'Basic Credential with proof of biometrics', + constraints: { + fields: [ + { + path: ['$.type'], + }, + { + path: [ + '$.issuer.id', + '$.issuer', + '$.vc.issuer.id', + '$.vc.issuer', + '$.iss', + ], + }, + ], + }, + }, + ], + }, + type: 'proof-request', +}; + describe('BBS+ presentations', () => { - it('should verify valid bbs+ credential', async () => { + it('should verify valid bbs+ credential with explicit attributesToReveal', async () => { const wallet: IWallet = await getWallet(); const controller = await createVerificationController({ wallet, }); - const proofRequest = { - qr: 'https://creds-example.dock.io/proof/d3c0c23e-efb5-41fc-a8a9-6213507f419a', - id: 'd3c0c23e-efb5-41fc-a8a9-6213507f419a', - name: 'BasicCredential Template', - nonce: '08ec5ca2e2446b50b25a55e1b6b21f2b', - created: '2023-10-02T21:30:55.851Z', - updated: '2023-10-02T21:30:55.851Z', - verified: false, - response_url: `/proof-requests/d3c0c23e-efb5-41fc-a8a9-6213507f419a/send-presentation`, - request: { - id: '1cf6a349-f1d3-42f7-b751-8de7fb5fde6c', - input_descriptors: [ - { - id: 'Credential 1', - name: 'Basic Credential (Biometrics)', - purpose: 'Basic Credential with proof of biometrics', - constraints: { - fields: [ - { - path: ['$.expirationDate'], - }, - { - path: ['$.type'], - }, - { - path: [ - '$.issuer.id', - '$.issuer', - '$.vc.issuer.id', - '$.vc.issuer', - '$.iss', - ], - }, - ], - }, - }, - ], - }, - type: 'proof-request', - }; - await controller.start({ template: proofRequest, }); @@ -153,47 +150,6 @@ describe('BBS+ presentations', () => { wallet, }); - const proofRequest = { - qr: 'https://creds-example.dock.io/proof/d3c0c23e-efb5-41fc-a8a9-6213507f419a', - id: 'd3c0c23e-efb5-41fc-a8a9-6213507f419a', - name: 'BasicCredential Template', - nonce: '08ec5ca2e2446b50b25a55e1b6b21f2b', - created: '2023-10-02T21:30:55.851Z', - updated: '2023-10-02T21:30:55.851Z', - verified: false, - response_url: `/proof-requests/d3c0c23e-efb5-41fc-a8a9-6213507f419a/send-presentation`, - request: { - id: '1cf6a349-f1d3-42f7-b751-8de7fb5fde6c', - input_descriptors: [ - { - id: 'Credential 1', - name: 'Basic Credential (Biometrics)', - purpose: 'Basic Credential with proof of biometrics', - constraints: { - fields: [ - { - path: ['$.expirationDate'], - }, - { - path: ['$.type'], - }, - { - path: [ - '$.issuer.id', - '$.issuer', - '$.vc.issuer.id', - '$.vc.issuer', - '$.iss', - ], - }, - ], - }, - }, - ], - }, - type: 'proof-request', - }; - await controller.start({ template: proofRequest, });