tweakKey static method
Tweaks a public key for Taproot (BIP-341).
This function performs a Taproot key tweak operation, modifying the given
x-only public key coordinate using a tweak value derived from tapTweakHash
.
xBig
: The x-coordinate of the public key as aBigInt
.tapTweakHash
: A 32-byte tweak hash used to modify the key.
Implementation
static ProjectiveECCPoint tweakKey(
{required BigInt xBig, required List<int> tapTweakHash}) {
if (tapTweakHash.length != 32) {
throw const CryptoSignException(
"The tap tweak hash must be 32-byte array.");
}
final n =
BitcoinSignerUtils.generator * BigintUtils.fromBytes(tapTweakHash);
final outPoint = P2TRUtils.liftX(xBig) + n;
return outPoint as ProjectiveECCPoint;
}