@@ -8,25 +8,60 @@ import {expect} from 'chai';
88export function algorithmSuite ( {
99 suiteName
1010} ) {
11- it ( 'When generating ECDSA signatures, the signature value MUST be ' +
12- 'expressed according to section 7 of [RFC4754] (sometimes referred to ' +
13- 'as the IEEE P1363 format) and encoded according to the specific ' +
14- 'cryptosuite proof generation algorithm.' , async function ( ) {
15- this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#algorithms:~:text=When%20generating%20ECDSA%20signatures%2C%20the%20signature%20value%20MUST%20be%20expressed%20according%20to%20section%207%20of%20%5BRFC4754%5D%20(sometimes%20referred%20to%20as%20the%20IEEE%20P1363%20format)%20and%20encoded%20according%20to%20the%20specific%20cryptosuite%20proof%20generation%20algorithm' ;
16- } ) ;
17- it ( 'For P-256 keys, the default hashing function, SHA-2 with 256 bits of ' +
18- 'output, MUST be used.' , async function ( ) {
19- this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#algorithms:~:text=For%20P%2D256%20keys%2C%20the%20default%20hashing%20function%2C%20SHA%2D2%20with%20256%20bits%20of%20output%2C%20MUST%20be%20used.' ;
20- } ) ;
21- it ( 'For P-384 keys, SHA-2 with 384-bits of output MUST be used, specified ' +
22- 'via the RDFC-1.0 implementation-specific parameter.' , async function ( ) {
23- this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#algorithms:~:text=For%20P%2D384%20keys%2C%20SHA%2D2%20with%20384%2Dbits%20of%20output%20MUST%20be%20used%2C%20specified%20via%20the%20RDFC%2D1.0%20implementation%2Dspecific%20parameter.' ;
24- } ) ;
11+ }
12+
13+ export function commonAlgorithms ( {
14+ credential,
15+ issuers,
16+ mandatoryPointers,
17+ keyType,
18+ suiteName,
19+ vcVersion
20+ } ) {
21+ for ( const [ name , { endpoints} ] of issuers ) {
22+ const [ issuer ] = endpoints ;
23+ // does the endpoint support this test?
24+ if ( ! endpointCheck ( { endpoint : issuer , keyType, vcVersion} ) ) {
25+ continue ;
26+ }
27+ describe ( `${ name } : ${ keyType } ` , function ( ) {
28+ let securedCredential = null ;
29+ let proofs = [ ] ;
30+ before ( async function ( ) {
31+ securedCredential = await createInitialVc ( {
32+ issuer,
33+ vcVersion,
34+ vc : credential ,
35+ mandatoryPointers
36+ } ) ;
37+ if ( securedCredential ) {
38+ proofs = Array . isArray ( securedCredential . proof ) ?
39+ securedCredential ?. proof : [ securedCredential ?. proof ] ;
40+ // only test proofs that match the relevant cryptosuite
41+ proofs = proofs . filter ( p => p ?. cryptosuite === suiteName ) ;
42+ }
43+ } ) ;
44+ it ( 'When generating ECDSA signatures, the signature value MUST be ' +
45+ 'expressed according to section 7 of [RFC4754] (sometimes referred to ' +
46+ 'as the IEEE P1363 format) and encoded according to the specific ' +
47+ 'cryptosuite proof generation algorithm.' , async function ( ) {
48+ this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#algorithms:~:text=When%20generating%20ECDSA%20signatures%2C%20the%20signature%20value%20MUST%20be%20expressed%20according%20to%20section%207%20of%20%5BRFC4754%5D%20(sometimes%20referred%20to%20as%20the%20IEEE%20P1363%20format)%20and%20encoded%20according%20to%20the%20specific%20cryptosuite%20proof%20generation%20algorithm' ;
49+ } ) ;
50+ it ( 'For P-256 keys, the default hashing function, SHA-2 with 256 bits of ' +
51+ 'output, MUST be used.' , async function ( ) {
52+ this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#algorithms:~:text=For%20P%2D256%20keys%2C%20the%20default%20hashing%20function%2C%20SHA%2D2%20with%20256%20bits%20of%20output%2C%20MUST%20be%20used.' ;
53+ } ) ;
54+ it ( 'For P-384 keys, SHA-2 with 384-bits of output MUST be used, specified ' +
55+ 'via the RDFC-1.0 implementation-specific parameter.' , async function ( ) {
56+ this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#algorithms:~:text=For%20P%2D384%20keys%2C%20SHA%2D2%20with%20384%2Dbits%20of%20output%20MUST%20be%20used%2C%20specified%20via%20the%20RDFC%2D1.0%20implementation%2Dspecific%20parameter.' ;
57+ } ) ;
58+ } ) ;
59+ }
2560}
2661
2762export function ecdsaRdfc2019Algorithms ( {
2863 credential,
29- endpoints ,
64+ verifiers ,
3065 mandatoryPointers,
3166 keyType,
3267 suiteName,
@@ -35,13 +70,13 @@ export function ecdsaRdfc2019Algorithms({
3570 return describe ( `${ suiteName } - Algorithms - VC ${ vcVersion } ` , function ( ) {
3671 this . matrix = true ;
3772 this . report = true ;
38- this . implemented = [ ...endpoints ] ;
73+ this . implemented = [ ...verifiers ] ;
3974 this . rowLabel = 'Test Name' ;
4075 this . columnLabel = 'Implementation' ;
41- for ( const [ name , { endpoints : issuers } ] of endpoints ) {
42- const [ issuer ] = issuers ;
76+ for ( const [ name , { endpoints} ] of verifiers ) {
77+ const [ verifier ] = endpoints ;
4378 // does the endpoint support this test?
44- if ( ! endpointCheck ( { endpoint : issuer , keyType, vcVersion} ) ) {
79+ if ( ! endpointCheck ( { endpoint : verifier , keyType, vcVersion} ) ) {
4580 continue ;
4681 }
4782 describe ( `${ name } : ${ keyType } ` , function ( ) {
@@ -75,14 +110,6 @@ export function ecdsaRdfc2019Algorithms({
75110 it ( 'Whenever this algorithm encodes strings, it MUST use UTF-8 ' +
76111 'encoding. (proof.type)' , async function ( ) {
77112 this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#transformation-ecdsa-rdfc-2019' ;
78- for ( const proof of proofs ) {
79- expect ( proof ?. type ) . to . exist ;
80- expect ( proof . type ) . to . be . a ( 'string' ) ;
81- expect (
82- proof . type . isWellFormed ( ) ,
83- 'Expected string to be a well formed UTF string'
84- ) . to . be . true ;
85- }
86113 } ) ;
87114 it ( 'If options.type is not set to the string DataIntegrityProof ' +
88115 'and options.cryptosuite is not set to the string ecdsa-rdfc-2019, ' +
0 commit comments