sec: use a hashtable for lookup
This commit is contained in:
parent
087ca551f5
commit
da48c988f6
1 changed files with 11 additions and 11 deletions
22
src/sec.js
22
src/sec.js
|
@ -193,17 +193,17 @@ function secp256r1() {
|
||||||
return new X9ECParameters(curve, G, n, h);
|
return new X9ECParameters(curve, G, n, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make this into a proper hashtable
|
|
||||||
function getSECCurveByName(name) {
|
function getSECCurveByName(name) {
|
||||||
if(name == "secp128r1") return secp128r1();
|
return ({
|
||||||
if(name == "secp160k1") return secp160k1();
|
"secp128r1": secp128r1,
|
||||||
if(name == "secp160r1") return secp160r1();
|
"secp160k1": secp160k1,
|
||||||
if(name == "secp192k1") return secp192k1();
|
"secp160r1": secp160r1,
|
||||||
if(name == "secp192r1") return secp192r1();
|
"secp192k1": secp192k1,
|
||||||
if(name == "secp224r1") return secp224r1();
|
"secp192r1": secp192r1,
|
||||||
if(name == "secp256k1") return secp256k1();
|
"secp224r1": secp224r1,
|
||||||
if(name == "secp256r1") return secp256r1();
|
"secp256k1": secp256k1,
|
||||||
return null;
|
"secp256r1": secp256r1
|
||||||
|
}[name])()
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = getSECCurveByName;
|
module.exports = getSECCurveByName
|
||||||
|
|
Loading…
Reference in a new issue