operator + method

  1. @override
JubJubPoint operator +(
  1. BaseRedJubJubPoint<JubJubScalar> rhs
)
override

Point addition with another JubJub point.

Implementation

@override
JubJubPoint operator +(BaseRedJubJubPoint rhs) {
  switch (rhs) {
    case final JubJubNielsPoint point:
      final a = (v - u) * point.vMinusU;
      final b = (v + u) * point.vPlusU;
      final c = t1 * t2 * point.t2d;
      final d = (z * point.z).double();
      return _JubjubCompletedPoint(
        u: b - a,
        v: b + a,
        z: d + c,
        t: d - c,
      ).toExtended();
    case final JubJubAffineNielsPoint point:
      final a = (v - u) * point.vMinusU;
      final b = (v + u) * point.vPlusU;
      final c = t1 * t2 * point.t2d;
      final d = z.double();
      return _JubjubCompletedPoint(
        u: b - a,
        v: b + a,
        z: d + c,
        t: d - c,
      ).toExtended();
    case final JubJubPoint point:
      return this + point.toNiels();
    case final JubJubAffinePoint point:
      return this + point.toNiels();
    default:
      throw CryptoException.operationNotSupported;
  }
}