operator == method
Equality operator for comparing two Edwards curve points.
This method checks if the current Edwards curve point is equal to another point by comparing their coordinates.
Parameters:
other
: The object to compare with.
Returns:
true
if the points are equal,false
otherwise.
Implementation
@override
bool operator ==(Object other) {
if (other is EDPoint) {
/// Create new coordinate lists to avoid modifying the original coordinates.
final List<BigInt> otherCoords = other.getCoords();
/// Extract coordinates of the current point.
final BigInt x1 = _coords[0];
final BigInt y1 = _coords[1];
final BigInt z1 = _coords[2];
final BigInt t1 = _coords[3];
/// Extract coordinates of the other point.
final BigInt x2 = otherCoords[0];
final BigInt y2 = otherCoords[1];
final BigInt z2 = otherCoords[2];
/// If the other point is infinity, check specific conditions.
if (other.isInfinity) {
return x1 == BigInt.zero || t1 == BigInt.zero;
}
/// Check if the curve of the two points is the same.
if (curve != other.curve) {
return false;
}
/// Retrieve the prime value (p) of the curve.
final BigInt p = curve.p;
/// Calculate the normalized coordinates of both points.
final BigInt xn1 = (x1 * z2) % p;
final BigInt xn2 = (x2 * z1) % p;
final BigInt yn1 = (y1 * z2) % p;
final BigInt yn2 = (y2 * z1) % p;
/// Check if the normalized coordinates are equal.
return xn1 == xn2 && yn1 == yn2;
}
return false;
}