diff --git a/lib/index.js b/lib/index.js index 0910c46..42d6885 100644 --- a/lib/index.js +++ b/lib/index.js @@ -41,13 +41,13 @@ export async function generate({id, controller, seed} = {}) { export async function from(key) { let multikey = {...key}; if(multikey.type && multikey.type !== 'Multikey') { + // attempt loading from JWK if `publicKeyJwk` is present + if(multikey.publicKeyJwk) { + return fromJwk({jwk: multikey.publicKeyJwk, secretKey: true}); + } multikey = await toMultikey({keyPair: multikey}); return _createKeyPairInterface({keyPair: multikey}); } - // attempt loading from JWK if `publicKeyJwk` is present - if(multikey.publicKeyJwk) { - return fromJwk({jwk: multikey.publicKeyJwk, secretKey: true}); - } if(!multikey.type) { multikey.type = 'Multikey'; }