2
2
* Copyright 2024 Digital Bazaar, Inc.
3
3
* SPDX-License-Identifier: BSD-3-Clause
4
4
*/
5
+ import {
6
+ assertions ,
7
+ generators ,
8
+ issueCloned
9
+ } from 'data-integrity-test-suite-assertion' ;
5
10
import { createInitialVc , endpointCheck } from '../helpers.js' ;
6
11
import { expect } from 'chai' ;
12
+ import { localVerifier } from '../vc-verifier/index.js' ;
7
13
8
14
export function algorithmSuite ( {
9
15
suiteName
@@ -15,9 +21,11 @@ export function commonAlgorithms({
15
21
issuers,
16
22
mandatoryPointers,
17
23
keyType,
24
+ cryptosuite,
18
25
suiteName,
19
26
vcVersion
20
27
} ) {
28
+ const verifier = localVerifier ( { cryptosuite} ) ;
21
29
for ( const [ name , { endpoints} ] of issuers ) {
22
30
const [ issuer ] = endpoints ;
23
31
// does the endpoint support this test?
@@ -26,35 +34,48 @@ export function commonAlgorithms({
26
34
}
27
35
describe ( `${ name } : ${ keyType } ` , function ( ) {
28
36
let securedCredential = null ;
29
- let proofs = [ ] ;
30
37
before ( async function ( ) {
31
38
securedCredential = await createInitialVc ( {
32
39
issuer,
33
40
vcVersion,
34
41
vc : credential ,
35
42
mandatoryPointers
36
43
} ) ;
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
} ) ;
44
45
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 ' +
46
+ 'expressed according to section 7 of [RFC4754] (sometimes referred ' +
47
+ 'to as the IEEE P1363 format) and encoded according to the specific ' +
47
48
'cryptosuite proof generation algorithm.' , async function ( ) {
48
49
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' ;
50
+ await assertions . verificationSuccess ( {
51
+ credential : securedCredential ,
52
+ verifier,
53
+ reason : `Should verify VC signed with ${ suiteName } ${ keyType } `
54
+ } ) ;
49
55
} ) ;
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
- } ) ;
56
+ if ( keyType === 'P-256' ) {
57
+ it ( 'For P-256 keys, the default hashing function, SHA-2 with 256 bits' +
58
+ 'of output, MUST be used.' , async function ( ) {
59
+ 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.' ;
60
+ await assertions . verificationSuccess ( {
61
+ credential : securedCredential ,
62
+ verifier,
63
+ reason : `Should verify VC signed with ${ suiteName } ${ keyType } `
64
+ } ) ;
65
+ } ) ;
66
+ }
67
+ if ( keyType === 'P-384' ) {
68
+ it ( 'For P-384 keys, SHA-2 with 384-bits of output MUST be used, ' +
69
+ 'specified via the RDFC-1.0 implementation-specific parameter.' ,
70
+ async function ( ) {
71
+ 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.' ;
72
+ await assertions . verificationSuccess ( {
73
+ credential : securedCredential ,
74
+ verifier,
75
+ reason : `Should verify VC signed with ${ suiteName } ${ keyType } `
76
+ } ) ;
77
+ } ) ;
78
+ }
58
79
} ) ;
59
80
}
60
81
}
0 commit comments