Skip to content

Commit 7bb2c58

Browse files
committed
improve proof selection when asserting issued credentials
Signed-off-by: PatStLouis <[email protected]>
1 parent 1db0e43 commit 7bb2c58

File tree

3 files changed

+43
-175
lines changed

3 files changed

+43
-175
lines changed

tests/90-algorithms-jcs.js

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
*/
55
import {
66
assertAllUtf8,
7-
assertDataIntegrityProof,
8-
assertSecuredCredential
7+
assertDataIntegrityProof
98
} from './assertions.js';
109
import {
1110
generateCredential,
12-
getProofs,
1311
isValidDatetime,
1412
proofExists,
1513
secureCredential,
@@ -47,18 +45,15 @@ describe('Algorithms - Create Proof (ecdsa-jcs-2019)', function() {
4745
describe(columnId, function() {
4846
const [issuer] = endpoints;
4947
let securedCredential;
50-
let proofs;
5148
before(async function() {
5249
securedCredential = await secureCredential(
5350
{issuer, vc: generateCredential()});
54-
proofs = getProofs(securedCredential);
5551
});
5652
beforeEach(setupRow);
5753
it('A data integrity proof (map), or an error, is produced as output.',
5854
async function() {
5955
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#create-proof-ecdsa-jcs-2019';
60-
assertSecuredCredential(securedCredential);
61-
const proof = proofExists(proofs);
56+
const proof = proofExists(securedCredential);
6257
assertDataIntegrityProof(proof, 'ecdsa-jcs-2019');
6358
// Since we are not sending proof options, we only do a positive test
6459
});
@@ -69,7 +64,7 @@ describe('Algorithms - Create Proof (ecdsa-jcs-2019)', function() {
6964
// NOTE, for backwards compatibility reason, this step is not mandatory
7065
// This feature is designed to be used with proof sets/chains,
7166
// when adding new context in subsequent proofs
72-
const proof = proofExists(proofs);
67+
const proof = proofExists(securedCredential);
7368
should.exist(proof['@context'],
7469
'Expected proof to have context.');
7570
canonicalize(proof['@context']).should.equal(
@@ -83,7 +78,7 @@ describe('Algorithms - Create Proof (ecdsa-jcs-2019)', function() {
8378
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#create-proof-ecdsa-jcs-2019';
8479
// Shallow multibase test
8580
// TODO try decoding
86-
const proof = proofExists(proofs);
81+
const proof = proofExists(securedCredential);
8782
should.exist(proof.proofValue,
8883
'Expected proof to have proofValue.');
8984
expect(proof.proofValue.startsWith('z')).to.be.true;
@@ -121,35 +116,24 @@ describe('Algorithms - Verify Proof (ecdsa-jcs-2019)', function() {
121116
}
122117
});
123118

124-
describe('Algorithms - Transformation', function() {
119+
describe('Algorithms - Transformation (ecdsa-jcs-2019)', function() {
125120
setupReportableTestSuite(this);
126121
this.implemented = [...issuers.keys()];
127122
for(const [columnId, {endpoints}] of issuers) {
128123
describe(columnId, function() {
129124
const [issuer] = endpoints;
130125
let securedCredential;
131-
let proofs;
132126
before(async function() {
133127
securedCredential = await secureCredential(
134128
{issuer, vc: generateCredential()});
135-
proofs = getProofs(securedCredential);
136129
});
137130
beforeEach(setupRow);
138-
it('The proof options MUST contain a type identifier for the ' +
139-
'cryptographic suite (type) and MAY contain a cryptosuite ' +
140-
'identifier (cryptosuite).',
141-
async function() {
142-
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#proof-serialization-ecdsa-jcs-2019';
143-
const proof = proofExists(proofs);
144-
should.exist(proof.type,
145-
'Expected a type identifier on the proof.');
146-
});
147131
it('The transformation options MUST contain a type identifier ' +
148132
'for the cryptographic suite (type) and a cryptosuite identifier ' +
149133
'(cryptosuite).',
150134
async function() {
151135
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#transformation-ecdsa-jcs-2019';
152-
const proof = proofExists(proofs);
136+
const proof = proofExists(securedCredential);
153137
should.exist(proof.type,
154138
'Expected a type identifier on the proof.');
155139
should.exist(proof.cryptosuite,
@@ -159,7 +143,7 @@ describe('Algorithms - Transformation', function() {
159143
'it MUST use UTF-8 encoding.',
160144
async function() {
161145
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#transformation-ecdsa-jcs-2019';
162-
const proof = proofExists(proofs);
146+
const proof = proofExists(securedCredential);
163147
assertAllUtf8(proof);
164148
});
165149
it('If options.type is not set to the string DataIntegrityProof or ' +
@@ -168,7 +152,7 @@ describe('Algorithms - Transformation', function() {
168152
'of PROOF_TRANSFORMATION_ERROR.',
169153
async function() {
170154
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#transformation-ecdsa-jcs-2019';
171-
const proof = proofExists(proofs);
155+
const proof = proofExists(securedCredential);
172156
should.exist(proof.type,
173157
'Expected a type identifier on the proof.');
174158
should.exist(proof.cryptosuite,
@@ -182,26 +166,24 @@ describe('Algorithms - Transformation', function() {
182166
}
183167
});
184168

185-
describe('ecdsa-jcs-2019 - Algorithms - Proof Configuration', function() {
169+
describe('Algorithms - Proof Configuration (ecdsa-jcs-2019)', function() {
186170
setupReportableTestSuite(this);
187171
this.implemented = [...issuers.keys()];
188172
for(const [columnId, {endpoints}] of issuers) {
189173
describe(columnId, function() {
190174
const [issuer] = endpoints;
191175
let securedCredential;
192-
let proofs;
193176
before(async function() {
194177
securedCredential = await secureCredential(
195178
{issuer, vc: generateCredential()});
196-
proofs = getProofs(securedCredential);
197179
});
198180
beforeEach(setupRow);
199181
it('The proof options MUST contain a type identifier for the ' +
200-
'cryptographic suite (type) and MUST contain a cryptosuite ' +
201-
'identifier (cryptosuite).',
182+
'cryptographic suite (type) and MUST contain a cryptosuite ' +
183+
'identifier (cryptosuite).',
202184
async function() {
203185
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#proof-configuration-ecdsa-jcs-2019';
204-
const proof = proofExists(proofs);
186+
const proof = proofExists(securedCredential);
205187
should.exist(proof.type,
206188
'Expected a type identifier on the proof.');
207189
should.exist(proof.cryptosuite,
@@ -213,7 +195,7 @@ describe('ecdsa-jcs-2019 - Algorithms - Proof Configuration', function() {
213195
'of PROOF_GENERATION_ERROR.',
214196
async function() {
215197
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#proof-configuration-ecdsa-jcs-2019';
216-
const proof = proofExists(proofs);
198+
const proof = proofExists(securedCredential);
217199
should.exist(proof.type,
218200
'Expected a type identifier on the proof.');
219201
should.exist(proof.cryptosuite,
@@ -228,7 +210,7 @@ describe('ecdsa-jcs-2019 - Algorithms - Proof Configuration', function() {
228210
'SHOULD convey an error type of PROOF_GENERATION_ERROR.',
229211
async function() {
230212
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#proof-configuration-ecdsa-jcs-2019';
231-
const proof = proofExists(proofs);
213+
const proof = proofExists(securedCredential);
232214
if(proof?.created) {
233215
isValidDatetime(proof.created).should.equal(
234216
true,
@@ -240,26 +222,24 @@ describe('ecdsa-jcs-2019 - Algorithms - Proof Configuration', function() {
240222
}
241223
});
242224

243-
describe('ecdsa-jcs-2019 - Algorithms - Proof Serialization', function() {
225+
describe('Algorithms - Proof Serialization (ecdsa-jcs-2019)', function() {
244226
setupReportableTestSuite(this);
245227
this.implemented = [...issuers.keys()];
246228
for(const [columnId, {endpoints}] of issuers) {
247229
describe(columnId, function() {
248230
const [issuer] = endpoints;
249231
let securedCredential;
250-
let proofs;
251232
before(async function() {
252233
securedCredential = await secureCredential(
253234
{issuer, vc: generateCredential()});
254-
proofs = getProofs(securedCredential);
255235
});
256236
beforeEach(setupRow);
257237
it('The proof options MUST contain a type identifier for the ' +
258238
'cryptographic suite (type) and MAY contain a cryptosuite identifier ' +
259239
'(cryptosuite).',
260240
async function() {
261241
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#proof-serialization-ecdsa-jcs-2019';
262-
const proof = proofExists(proofs);
242+
const proof = proofExists(securedCredential);
263243
should.exist(proof.type,
264244
'Expected a type identifier on the proof.');
265245
});

0 commit comments

Comments
 (0)