tweakKey static method

ProjectiveECCPoint tweakKey({
  1. required BigInt xBig,
  2. required List<int> tapTweakHash,
})

Tweaks a public key for Taproot (BIP-341).

  • xBig: The x-coordinate of the public key as a BigInt.
  • 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 ArgumentException.invalidOperationArguments(
      "tweakKey",
      name: "signature",
      reason: "Invalid Tap-tweak hash bytes length.",
    );
  }
  final n =
      BitcoinSignerUtils.generator * BigintUtils.fromBytes(tapTweakHash);
  final outPoint = P2TRUtils.liftX(xBig) + n;
  return outPoint as ProjectiveECCPoint;
}