signTapRoot method
sign taproot transaction digest and returns the signature.
Implementation
String signTapRoot(Uint8List txDigest,
{sighash = TAPROOT_SIGHASH_ALL,
List<dynamic> scripts = const [],
bool tweak = true}) {
Uint8List byteKey = Uint8List(0);
if (tweak) {
final ECPublic publicKey = ECPublic.fromHex(_publicHex);
final t = publicKey.calculateTweek(script: scripts);
byteKey = ec.tweekTapprotPrivate(hexToBytes(_priveHex), t);
} else {
byteKey = hexToBytes(_priveHex);
}
final randAux = singleHash(Uint8List.fromList([...txDigest, ...byteKey]));
Uint8List signatur = ec.schnorrSign(txDigest, byteKey, randAux);
if (sighash != TAPROOT_SIGHASH_ALL) {
signatur = Uint8List.fromList([...signatur, sighash]);
}
return bytesToHex(signatur);
}