-
Notifications
You must be signed in to change notification settings - Fork 8
JCS Algorithms file #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6adc7c3
ecdsa-jcs algorithms and helpers
PatStLouis 61eee84
Apply text suggestion
PatStLouis 3d32142
Merge branch 'add-algorithm-suites' into algo-ecdsa-jcs-2019
PatStLouis 274e80b
Use test helpers not suite helpers.
aljones15 dd48a98
Switch default interop vc version to 2.0 for rdfc-2019.
aljones15 f36026e
Merge isValid utils into common helpers import.
aljones15 7b4034e
Add initial jcs 2019 config and update cryptosuite name.
aljones15 8cdd7d4
Change default supported vc type to 2.0.
aljones15 1771eba
Minor corrections to jcs suite.
aljones15 9b8bbca
Add implemented to suites.
aljones15 565007b
Replace ecdsa2022 w/ jcs2019Proofs.
aljones15 f044d3c
Move lone transformation test to main area.
aljones15 5e8c1d5
Update tests/helpers.js comment about test version support.
aljones15 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/*! | ||
* Copyright 2024 Digital Bazaar, Inc. | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
import {ecdsaJcs2019Algorithms} from './suites/algorithms-jcs.js'; | ||
|
||
ecdsaJcs2019Algorithms(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,228 @@ | ||
/*! | ||
* Copyright 2024 Digital Bazaar, Inc. | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
import { | ||
config, | ||
createInitialVc, | ||
createValidCredential, | ||
getProofs, | ||
isValidDatetime, | ||
isValidUtf8, | ||
setupReportableTestSuite, | ||
setupRow | ||
} from '../helpers.js'; | ||
import chai from 'chai'; | ||
import {endpoints} from 'vc-test-suite-implementations'; | ||
|
||
export function ecdsaJcs2019Algorithms() { | ||
const cryptosuite = 'ecdsa-jcs-2019'; | ||
const {tags} = config.suites[ | ||
cryptosuite | ||
]; | ||
const {match: issuers} = endpoints.filterByTag({ | ||
tags: [...tags], | ||
property: 'issuers' | ||
}); | ||
const should = chai.should(); | ||
|
||
describe('ecdsa-jcs-2019 - Algorithms - Transformation', function() { | ||
setupReportableTestSuite(this); | ||
this.implemented = [...issuers.keys()]; | ||
let validCredential; | ||
before(async function() { | ||
validCredential = await createValidCredential(); | ||
}); | ||
for(const [columnId, {endpoints}] of issuers) { | ||
describe(columnId, function() { | ||
const [issuer] = endpoints; | ||
let issuedVc; | ||
let proofs; | ||
let jcs2019Proofs = []; | ||
before(async function() { | ||
issuedVc = await createInitialVc({issuer, vc: validCredential}); | ||
proofs = getProofs(issuedVc); | ||
if(proofs?.length) { | ||
jcs2019Proofs = proofs.filter( | ||
proof => proof?.cryptosuite === cryptosuite); | ||
} | ||
}); | ||
beforeEach(setupRow); | ||
const assertBefore = () => { | ||
should.exist(issuedVc, 'Expected issuer to have issued a ' + | ||
'credential.'); | ||
should.exist(proofs, 'Expected credential to have a proof.'); | ||
jcs2019Proofs.length.should.be.gte(1, 'Expected at least one ' + | ||
'ecdsa-jcs-2019 cryptosuite.'); | ||
}; | ||
it('The transformation options MUST contain a type identifier ' + | ||
'for the cryptographic suite (type) and a cryptosuite identifier ' + | ||
'(cryptosuite).', | ||
async function() { | ||
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#transformation-ecdsa-jcs-2019'; | ||
assertBefore(); | ||
for(const proof of jcs2019Proofs) { | ||
should.exist(proof.type, 'Expected a type identifier on ' + | ||
'the proof.'); | ||
should.exist(proof.cryptosuite, | ||
'Expected a cryptosuite identifier on the proof.'); | ||
} | ||
}); | ||
it('Whenever this algorithm encodes strings, ' + | ||
'it MUST use UTF-8 encoding.', | ||
async function() { | ||
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#transformation-ecdsa-jcs-2019'; | ||
assertBefore(); | ||
for(const proof of jcs2019Proofs) { | ||
should.exist(proof?.proofValue, | ||
'Expected proofValue to exist.'); | ||
isValidUtf8(proof.proofValue).should.equal( | ||
true, | ||
'Expected proofValue value to be a valid UTF-8 encoded string.' | ||
); | ||
} | ||
}); | ||
it('If options.type is not set to the string DataIntegrityProof or ' + | ||
'options.cryptosuite is not set to the string ecdsa-jcs-2019, ' + | ||
'an error MUST be raised and SHOULD convey an error type ' + | ||
'of PROOF_TRANSFORMATION_ERROR.', | ||
async function() { | ||
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#transformation-ecdsa-jcs-2019'; | ||
assertBefore(); | ||
for(const proof of jcs2019Proofs) { | ||
should.exist(proof.type, | ||
'Expected a type identifier on the proof.'); | ||
should.exist(proof.cryptosuite, | ||
'Expected a cryptosuite identifier on the proof.'); | ||
proof.type.should.equal('DataIntegrityProof', | ||
'Expected DataIntegrityProof type.'); | ||
proof.cryptosuite.should.equal('ecdsa-jcs-2019', | ||
'Expected ecdsa-jcs-2019 cryptosuite.'); | ||
} | ||
}); | ||
}); | ||
} | ||
}); | ||
|
||
describe('ecdsa-jcs-2019 - Algorithms - Proof Configuration', function() { | ||
setupReportableTestSuite(this); | ||
this.implemented = [...issuers.keys()]; | ||
let validCredential; | ||
before(async function() { | ||
validCredential = await createValidCredential(); | ||
}); | ||
for(const [columnId, {endpoints}] of issuers) { | ||
describe(columnId, function() { | ||
const [issuer] = endpoints; | ||
let issuedVc; | ||
let proofs; | ||
let jcs2019Proofs = []; | ||
before(async function() { | ||
issuedVc = await createInitialVc({issuer, vc: validCredential}); | ||
proofs = getProofs(issuedVc); | ||
if(proofs?.length) { | ||
jcs2019Proofs = proofs.filter( | ||
proof => proof?.cryptosuite === cryptosuite); | ||
} | ||
}); | ||
beforeEach(setupRow); | ||
const assertBefore = () => { | ||
should.exist(issuedVc, 'Expected issuer to have issued a ' + | ||
'credential.'); | ||
should.exist(proofs, 'Expected credential to have a proof.'); | ||
jcs2019Proofs.length.should.be.gte(1, 'Expected at least one ' + | ||
'ecdsa-jcs-2019 cryptosuite.'); | ||
}; | ||
it('The proof options MUST contain a type identifier for the ' + | ||
'cryptographic suite (type) and MUST contain a cryptosuite ' + | ||
'identifier (cryptosuite).', | ||
async function() { | ||
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#proof-configuration-ecdsa-jcs-2019'; | ||
assertBefore(); | ||
for(const proof of jcs2019Proofs) { | ||
should.exist(proof.type, | ||
'Expected a type identifier on the proof.'); | ||
should.exist(proof.cryptosuite, | ||
'Expected a cryptosuite identifier on the proof.'); | ||
} | ||
}); | ||
it('If proofConfig.type is not set to DataIntegrityProof ' + | ||
'and/or proofConfig.cryptosuite is not set to ecdsa-jcs-2019, ' + | ||
'an error MUST be raised and SHOULD convey an error type ' + | ||
'of PROOF_GENERATION_ERROR.', | ||
async function() { | ||
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#proof-configuration-ecdsa-jcs-2019'; | ||
assertBefore(); | ||
for(const proof of jcs2019Proofs) { | ||
should.exist(proof.type, | ||
'Expected a type identifier on the proof.'); | ||
should.exist(proof.cryptosuite, | ||
'Expected a cryptosuite identifier on the proof.'); | ||
proof.type.should.equal('DataIntegrityProof', | ||
'Expected DataIntegrityProof type.'); | ||
proof.cryptosuite.should.equal('ecdsa-jcs-2019', | ||
'Expected ecdsa-jcs-2019 cryptosuite.'); | ||
} | ||
}); | ||
it('If proofConfig.created is set and if the value is not a ' + | ||
'valid [XMLSCHEMA11-2] datetime, an error MUST be raised and ' + | ||
'SHOULD convey an error type of PROOF_GENERATION_ERROR.', | ||
async function() { | ||
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#proof-configuration-ecdsa-jcs-2019'; | ||
for(const proof of jcs2019Proofs) { | ||
if(proof?.created) { | ||
isValidDatetime(proof.created).should.equal( | ||
true, | ||
'Expected created value to be a valid datetime string.' | ||
); | ||
} | ||
} | ||
}); | ||
}); | ||
} | ||
}); | ||
|
||
describe('ecdsa-jcs-2019 - Algorithms - Transformation', function() { | ||
setupReportableTestSuite(this); | ||
this.implemented = [...issuers.keys()]; | ||
let validCredential; | ||
before(async function() { | ||
validCredential = await createValidCredential(); | ||
}); | ||
for(const [columnId, {endpoints}] of issuers) { | ||
describe(columnId, function() { | ||
const [issuer] = endpoints; | ||
let issuedVc; | ||
let proofs; | ||
let jcs2019Proofs = []; | ||
before(async function() { | ||
issuedVc = await createInitialVc({issuer, vc: validCredential}); | ||
proofs = getProofs(issuedVc); | ||
if(proofs?.length) { | ||
jcs2019Proofs = proofs.filter( | ||
proof => proof?.cryptosuite === cryptosuite); | ||
} | ||
}); | ||
beforeEach(setupRow); | ||
const assertBefore = () => { | ||
should.exist(issuedVc, 'Expected issuer to have issued a ' + | ||
'credential.'); | ||
should.exist(proofs, 'Expected credential to have a proof.'); | ||
jcs2019Proofs.length.should.be.gte(1, 'Expected at least one ' + | ||
'ecdsa-jcs-2019 cryptosuite.'); | ||
}; | ||
it('The proof options MUST contain a type identifier for the ' + | ||
'cryptographic suite (type) and MAY contain a cryptosuite ' + | ||
'identifier (cryptosuite).', | ||
async function() { | ||
this.test.link = 'https://www.w3.org/TR/vc-di-ecdsa/#proof-serialization-ecdsa-jcs-2019'; | ||
assertBefore(); | ||
for(const proof of jcs2019Proofs) { | ||
should.exist(proof.type, | ||
'Expected a type identifier on the proof.'); | ||
} | ||
}); | ||
}); | ||
} | ||
}); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.