From ca859c357d5cef54033ea664f9f236f670e64a9a Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Tue, 18 Jun 2024 18:32:52 +0000 Subject: [PATCH 1/8] Add invalid created tests. --- tests/setup.js | 9 ++++++++- tests/suites/verify.js | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/setup.js b/tests/setup.js index 5e8a2d5..c898c40 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -130,7 +130,8 @@ export async function verifySetup({credentials, keyTypes, suite}) { suiteName: suite, keys }); - const {mandatory} = generators; + const {mandatory, created} = generators; + const {invalidCreated} = created; const {invalidCryptosuite, invalidProofType} = mandatory; disclosed.invalid.proofTypeAndCryptosuite = await deriveCredentials({ @@ -207,6 +208,12 @@ export async function verifySetup({credentials, keyTypes, suite}) { } } disclosed.invalid.valuePrefix = valuePrefix; + disclosed.invalid.created = await deriveCredentials({ + keys, + vectors: transformVectors(subjectNestedObjects), + suiteName: suite, + generators: [invalidCreated] + }); return { base, disclosed diff --git a/tests/suites/verify.js b/tests/suites/verify.js index a07e3ee..9defcf6 100644 --- a/tests/suites/verify.js +++ b/tests/suites/verify.js @@ -154,6 +154,14 @@ export function verifySuite({ verifier }); }); + it('If proofConfig.created is set and if the value is not a valid ' + + '[XMLSCHEMA11-2] datetime, an INVALID_PROOF_DATETIME error MUST be ' + + 'raised.', async function() { + this.test.link = 'https://w3c.github.io/vc-di-bbs/#linkage-via-proof-options-and-mandatory-reveal:~:text=If%20proofConfig.created%20is%20set%20and%20if%20the%20value%20is%20not%20a%20valid%20%5BXMLSCHEMA11%2D2%5D%20datetime%2C%20an%20INVALID_PROOF_DATETIME%20error%20MUST%20be%20raised.'; + const credential = cloneTestVector( + disclosed?.invalid?.created); + await verificationFail({credential, verifier}); + }); it('MUST fail to verify a base proof.', async function() { const credential = cloneTestVector(base); await verificationFail({credential, verifier}); From 20127fc06675ab2df8aaacb8d71395e1f153f197 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Tue, 18 Jun 2024 18:36:27 +0000 Subject: [PATCH 2/8] Add initialParams to overwrite defaults. --- tests/setup.js | 4 ++++ tests/vc-generator/index.js | 1 + 2 files changed, 5 insertions(+) diff --git a/tests/setup.js b/tests/setup.js index c898c40..4f88ce7 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -212,6 +212,10 @@ export async function verifySetup({credentials, keyTypes, suite}) { keys, vectors: transformVectors(subjectNestedObjects), suiteName: suite, + initialParams: { + // disclosed suite has no created + selectiveSuite: null + }, generators: [invalidCreated] }); return { diff --git a/tests/vc-generator/index.js b/tests/vc-generator/index.js index a22f426..bfaa4ae 100644 --- a/tests/vc-generator/index.js +++ b/tests/vc-generator/index.js @@ -110,6 +110,7 @@ export async function deriveCredentials({ suite: getSuite({suite: suiteName, signer, mandatoryPointers}), selectiveSuite: getSuite({suite: suiteName, signer, selectivePointers}), credential: _credential, + // add the ability to overwrite the defaults ...initialParams }; // call each generator on itself to produce accumulated invalid suites From 46876f41c757c9fb2381d63b3e1e7f5ae5cdbbe2 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Tue, 18 Jun 2024 21:02:23 +0000 Subject: [PATCH 3/8] Add FIXME for invalid created test. --- tests/suites/verify.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/suites/verify.js b/tests/suites/verify.js index 9defcf6..9f97489 100644 --- a/tests/suites/verify.js +++ b/tests/suites/verify.js @@ -158,8 +158,10 @@ export function verifySuite({ '[XMLSCHEMA11-2] datetime, an INVALID_PROOF_DATETIME error MUST be ' + 'raised.', async function() { this.test.link = 'https://w3c.github.io/vc-di-bbs/#linkage-via-proof-options-and-mandatory-reveal:~:text=If%20proofConfig.created%20is%20set%20and%20if%20the%20value%20is%20not%20a%20valid%20%5BXMLSCHEMA11%2D2%5D%20datetime%2C%20an%20INVALID_PROOF_DATETIME%20error%20MUST%20be%20raised.'; - const credential = cloneTestVector( - disclosed?.invalid?.created); + const credential = cloneTestVector(disclosed?.invalid?.created); + //FIXME assert on error code or message when available + //a base proof will fail verification in any case + //we need to know the specific reason it fails await verificationFail({credential, verifier}); }); it('MUST fail to verify a base proof.', async function() { From 7c747a8f4ad018aae388e78ef6ab0de9e3155e61 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Thu, 20 Jun 2024 10:44:34 -0400 Subject: [PATCH 4/8] Add FIXME for testing created with disclosed VC. --- tests/setup.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/setup.js b/tests/setup.js index 4f88ce7..62bf4c5 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -213,7 +213,8 @@ export async function verifySetup({credentials, keyTypes, suite}) { vectors: transformVectors(subjectNestedObjects), suiteName: suite, initialParams: { - // disclosed suite has no created + // FIXME while created is not recommended for bbs it should be in + // the disclosed VC too. selectiveSuite: null }, generators: [invalidCreated] From 117c5ab21e89680b5ac0e36a10c652700ffb0282 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Wed, 26 Jun 2024 19:36:01 +0000 Subject: [PATCH 5/8] Update tests/suites/verify.js update test title to match spec test about created. Co-authored-by: Ted Thibodeau Jr --- tests/suites/verify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/suites/verify.js b/tests/suites/verify.js index 9f97489..5527691 100644 --- a/tests/suites/verify.js +++ b/tests/suites/verify.js @@ -154,7 +154,7 @@ export function verifySuite({ verifier }); }); - it('If proofConfig.created is set and if the value is not a valid ' + + it('If proofConfig.created is set and the value is not a valid ' + '[XMLSCHEMA11-2] datetime, an INVALID_PROOF_DATETIME error MUST be ' + 'raised.', async function() { this.test.link = 'https://w3c.github.io/vc-di-bbs/#linkage-via-proof-options-and-mandatory-reveal:~:text=If%20proofConfig.created%20is%20set%20and%20if%20the%20value%20is%20not%20a%20valid%20%5BXMLSCHEMA11%2D2%5D%20datetime%2C%20an%20INVALID_PROOF_DATETIME%20error%20MUST%20be%20raised.'; From e703ff7d6e760d394b90e0dea1d09cf599e5b78d Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Fri, 28 Jun 2024 21:50:00 +0000 Subject: [PATCH 6/8] stub verify data to so created is not deleted. --- tests/setup.js | 10 +++------- tests/vc-generator/generators.js | 8 ++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/setup.js b/tests/setup.js index 62bf4c5..886d3ea 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -6,7 +6,8 @@ import * as base64url from 'base64url-universal'; import { allowUnsafeCanonize, invalidCborEncoding, - invalidStringEncoding + invalidStringEncoding, + passCreated } from './vc-generator/generators.js'; import { deriveCredentials, @@ -212,12 +213,7 @@ export async function verifySetup({credentials, keyTypes, suite}) { keys, vectors: transformVectors(subjectNestedObjects), suiteName: suite, - initialParams: { - // FIXME while created is not recommended for bbs it should be in - // the disclosed VC too. - selectiveSuite: null - }, - generators: [invalidCreated] + generators: [invalidCreated, passCreated] }); return { base, diff --git a/tests/vc-generator/generators.js b/tests/vc-generator/generators.js index e2ddf7a..985e757 100644 --- a/tests/vc-generator/generators.js +++ b/tests/vc-generator/generators.js @@ -13,6 +13,14 @@ export function allowUnsafeCanonize({suite, selectiveSuite, ...args}) { return {...args, suite, selectiveSuite}; } +export function passCreated({suite, ...args}) { + suite._cryptosuite = stubMethods({ + object: suite._cryptosuite, + stubs: {createVerifyData: stubs.stubVerifyData({deleteCreated: false})}, + }); + return {...args, suite}; +} + export function invalidStringEncoding({suite, selectiveSuite, ...args}) { suite._cryptosuite = stubMethods({ object: suite._cryptosuite, From 20a3f4ef5be8e3a3c1127a4bd9e5d93e76d8bcb6 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Fri, 28 Jun 2024 21:54:34 +0000 Subject: [PATCH 7/8] Shorten FIXME about asserting on error codes. --- tests/suites/verify.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/suites/verify.js b/tests/suites/verify.js index 5527691..3e110c4 100644 --- a/tests/suites/verify.js +++ b/tests/suites/verify.js @@ -160,8 +160,6 @@ export function verifySuite({ this.test.link = 'https://w3c.github.io/vc-di-bbs/#linkage-via-proof-options-and-mandatory-reveal:~:text=If%20proofConfig.created%20is%20set%20and%20if%20the%20value%20is%20not%20a%20valid%20%5BXMLSCHEMA11%2D2%5D%20datetime%2C%20an%20INVALID_PROOF_DATETIME%20error%20MUST%20be%20raised.'; const credential = cloneTestVector(disclosed?.invalid?.created); //FIXME assert on error code or message when available - //a base proof will fail verification in any case - //we need to know the specific reason it fails await verificationFail({credential, verifier}); }); it('MUST fail to verify a base proof.', async function() { From 4dbc92ad49b3ec93eefd6edb86b623ab497ad944 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 1 Jul 2024 20:37:57 +0000 Subject: [PATCH 8/8] Update test title for proofConfig.created & link. --- tests/suites/verify.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/suites/verify.js b/tests/suites/verify.js index 3e110c4..22ac03c 100644 --- a/tests/suites/verify.js +++ b/tests/suites/verify.js @@ -154,10 +154,10 @@ export function verifySuite({ verifier }); }); - it('If proofConfig.created is set and the value is not a valid ' + - '[XMLSCHEMA11-2] datetime, an INVALID_PROOF_DATETIME error MUST be ' + - 'raised.', async function() { - this.test.link = 'https://w3c.github.io/vc-di-bbs/#linkage-via-proof-options-and-mandatory-reveal:~:text=If%20proofConfig.created%20is%20set%20and%20if%20the%20value%20is%20not%20a%20valid%20%5BXMLSCHEMA11%2D2%5D%20datetime%2C%20an%20INVALID_PROOF_DATETIME%20error%20MUST%20be%20raised.'; + it('If proofConfig.created is set and if the value is not a valid ' + + '[XMLSCHEMA11-2] datetime, an error MUST be raised and SHOULD convey ' + + 'an error type of PROOF_GENERATION_ERROR.', async function() { + this.test.link = 'https://w3c.github.io/vc-di-bbs/#:~:text=If%20proofConfig.created%20is%20set%20and%20if%20the%20value%20is%20not%20a%20valid%20%5BXMLSCHEMA11%2D2%5D%20datetime%2C%20an%20error%20MUST%20be%20raised%20and%20SHOULD%20convey%20an%20error%20type%20of%20PROOF_GENERATION_ERROR.'; const credential = cloneTestVector(disclosed?.invalid?.created); //FIXME assert on error code or message when available await verificationFail({credential, verifier});