33 * SPDX-License-Identifier: BSD-3-Clause
44 */
55import {
6- assertIssuedVc ,
7- createInitialVc ,
8- createValidCredential ,
9- getProofs ,
6+ generateCredential ,
7+ multikeyFromVerificationMethod ,
8+ proofExists ,
9+ secureCredential ,
1010 setupReportableTestSuite ,
1111 setupRow
1212} from './helpers.js' ;
13+ import {
14+ assertDataIntegrityProof
15+ } from './assertions.js' ;
1316import chai from 'chai' ;
1417import { endpoints } from 'vc-test-suite-implementations' ;
18+ import { expect } from 'chai' ;
1519
1620const should = chai . should ( ) ;
1721
@@ -29,39 +33,41 @@ const {match: issuers} = endpoints.filterByTag({
2933describe ( 'Data Model - Verification Methods (Multikey)' , function ( ) {
3034 setupReportableTestSuite ( this ) ;
3135 this . implemented = [ ...issuers . keys ( ) ] ;
32- let validCredential ;
33- before ( async function ( ) {
34- validCredential = await createValidCredential ( ) ;
35- } ) ;
3636 for ( const [ columnId , { endpoints} ] of issuers ) {
3737 describe ( columnId , function ( ) {
3838 const [ issuer ] = endpoints ;
39- let issuedVc ;
40- let proofs ;
41- let ecdsaProofs = [ ] ;
39+ let securedCredential ;
4240 before ( async function ( ) {
43- issuedVc = await createInitialVc ( { issuer, vc : validCredential } ) ;
44- proofs = getProofs ( issuedVc ) ;
45- if ( proofs ?. length ) {
46- ecdsaProofs = proofs . filter (
47- proof => cryptosuites . includes ( proof ?. cryptosuite ) ) ;
48- }
41+ securedCredential = await secureCredential (
42+ { issuer, vc : generateCredential ( ) } ) ;
4943 } ) ;
5044 beforeEach ( setupRow ) ;
5145 it ( 'The publicKeyMultibase value of the verification method ' +
5246 'MUST start with the base-58-btc prefix (z), as defined in ' +
5347 'the Multibase section of Controller Documents 1.0.' ,
5448 async function ( ) {
5549 this . test . link = 'https://www.w3.org/TR/vc-di-ecdsa/#dataintegrityproof' ;
56- assertIssuedVc ( issuedVc , proofs , ecdsaProofs ) ;
50+ const proof = proofExists ( securedCredential ) ;
51+ const verificationMethod = proof . verificationMethod ;
52+ // Only did key is supported
53+ const keyType = issuer . settings . supportedEcdsaKeyTypes [ 0 ] ;
54+ const multikey =
55+ await multikeyFromVerificationMethod ( verificationMethod , keyType ) ;
56+ expect ( multikey . startsWith ( 'z' ) ) . to . be . true ;
5757 } ) ;
5858 it ( 'A Multibase-encoded ECDSA 256-bit public key value or an ' +
5959 'ECDSA 384-bit public key value follows, as defined in the Multikey ' +
6060 'section of Controller Documents 1.0. Any other encoding ' +
6161 'MUST NOT be allowed.' ,
6262 async function ( ) {
6363 this . test . link = 'https://www.w3.org/TR/vc-di-ecdsa/#dataintegrityproof' ;
64- assertIssuedVc ( issuedVc , proofs , ecdsaProofs ) ;
64+ const proof = proofExists ( securedCredential ) ;
65+ const verificationMethod = proof . verificationMethod ;
66+ // Only did key is supported
67+ const keyType = issuer . settings . supportedEcdsaKeyTypes [ 0 ] ;
68+ const multikey =
69+ await multikeyFromVerificationMethod ( verificationMethod , keyType ) ;
70+ expect ( multikey ) . to . be . exist ;
6571 } ) ;
6672 } ) ;
6773 }
@@ -70,35 +76,40 @@ describe('Data Model - Verification Methods (Multikey)', function() {
7076describe ( 'Data Model - Proof Representations' , function ( ) {
7177 setupReportableTestSuite ( this ) ;
7278 this . implemented = [ ...issuers . keys ( ) ] ;
73- let validCredential ;
74- before ( async function ( ) {
75- validCredential = await createValidCredential ( ) ;
76- } ) ;
7779 for ( const [ columnId , { endpoints} ] of issuers ) {
7880 describe ( columnId , function ( ) {
7981 const [ issuer ] = endpoints ;
80- let issuedVc ;
81- let proofs ;
82- let ecdsaProofs = [ ] ;
82+ let securedCredential ;
8383 before ( async function ( ) {
84- issuedVc = await createInitialVc ( { issuer, vc : validCredential } ) ;
85- proofs = getProofs ( issuedVc ) ;
86- if ( proofs ?. length ) {
87- ecdsaProofs = proofs . filter (
88- proof => cryptosuites . includes ( proof ?. cryptosuite ) ) ;
89- }
84+ securedCredential = await secureCredential (
85+ { issuer, vc : generateCredential ( ) } ) ;
9086 } ) ;
9187 beforeEach ( setupRow ) ;
88+ it ( 'A proof contains the attributes specified in the ' +
89+ 'Proofs section of [VC-DATA-INTEGRITY].' ,
90+ async function ( ) {
91+ this . test . link = 'https://www.w3.org/TR/vc-di-ecdsa/#dataintegrityproof' ;
92+ const proof = proofExists ( securedCredential ) ;
93+ assertDataIntegrityProof ( proof ) ;
94+ } ) ;
9295 it ( 'The type property MUST be DataIntegrityProof.' ,
9396 async function ( ) {
9497 this . test . link = 'https://www.w3.org/TR/vc-di-ecdsa/#dataintegrityproof' ;
95- assertIssuedVc ( issuedVc , proofs , ecdsaProofs ) ;
98+ const proof = proofExists ( securedCredential ) ;
99+ should . exist ( proof . type ,
100+ 'Expected a type on the proof.' ) ;
101+ proof . type . should . equal ( 'DataIntegrityProof' ,
102+ 'Expected DataIntegrityProof type.' ) ;
96103 } ) ;
97104 it ( 'The cryptosuite property MUST be ecdsa-rdfc-2019, ' +
98- 'ecdsa-jcs-2019, or ecdsa-sd-2023.' ,
105+ 'ecdsa-jcs-2019, or ecdsa-sd-2023.' ,
99106 async function ( ) {
100107 this . test . link = 'https://www.w3.org/TR/vc-di-ecdsa/#dataintegrityproof' ;
101- assertIssuedVc ( issuedVc , proofs , ecdsaProofs ) ;
108+ const proof = proofExists ( securedCredential ) ;
109+ should . exist ( proof . cryptosuite ,
110+ 'Expected a cryptosuite identifier on the proof.' ) ;
111+ proof . cryptosuite . should . be . oneOf ( cryptosuites ,
112+ `Expected cryptosuite for be one of ${ cryptosuites } .` ) ;
102113 } ) ;
103114 } ) ;
104115 }
0 commit comments