operator + method
Addition operator for two Edwards curve points.
This operator performs point addition on the Edwards curve. It checks if the points are on the same curve and not at infinity, then calculates the result of the addition operation and returns a new Edwards curve point.
Parameters:
other
: The other Edwards curve point to add to this point.
Returns:
- A new Edwards curve point representing the result of the addition.
Throws:
- ArgumentException: If the 'other' point is on a different curve or at infinity.
Implementation
@override
EDPoint operator +(AbstractPoint other) {
if (other is! EDPoint || curve != other.curve) {
throw const ArgumentException("The other point is on a different curve.");
}
if (other.isInfinity) {
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);
if (result[0] == BigInt.zero || result[3] == BigInt.zero) {
return EDPoint.infinity(curve: curve);
}
return EDPoint(
curve: curve,
x: result[0],
y: result[1],
z: result[2],
t: result[3],
order: order);
}