simplify ec.publicKeyConvert.
This commit is contained in:
parent
4bf31f32bf
commit
08692957c7
@ -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));
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user