src/coins/compress.js
function decompressKey(key) {
  const format = key[0];

  assert(key.length === 33);

  switch (format) {
    case 0x02:
    case 0x03:
      return key;
    case 0x04:
      key[0] = 0x02;
      break;
    case 0x05:
      key[0] = 0x03;
      break;
    default:
      throw new Error('Bad point format.');
  }

  // Decompress the key.
  const out = secp256k1.publicKeyConvert(key, false);

  // Reset the first byte so as not to
  // mutate the original buffer.
  key[0] = format;

  return out;
}
function decompressKey(key) {
  const format = key[0];

  assert(key.length === 33);

  switch (format) {
    case 0x02:
    case 0x03:
      return key;
    case 0x04:
      key[0] = 0x02;
      break;
    case 0x05:
      key[0] = 0x03;
      break;
    default:
      throw new Error('Bad point format.');
  }

  // Decompress the key.
  const out = secp256k1.publicKeyConvert(key, false);

  // Reset the first byte so as not to
  // mutate the original buffer.
  key[0] = format;

  return out;
}
function decompressKey ( key ) { const format = key [ 0 ] ; assert ( key . length === 33 ) ; switch ( format ) { case 0x02 : case 0x03 : return key ; case 0x04 : key [ 0 ] = 0x02 ; break ; case 0x05 : key [ 0 ] = 0x03 ; break ; default : throw new Error ( 'Bad point format.' ) ; } // Decompress the key. const out = secp256k1 . publicKeyConvert ( key , false ) ; // Reset the first byte so as not to // mutate the original buffer. key [ 0 ] = format ; return out ; }
Decompress a public key from the coins compression format.
@param {Buffer} key
@returns {Buffer}
Decompress a public key from the coins compression format .