code: 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);
  }
docs: verify that message authentication codes match, then decrypt