simplify ec.publicKeyConvert.

This commit is contained in:
Christopher Jeffrey 2016-07-01 19:41:33 -07:00
parent 4bf31f32bf
commit 08692957c7
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -129,24 +129,9 @@ ec.publicKeyConvert = function publicKeyConvert(key, compressed) {
if (secp256k1)
return secp256k1.publicKeyConvert(key, compressed);
switch (key[0]) {
case 0x02:
case 0x03:
if (compressed)
return key;
point = ec.decodePoint(key);
return new Buffer(point.encode('array', false));
case 0x04:
case 0x06:
case 0x07:
if (compressed) {
point = ec.decodePoint(key);
return new Buffer(point.encode('array', true));
}
return key;
default:
throw new Error('Bad point format.');
}
point = ec.decodePoint(key);
return new Buffer(point.encode('array', compressed));
};
/**