From 21cc11d1017f31ce3981224c05401d3fad133e43 Mon Sep 17 00:00:00 2001 From: "Charles E. Lehner" Date: Thu, 3 Feb 2022 16:28:21 -0500 Subject: [PATCH] Update ZKP tests for changes in VC Data Model v1.1 - Remove requirement for credentialSchema - Remove requirement for verifiable presentation proof - Add skipped test for credential definition - Add skipped test about derived verifiable credential --- implementations/generate.js | 11 +++ test/vc-data-model-1.0/60-zkp.js | 87 +++---------------- ...015-zkp-bad-no-credential-schema-id.jsonld | 28 ------ ...5-zkp-bad-no-credential-schema-type.jsonld | 28 ------ ...le-015-zkp-bad-no-credential-schema.jsonld | 25 ------ ...ple-015-zkp-credential-schema-array.jsonld | 37 -------- ...015-zkp-vp-bad-no-credential-schema.jsonld | 29 ------- 7 files changed, 21 insertions(+), 224 deletions(-) delete mode 100644 test/vc-data-model-1.0/input/example-015-zkp-bad-no-credential-schema-id.jsonld delete mode 100644 test/vc-data-model-1.0/input/example-015-zkp-bad-no-credential-schema-type.jsonld delete mode 100644 test/vc-data-model-1.0/input/example-015-zkp-bad-no-credential-schema.jsonld delete mode 100644 test/vc-data-model-1.0/input/example-015-zkp-credential-schema-array.jsonld delete mode 100644 test/vc-data-model-1.0/input/example-015-zkp-vp-bad-no-credential-schema.jsonld diff --git a/implementations/generate.js b/implementations/generate.js index 7c0501c..2291613 100644 --- a/implementations/generate.js +++ b/implementations/generate.js @@ -46,8 +46,19 @@ const deprecatedTests = [ 'Basic Documents Presentations MUST include `verifiableCredential` and `proof`', 'Basic Documents Presentations MUST include `verifiableCredential` and `proof` (negative - missing `verifiableCredential`)', 'Basic Documents Presentations MUST include `verifiableCredential` and `proof` (negative - missing `proof`)', + 'Zero-Knowledge Proofs (optional) A verifiable credential... MUST contain a credentialSchema', + 'Zero-Knowledge Proofs (optional) A verifiable credential... MUST contain a credentialSchema (negative - credentialSchema missing)', + 'Zero-Knowledge Proofs (optional) A verifiable credential... Each credentialSchema... MUST specify a type', + 'Zero-Knowledge Proofs (optional) A verifiable credential... Each credentialSchema... MUST specify a type (negative - type missing)', + 'Zero-Knowledge Proofs (optional) A verifiable credential... Each credentialSchema... MUST specify an `id` property', + 'Zero-Knowledge Proofs (optional) A verifiable credential... Each credentialSchema... MUST specify an `id` property (negative - `id` missing)', + 'Zero-Knowledge Proofs (optional) A verifiable credential... Each credentialSchema... value of `id` MUST be a URI identifying a schema file', 'Zero-Knowledge Proofs (optional) A verifiable presentation... MUST include `verifiableCredential`', 'Zero-Knowledge Proofs (optional) A verifiable presentation... MUST include `verifiableCredential` (negative - missing `verifiableCredential`)', + 'Zero-Knowledge Proofs (optional) A verifiable presentation... MUST include `proof`', + 'Zero-Knowledge Proofs (optional) A verifiable presentation... MUST include `proof` (negative - missing `proof`)', + 'Zero-Knowledge Proofs (optional) A verifiable presentation... Each verifiable credential... MUST have a `credentialSchema` member', + 'Zero-Knowledge Proofs (optional) A verifiable presentation... Each verifiable credential... MUST contain a credentialSchema (negative - credentialSchema missing)' ]; const invalidTests = [ diff --git a/test/vc-data-model-1.0/60-zkp.js b/test/vc-data-model-1.0/60-zkp.js index 48beaf1..dc9d970 100644 --- a/test/vc-data-model-1.0/60-zkp.js +++ b/test/vc-data-model-1.0/60-zkp.js @@ -27,63 +27,13 @@ describe('Zero-Knowledge Proofs (optional)', function() { }); describe('A verifiable credential...', function() { - it('MUST contain a credentialSchema', async function() { - const doc = await util.generate('example-015-zkp.jsonld', generatorOptions); - const isArray = Array.isArray(doc.credentialSchema) && - doc.credentialSchema.length > 0; - const isObject = doc.credentialSchema && typeof doc.credentialSchema.id === 'string'; - expect(isArray || isObject).to.be.true; - }); - it('MUST contain a credentialSchema (negative - credentialSchema missing)', async function() { - await expect(util.generate( - 'example-015-zkp-bad-no-credential-schema.jsonld', generatorOptions)) - .to.be.rejectedWith(Error); + it.skip('derived verifiable credential MUST contain all information necessary to verify', async function() { + /*Each derived verifiable credential within a verifiable presentation MUST + contain all information necessary to verify the verifiable credential, + either by including it directly within the credential, or by referencing + the necessary information.*/ }); - describe('Each credentialSchema...', function() { - it('MUST specify a type', async function() { - const doc = await util.generate('example-015-zkp-credential-schema-array.jsonld', - generatorOptions); - should.exist(doc.credentialSchema); - let schemas = [].concat(doc.credentialSchema); - expect(schemas.length > 0).to.be.true; - - for(let schema of schemas) { - schema.type.should.be.a('string'); - } - }); - it('MUST specify a type (negative - type missing)', async function() { - await expect(util.generate( - 'example-015-zkp-bad-no-credential-schema-type.jsonld', generatorOptions)) - .to.be.rejectedWith(Error); - }); - it('MUST specify an `id` property', async function() { - // test for `id` property existence - const doc = await util.generate('example-015-zkp.jsonld', generatorOptions); - should.exist(doc.credentialSchema.id); - let schemas = [].concat(doc.credentialSchema); - expect(schemas.length > 0).to.be.true; - - for(let schema of schemas) { - schema.id.should.be.a('string'); - } - }); - it('MUST specify an `id` property (negative - `id` missing)', async function() { - await expect(util.generate( - 'example-015-zkp-bad-no-credential-schema-id.jsonld', generatorOptions)) - .to.be.rejectedWith(Error); - }); - - it('value of `id` MUST be a URI identifying a schema file', async function() { - // test that `id`'s value is a valid URI - // TODO: https://github.com/w3c/vc-data-model/issues/381 - const doc = await util.generate('example-015-zkp.jsonld', generatorOptions); - const schemas = [].concat(doc.credentialSchema); - for(let schema of schemas) { - expect(schema.id).to.match(uriRegex); - } - }); - }); // all verifiable credentials need to have a proof, // so these tests feel redundant it('MUST contain a proof', async function() { @@ -128,28 +78,11 @@ describe('Zero-Knowledge Proofs (optional)', function() { expect(hasType(doc, 'VerifiablePresentation')).to.be.true; }); - describe('Each verifiable credential...', function() { - it('MUST have a `credentialSchema` member', async function() { - const doc = await util.generatePresentation('example-015-zkp-vp.jsonld', generatorOptions); - if (Array.isArray(doc.verifiableCredential)) { - let creds = [].concat(doc.verifiableCredential) - for(let cred of creds){ - const isArray = Array.isArray(cred.credentialSchema) && cred.credentialSchema.length > 0; - const isObject = cred.credentialSchema && typeof cred.credentialSchema.id === 'string'; - expect(isArray || isObject).to.be.true; - } - } else { - // only one credential - const isArray = Array.isArray(doc.verifiableCredential.credentialSchema) && doc.verifiableCredential.credentialSchema.length > 0; - const isObject = doc.verifiableCredential.credentialSchema && typeof doc.verifiableCredential.credentialSchema.id === 'string'; - expect(isArray || isObject).to.be.true; - } - }); - it('MUST contain a credentialSchema (negative - credentialSchema missing)', async function() { - await expect(util.generate( - 'example-015-zkp-vp-bad-no-credential-schema.jsonld', generatorOptions)) - .to.be.rejectedWith(Error); - }); + it.skip('credential definition MUST be defined in credentialSchema', async function() { + /*If a credential definition is being used, the credential + definition MUST be defined in the credentialSchema property, + so that it can be used by all parties to perform various cryptographic + operations in zero-knowledge.*/ }); it.skip('MUST NOT leak information', async function() { diff --git a/test/vc-data-model-1.0/input/example-015-zkp-bad-no-credential-schema-id.jsonld b/test/vc-data-model-1.0/input/example-015-zkp-bad-no-credential-schema-id.jsonld deleted file mode 100644 index 880e90e..0000000 --- a/test/vc-data-model-1.0/input/example-015-zkp-bad-no-credential-schema-id.jsonld +++ /dev/null @@ -1,28 +0,0 @@ -{ - "@context": [ - "https://www.w3.org/2018/credentials/v1", - "https://www.w3.org/2018/credentials/examples/v1" - ], - "type": ["VerifiableCredential", "UniversityDegreeCredential"], - "credentialSchema": { - "type": "did:example:schema:22KpkXgecryx9k7N6XN1QoN3gXwBkSU8SfyyYQG" - }, - "issuer": "did:example:Wz4eUg7SetGfaUVCn8U9d62oDYrUJLuUtcy619", - "issuanceDate": "2010-01-01T19:23:24Z", - "credentialSubject": { - "givenName": "Jane", - "familyName": "Doe", - "degree": { - "type": "BachelorDegree", - "name": "Bachelor of Science in Mechanical Engineering", - "college": "College of Engineering" - } - }, - "proof": { - "type": "CLSignature2019", - "issuerData": "5NQ4TgzNfSQxoLzf2d5AV3JNiCdMaTgm...BXiX5UggB381QU7ZCgqWivUmy4D", - "attributes": "pPYmqDvwwWBDPNykXVrBtKdsJDeZUGFA...tTERiLqsZ5oxCoCSodPQaggkDJy", - "signature": "8eGWSiTiWtEA8WnBwX4T259STpxpRKuk...kpFnikqqSP3GMW7mVxC4chxFhVs", - "signatureCorrectnessProof": "SNQbW3u1QV5q89qhxA1xyVqFa6jCrKwv...dsRypyuGGK3RhhBUvH1tPEL8orH" - } -} diff --git a/test/vc-data-model-1.0/input/example-015-zkp-bad-no-credential-schema-type.jsonld b/test/vc-data-model-1.0/input/example-015-zkp-bad-no-credential-schema-type.jsonld deleted file mode 100644 index bcf17df..0000000 --- a/test/vc-data-model-1.0/input/example-015-zkp-bad-no-credential-schema-type.jsonld +++ /dev/null @@ -1,28 +0,0 @@ -{ - "@context": [ - "https://www.w3.org/2018/credentials/v1", - "https://www.w3.org/2018/credentials/examples/v1" - ], - "type": ["VerifiableCredential", "UniversityDegreeCredential"], - "credentialSchema": { - "id": "did:example:cdf:35LB7w9ueWbagPL94T9bMLtyXDj9pX5o" - }, - "issuer": "did:example:Wz4eUg7SetGfaUVCn8U9d62oDYrUJLuUtcy619", - "issuanceDate": "2010-01-01T19:23:24Z", - "credentialSubject": { - "givenName": "Jane", - "familyName": "Doe", - "degree": { - "type": "BachelorDegree", - "name": "Bachelor of Science in Mechanical Engineering", - "college": "College of Engineering" - } - }, - "proof": { - "type": "CLSignature2019", - "issuerData": "5NQ4TgzNfSQxoLzf2d5AV3JNiCdMaTgm...BXiX5UggB381QU7ZCgqWivUmy4D", - "attributes": "pPYmqDvwwWBDPNykXVrBtKdsJDeZUGFA...tTERiLqsZ5oxCoCSodPQaggkDJy", - "signature": "8eGWSiTiWtEA8WnBwX4T259STpxpRKuk...kpFnikqqSP3GMW7mVxC4chxFhVs", - "signatureCorrectnessProof": "SNQbW3u1QV5q89qhxA1xyVqFa6jCrKwv...dsRypyuGGK3RhhBUvH1tPEL8orH" - } -} diff --git a/test/vc-data-model-1.0/input/example-015-zkp-bad-no-credential-schema.jsonld b/test/vc-data-model-1.0/input/example-015-zkp-bad-no-credential-schema.jsonld deleted file mode 100644 index ecac873..0000000 --- a/test/vc-data-model-1.0/input/example-015-zkp-bad-no-credential-schema.jsonld +++ /dev/null @@ -1,25 +0,0 @@ -{ - "@context": [ - "https://www.w3.org/2018/credentials/v1", - "https://www.w3.org/2018/credentials/examples/v1" - ], - "type": ["VerifiableCredential", "UniversityDegreeCredential"], - "issuer": "did:example:Wz4eUg7SetGfaUVCn8U9d62oDYrUJLuUtcy619", - "issuanceDate": "2010-01-01T19:23:24Z", - "credentialSubject": { - "givenName": "Jane", - "familyName": "Doe", - "degree": { - "type": "BachelorDegree", - "name": "Bachelor of Science in Mechanical Engineering", - "college": "College of Engineering" - } - }, - "proof": { - "type": "CLSignature2019", - "issuerData": "5NQ4TgzNfSQxoLzf2d5AV3JNiCdMaTgm...BXiX5UggB381QU7ZCgqWivUmy4D", - "attributes": "pPYmqDvwwWBDPNykXVrBtKdsJDeZUGFA...tTERiLqsZ5oxCoCSodPQaggkDJy", - "signature": "8eGWSiTiWtEA8WnBwX4T259STpxpRKuk...kpFnikqqSP3GMW7mVxC4chxFhVs", - "signatureCorrectnessProof": "SNQbW3u1QV5q89qhxA1xyVqFa6jCrKwv...dsRypyuGGK3RhhBUvH1tPEL8orH" - } -} diff --git a/test/vc-data-model-1.0/input/example-015-zkp-credential-schema-array.jsonld b/test/vc-data-model-1.0/input/example-015-zkp-credential-schema-array.jsonld deleted file mode 100644 index e9a865a..0000000 --- a/test/vc-data-model-1.0/input/example-015-zkp-credential-schema-array.jsonld +++ /dev/null @@ -1,37 +0,0 @@ -{ - "@context": [ - "https://www.w3.org/2018/credentials/v1", - "https://www.w3.org/2018/credentials/examples/v1" - ], - "type": ["VerifiableCredential", "UniversityDegreeCredential"], - "credentialSchema": [ - { - "id": "did:example:cdf:35LB7w9ueWbagPL94T9bMLtyXDj9pX5o", - "type": "did:example:schema:22KpkXgecryx9k7N6XN1QoN3gXwBkSU8SfyyYQG" - }, - { - "id": "https://example.org/examples/degree.json", - "type": "JsonSchemaValidator2018" - } - ], - "issuer": "did:example:Wz4eUg7SetGfaUVCn8U9d62oDYrUJLuUtcy619", - "issuanceDate": "2010-01-01T19:23:24Z", - "credentialSubject": { - "givenName": "Jane", - "familyName": "Doe", - "degree": { - "type": "BachelorDegree", - "name": "Bachelor of Science in Mechanical Engineering", - "college": "College of Engineering" - } - }, - "proof": { - "type": "CLSignature2019", - "issuerData": "5NQ4TgzNfSQxoLzf2d5AV3JNiCdMaTgm...BXiX5UggB381QU7ZCgqWivUmy4D", - "attributes": "pPYmqDvwwWBDPNykXVrBtKdsJDeZUGFA...tTERiLqsZ5oxCoCSodPQaggkDJy", - "signature": "8eGWSiTiWtEA8WnBwX4T259STpxpRKuk...kpFnikqqSP3GMW7mVxC4chxFhVs", - "signatureCorrectnessProof": "SNQbW3u1QV5q89qhxA1xyVqFa6jCrKwv...dsRypyuGGK3RhhBUvH1tPEL8orH" - } -} - - diff --git a/test/vc-data-model-1.0/input/example-015-zkp-vp-bad-no-credential-schema.jsonld b/test/vc-data-model-1.0/input/example-015-zkp-vp-bad-no-credential-schema.jsonld deleted file mode 100644 index 3a0f0c2..0000000 --- a/test/vc-data-model-1.0/input/example-015-zkp-vp-bad-no-credential-schema.jsonld +++ /dev/null @@ -1,29 +0,0 @@ -{ - "@context": [ - "https://www.w3.org/2018/credentials/v1", - "https://www.w3.org/2018/credentials/examples/v1" - ], - "type": "VerifiablePresentation", - "verifiableCredential": { - "@context": [ - "https://www.w3.org/2018/credentials/v1", - "https://www.w3.org/2018/credentials/examples/v1" - ], - "type": ["VerifiableCredential", "UniversityDegreeCredential"], - "issuer": "did:example:Wz4eUg7SetGfaUVCn8U9d62oDYrUJLuUtcy619", - "issuanceDate": "2010-01-01T19:23:24Z", - "credentialSubject": { - "degreeType": "BachelorDegree", - "degreeSchool": "College of Engineering" - }, - "proof": { - "type": "ex:AnonCredDerivedCredentialv1", - "primaryProof": "cg7wLNSi48K5qNyAVMwdYqVHSMv1Ur8i...Fg2ZvWF6zGvcSAsym2sgSk737", - "nonRevocationProof": "mu6fg24MfJPU1HvSXsf3ybzKARib4WxG...RSce53M6UwQCxYshCuS3d2h" - } - }, - "proof": { - "type": "ex:AnonCredPresentationProofv1", - "proofValue": "DgYdYMUYHURJLD7xdnWRinqWCEY5u5fK...j915Lt3hMzLHoPiPQ9sSVfRrs1D" - } -}