Skip to content

Commit

Permalink
Add support for JCS Cryptosuites.
Browse files Browse the repository at this point in the history
  • Loading branch information
gannan08 committed Nov 8, 2024
1 parent 66bf2f0 commit b04e690
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# bedrock-vc-issuer ChangeLog

## 28.1.0 - 2024-11-xx

### Added
- Add support for issuing vcs with `ecdsa-jcs-2019` and `eddsa-jcs-2022`
signatures.

## 28.0.0 - 2024-09-23

### Changed
Expand Down
28 changes: 28 additions & 0 deletions lib/suites.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ import * as Bls12381Multikey from '@digitalbazaar/bls12-381-multikey';
import {
createSignCryptosuite as createBbs2023SignCryptosuite
} from '@digitalbazaar/bbs-2023-cryptosuite';
import {
createSignCryptosuite as createEcdsaJcs2019CryptoSuite
} from '@digitalbazaar/ecdsa-jcs-2019-cryptosuite';
import {
createSignCryptosuite as createEcdsaSd2023SignCryptosuite
} from '@digitalbazaar/ecdsa-sd-2023-cryptosuite';
import {
createCryptosuite as createEcdsaXi2023SignCryptosuite
} from '@digitalbazaar/ecdsa-xi-2023-cryptosuite';
import {
createSignCryptosuite as createEddsaJcs2022CryptoSuite
} from '@digitalbazaar/eddsa-jcs-2022-cryptosuite';
import {DataIntegrityProof} from '@digitalbazaar/data-integrity';
import {decode} from 'base64url-universal';
import {
Expand Down Expand Up @@ -49,6 +55,12 @@ const SUPPORTED_SUITES = new Map([
[ecdsaRdfc2019CryptoSuite.name, {
createSuite: _createEcdsaRdfc2019Suite
}],
[createEddsaJcs2022CryptoSuite().name, {
createSuite: _createEddsaJcs2022Suite
}],
[createEcdsaJcs2019CryptoSuite().name, {
createSuite: _createEcdsaJcs2019Suite
}],
[createEcdsaSd2023SignCryptosuite().name, {
createSuite: _createEcdsaSd2023Suite
}],
Expand Down Expand Up @@ -164,6 +176,22 @@ function _createEcdsaRdfc2019Suite({signer, cryptosuiteConfig} = {}) {
});
}

function _createEddsaJcs2022Suite({signer, cryptosuiteConfig}) {
return new DataIntegrityProof({
signer,
date: _getCreated({cryptosuiteConfig}),
cryptosuite: createEddsaJcs2022CryptoSuite()
});
}

function _createEcdsaJcs2019Suite({signer, cryptosuiteConfig} = {}) {
return new DataIntegrityProof({
signer,
date: _getCreated({cryptosuiteConfig}),
cryptosuite: createEcdsaJcs2019CryptoSuite()
});
}

function _createEcdsaSd2023Suite({signer, options, cryptosuiteConfig} = {}) {
// enforce `cryptosuiteConfig.options` if given
if(cryptosuiteConfig?.options?.mandatoryPointers &&
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@
"@digitalbazaar/bls12-381-multikey": "^1.3.0",
"@digitalbazaar/data-integrity": "^2.3.0",
"@digitalbazaar/ecdsa-2019-cryptosuite": "^2.0.0",
"@digitalbazaar/ecdsa-jcs-2019-cryptosuite": "^1.0.0",
"@digitalbazaar/ecdsa-rdfc-2019-cryptosuite": "^1.1.1",
"@digitalbazaar/ecdsa-sd-2023-cryptosuite": "^3.4.1",
"@digitalbazaar/ecdsa-xi-2023-cryptosuite": "^1.0.1",
"@digitalbazaar/ed25519-signature-2018": "^4.0.0",
"@digitalbazaar/ed25519-signature-2020": "^5.4.0",
"@digitalbazaar/eddsa-2022-cryptosuite": "^1.0.0",
"@digitalbazaar/eddsa-jcs-2022-cryptosuite": "^1.0.0",
"@digitalbazaar/eddsa-rdfc-2022-cryptosuite": "^1.1.0",
"@digitalbazaar/ezcap": "^4.1.0",
"@digitalbazaar/vc": "^7.0.0",
Expand Down
12 changes: 6 additions & 6 deletions schemas/bedrock-vc-issuer.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ const cryptosuite = {
type: 'string',
// supported default suites in this version
enum: [
'ecdsa-rdfc-2019', 'eddsa-rdfc-2022', 'Ed25519Signature2020',
'Ed25519Signature2018', 'ecdsa-sd-2023', 'ecdsa-xi-2023',
'bbs-2023'
'ecdsa-rdfc-2019', 'eddsa-rdfc-2022', 'ecdsa-jcs-2019',
'eddsa-jcs-2022', 'Ed25519Signature2020', 'Ed25519Signature2018',
'ecdsa-sd-2023', 'ecdsa-xi-2023', 'bbs-2023'
]
},
options: {
Expand Down Expand Up @@ -138,9 +138,9 @@ export const issueOptions = {
type: 'string',
// supported default suites in this version
enum: [
'ecdsa-rdfc-2019', 'eddsa-rdfc-2022', 'Ed25519Signature2020',
'Ed25519Signature2018', 'ecdsa-sd-2023', 'ecdsa-xi-2023',
'bbs-2023'
'ecdsa-rdfc-2019', 'eddsa-rdfc-2022', 'ecdsa-jcs-2019',
'eddsa-jcs-2022', 'Ed25519Signature2020', 'Ed25519Signature2018',
'ecdsa-sd-2023', 'ecdsa-xi-2023', 'bbs-2023'
]
}
}
Expand Down
24 changes: 24 additions & 0 deletions test/mocha/20-issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ describe('issue', () => {
},
tags: ['general']
},
'eddsa-jcs-2022': {
suiteName: 'eddsa-jcs-2022',
algorithm: 'Ed25519',
issueOptions: {},
statusOptions: {
suiteName: 'eddsa-jcs-2022',
algorithm: 'Ed25519'
},
tags: ['general']
},
'ecdsa-rdfc-2019, P-256': {
suiteName: 'ecdsa-rdfc-2019',
algorithm: 'P-256',
Expand All @@ -38,6 +48,20 @@ describe('issue', () => {
statusOptions: {},
tags: []
},
'ecdsa-jcs-2019, P-256': {
suiteName: 'ecdsa-jcs-2019',
algorithm: 'P-256',
issueOptions: {},
statusOptions: {},
tags: []
},
'ecdsa-jcs-2019, P-384': {
suiteName: 'ecdsa-jcs-2019',
algorithm: 'P-384',
issueOptions: {},
statusOptions: {},
tags: []
},
'ecdsa-sd-2023': {
suiteName: 'ecdsa-sd-2023',
algorithm: 'P-256',
Expand Down
6 changes: 6 additions & 0 deletions test/mocha/40-did-web-issuer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@ describe('issue using "did:web" issuer', () => {
}, {
name: 'eddsa-rdfc-2022',
algorithm: 'Ed25519'
}, {
name: 'eddsa-jcs-2022',
algorithm: 'Ed25519'
}, {
name: 'ecdsa-rdfc-2019',
algorithm: 'P-256'
}, {
name: 'ecdsa-jcs-2019',
algorithm: 'P-256'
}, {
name: 'ecdsa-sd-2023',
algorithm: 'P-256',
Expand Down
6 changes: 6 additions & 0 deletions test/mocha/70-misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,15 @@ describe('fail for bad credentials', () => {
}, {
name: 'eddsa-rdfc-2022',
algorithm: 'Ed25519'
}, {
name: 'eddsa-jcs-2022',
algorithm: 'Ed25519'
}, {
name: 'ecdsa-rdfc-2019',
algorithm: 'P-256'
}, {
name: 'ecdsa-jcs-2019',
algorithm: 'P-256'
}, {
name: 'ecdsa-sd-2023',
algorithm: 'P-256',
Expand Down

0 comments on commit b04e690

Please sign in to comment.