lib/gallactickeys.js
function verifyAndDecrypt(derivedKey, iv, ciphertext, algo, mac) {
  if (typeof algo !== 'string') {
    throw new Error('Cipher method is invalid. Unable to proceed')
  }
  var key;
  if (crypto.createMac(derivedKey, ciphertext) !== mac) {
    throw new Error('message authentication code mismatch');
  }

  key = derivedKey.slice(0, 16);

  return crypto.bs58Encode(util.bytesToHexUpperString(crypto.decrypt(ciphertext, key, iv, algo)), 3);
}
function verifyAndDecrypt(derivedKey, iv, ciphertext, algo, mac) {
  if (typeof algo !== 'string') {
    throw new Error('Cipher method is invalid. Unable to proceed')
  }
  var key;
  if (crypto.createMac(derivedKey, ciphertext) !== mac) {
    throw new Error('message authentication code mismatch');
  }

  key = derivedKey.slice(0, 16);

  return crypto.bs58Encode(util.bytesToHexUpperString(crypto.decrypt(ciphertext, key, iv, algo)), 3);
}
function verifyAndDecrypt ( derivedKey , iv , ciphertext , algo , mac ) { if ( typeof algo !== 'string' ) { throw new Error ( 'Cipher method is invalid. Unable to proceed' ) } var key ; if ( crypto . createMac ( derivedKey , ciphertext ) !== mac ) { throw new Error ( 'message authentication code mismatch' ) ; } key = derivedKey . slice ( 0 , 16 ) ; return crypto . bs58Encode ( util . bytesToHexUpperString ( crypto . decrypt ( ciphertext , key , iv , algo ) ) , 3 ) ; }
verify that message authentication codes match, then decrypt
verify that message authentication codes match then decrypt