pointAddScalar method

Uint8List? pointAddScalar(
  1. Uint8List p,
  2. Uint8List tweak
)

Implementation

Uint8List? pointAddScalar(Uint8List p, Uint8List tweak) {
  if (!isPoint(p)) {
    throw ArgumentError('Expected a point');
  }

  if (!isOrderScalar(tweak)) {
    throw ArgumentError('Expected a tweak');
  }

  final pp = Bip32._secp256k1.curve.decodePoint(p);

  if (_compare(tweak, _zero32) == 0) {
    return pp!.getEncoded(true);
  }

  final tt = tweak.toBigInt();
  final qq = Bip32._secp256k1.G * tt;
  final uu = pp! + qq;

  if (uu!.isInfinity) {
    return null;
  }

  return uu.getEncoded(true);
}