Skip to content

Commit

Permalink
Changed nested if statement to compound and statement.
Browse files Browse the repository at this point in the history
  • Loading branch information
kezike authored and dlongley committed Feb 27, 2023
1 parent c55073c commit 377688a
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,17 @@ import {

// retrieves name of appropriate ECDSA curve
export function getNamedCurve({publicMultikey}) {
if(publicMultikey[0] === MULTICODEC_P256_PUBLIC_KEY_HEADER[0]) {
if(publicMultikey[1] === MULTICODEC_P256_PUBLIC_KEY_HEADER[1]) {
return ECDSA_CURVE.P256;
}
if(publicMultikey[0] === MULTICODEC_P256_PUBLIC_KEY_HEADER[0] &&
publicMultikey[1] === MULTICODEC_P256_PUBLIC_KEY_HEADER[1]) {
return ECDSA_CURVE.P256;
}
if(publicMultikey[0] === MULTICODEC_P384_PUBLIC_KEY_HEADER[0]) {
if(publicMultikey[1] === MULTICODEC_P384_PUBLIC_KEY_HEADER[1]) {
return ECDSA_CURVE.P384;
}
if(publicMultikey[0] === MULTICODEC_P384_PUBLIC_KEY_HEADER[0] &&
publicMultikey[1] === MULTICODEC_P384_PUBLIC_KEY_HEADER[1]) {
return ECDSA_CURVE.P384;
}
if(publicMultikey[0] === MULTICODEC_P521_PUBLIC_KEY_HEADER[0]) {
if(publicMultikey[1] === MULTICODEC_P521_PUBLIC_KEY_HEADER[1]) {
return ECDSA_CURVE.P521;
}
if(publicMultikey[0] === MULTICODEC_P521_PUBLIC_KEY_HEADER[0] &&
publicMultikey[1] === MULTICODEC_P521_PUBLIC_KEY_HEADER[1]) {
return ECDSA_CURVE.P521;
}
// FIXME; also support P-256K/secp256k1
throw new TypeError('Unsupported multikey header.');
Expand Down

0 comments on commit 377688a

Please sign in to comment.