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 secp256k1 = ECCSecp256k1();
  final pp = secp256k1.curve.decodePoint(p);

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

  const bigIntEndian = BigIntBigEndian();
  final tt = bigIntEndian.decode(tweak);
  final qq = secp256k1.G * tt;
  final uu = pp! + qq;

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

  return uu.getEncoded(true);
}