function sign(transaction, privateKey, sighashType, inputIndex, sigversion, leafHash) {
  $.checkArgument(sigversion === Signature.Version.TAPROOT || sigversion === Signature.Version.TAPSCRIPT, 'Invalid sigversion');
  
  const execdata = _getExecData(sigversion, leafHash);
  const hashbuf = _signatureHash(transaction, sighashType, inputIndex, sigversion, execdata);
  if (!hashbuf) {
    return false;
  }
  const sig = Schnorr.sign(privateKey, hashbuf);
  if (sighashType !== Signature.SIGHASH_DEFAULT) {
    return Buffer.concat([sig, Buffer.from([sighashType])]); // 65 bytes
  }
  return sig; // 64 bytes
}
Create a Schnorr signature

@name Signing.sign
@param {Transaction} transaction
@param {Buffer|BN|PrivateKey} privateKey
@param {number} sighash
@param {number} inputIndex
@param {number} sigversion
@param {Buffer} leafHash
@return {Signature}