@@ -8,25 +8,60 @@ import {expect} from 'chai';
8
8
export function algorithmSuite ( {
9
9
suiteName
10
10
} ) {
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
+ }
25
60
}
26
61
27
62
export function ecdsaRdfc2019Algorithms ( {
28
63
credential,
29
- endpoints ,
64
+ verifiers ,
30
65
mandatoryPointers,
31
66
keyType,
32
67
suiteName,
@@ -35,13 +70,13 @@ export function ecdsaRdfc2019Algorithms({
35
70
return describe ( `${ suiteName } - Algorithms - VC ${ vcVersion } ` , function ( ) {
36
71
this . matrix = true ;
37
72
this . report = true ;
38
- this . implemented = [ ...endpoints ] ;
73
+ this . implemented = [ ...verifiers ] ;
39
74
this . rowLabel = 'Test Name' ;
40
75
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 ;
43
78
// does the endpoint support this test?
44
- if ( ! endpointCheck ( { endpoint : issuer , keyType, vcVersion} ) ) {
79
+ if ( ! endpointCheck ( { endpoint : verifier , keyType, vcVersion} ) ) {
45
80
continue ;
46
81
}
47
82
describe ( `${ name } : ${ keyType } ` , function ( ) {
@@ -75,14 +110,6 @@ export function ecdsaRdfc2019Algorithms({
75
110
it ( 'Whenever this algorithm encodes strings, it MUST use UTF-8 ' +
76
111
'encoding. (proof.type)' , async function ( ) {
77
112
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
- }
86
113
} ) ;
87
114
it ( 'If options.type is not set to the string DataIntegrityProof ' +
88
115
'and options.cryptosuite is not set to the string ecdsa-rdfc-2019, ' +
0 commit comments