function tweakInternalPubKey(inputIndex, input) {
  const tapInternalKey = input.tapInternalKey;
  const outputKey =
    tapInternalKey && tweakKey(tapInternalKey, input.tapMerkleRoot);
  if (!outputKey)
    throw new Error(
      `Cannot tweak tap internal key for input #${inputIndex}. Public key: ${
        // tapInternalKey && tapInternalKey.toString('hex')
        tapInternalKey && tools.toHex(tapInternalKey)
      }`,
    );
  return outputKey.x;
}
Tweak the internal public key for a specific input.
@param inputIndex - The index of the input.
@param input - The PsbtInput object representing the input.
@returns The tweaked internal public key.
@throws Error if the tap internal key cannot be tweaked.