Skip to content

Commit

Permalink
Replace the keyType with algorithm.
Browse files Browse the repository at this point in the history
  • Loading branch information
JSAssassin committed Nov 3, 2023
1 parent 9b8927d commit 7d02961
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions test/mocha/20-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe('verify APIs', () => {
const {type, cryptosuite} = mockCredential.proof;
if(cryptosuite) {
if(cryptosuite === 'ecdsa-2019') {
const keyType = helpers.getEcdsaKeyTypes({
const keyType = helpers.getEcdsaAlgorithms({
credential: mockCredential
})[0];
description = `${type} - ${cryptosuite}, keytype: ${keyType}`;
Expand Down Expand Up @@ -397,7 +397,7 @@ describe('verify APIs', () => {
const {type, cryptosuite} = mockCredential.proof;
if(cryptosuite) {
if(cryptosuite === 'ecdsa-2019') {
const keyType = helpers.getEcdsaKeyTypes({
const keyType = helpers.getEcdsaAlgorithms({
credential: mockCredential
})[0];
description = `${type} - ${cryptosuite}, keytype: ${keyType}`;
Expand Down
16 changes: 8 additions & 8 deletions test/mocha/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {mockData} from './mock.data.js';
const edvBaseUrl = `${mockData.baseUrl}/edvs`;
const kmsBaseUrl = `${mockData.baseUrl}/kms`;

const SUPPORTED_ECDSA_KEY_TYPES = new Map([
const SUPPORTED_ECDSA_ALGORITHMS = new Map([
['zDna', 'P-256'],
['z82L', 'P-384']
]);
Expand Down Expand Up @@ -284,10 +284,10 @@ async function keyResolver({id}) {
return data;
}

export function getEcdsaKeyTypes({credential, presentation} = {}) {
export function getEcdsaAlgorithms({credential, presentation} = {}) {
let vc = presentation ? presentation.verifiableCredential : credential;
vc = Array.isArray(vc) ? vc : [vc];
const ecdsaKeyTypes = [];
const ecdsaAlgorithms = [];
vc.forEach(credential => {
const proofs = Array.isArray(credential.proof) ? credential.proof :
[credential.proof];
Expand All @@ -296,13 +296,13 @@ export function getEcdsaKeyTypes({credential, presentation} = {}) {
const {verificationMethod} = proof;
const multibaseMultikeyHeader =
verificationMethod.substring('did:key:'.length).slice(0, 4);
const ecdsaKeyType =
SUPPORTED_ECDSA_KEY_TYPES.get(multibaseMultikeyHeader);
if(!ecdsaKeyTypes.includes(ecdsaKeyType)) {
ecdsaKeyTypes.push(ecdsaKeyType);
const ecdsaAlgorithm =
SUPPORTED_ECDSA_ALGORITHMS.get(multibaseMultikeyHeader);
if(!ecdsaAlgorithms.includes(ecdsaAlgorithm)) {
ecdsaAlgorithms.push(ecdsaAlgorithm);
}
}
}
});
return ecdsaKeyTypes;
return ecdsaAlgorithms;
}

0 comments on commit 7d02961

Please sign in to comment.