operator + method

  1. @override
EDPoint operator +(
  1. BaseExtendedPointNative other
)
override

Addition operator for two Edwards curve points.

Implementation

@override
EDPoint operator +(BaseExtendedPointNative other) {
  if (curve != other.curve) {
    throw ArgumentException.invalidOperationArguments(
      "Addition",
      reason: "The other point is on a different curve.",
    );
  }
  if (other is! EDPoint) {
    throw ArgumentException.invalidOperationArguments(
      "Addition",
      reason: "The other point has different type.",
    );
  }
  if (other.isZero()) {
    return this;
  }
  final BigInt p = curve.p;
  final BigInt a = curve.a;

  final BigInt x1 = _coords[0];
  final BigInt y1 = _coords[1];
  final BigInt z1 = _coords[2];
  final BigInt t1 = _coords[3];

  final BigInt x2 = other._coords[0];
  final BigInt y2 = other._coords[1];
  final BigInt z2 = other._coords[2];
  final BigInt t2 = other._coords[3];

  final List<BigInt> result = _add(x1, y1, z1, t1, x2, y2, z2, t2, p, a);

  return EDPoint(
    curve: curve,
    x: result[0],
    y: result[1],
    z: result[2],
    t: result[3],
    order: order,
  );
}