diff options
Diffstat (limited to 'crypto/src/math/ec/ECPoint.cs')
-rw-r--r-- | crypto/src/math/ec/ECPoint.cs | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/crypto/src/math/ec/ECPoint.cs b/crypto/src/math/ec/ECPoint.cs index 6a06be4d1..e4ce58d2d 100644 --- a/crypto/src/math/ec/ECPoint.cs +++ b/crypto/src/math/ec/ECPoint.cs @@ -59,29 +59,36 @@ namespace Org.BouncyCastle.Math.EC get { return withCompression; } } - public override bool Equals( - object obj) + public override bool Equals(object obj) { - if (obj == this) - return true; - - ECPoint o = obj as ECPoint; + return Equals(obj as ECPoint); + } - if (o == null) + public virtual bool Equals(ECPoint other) + { + if (this == other) + return true; + if (null == other) return false; - if (this.IsInfinity) - return o.IsInfinity; + bool i1 = IsInfinity, i2 = other.IsInfinity; + if (i1 || i2) + { + return i1 && i2; + } - return x.Equals(o.x) && y.Equals(o.y); + return X.Equals(other.X) && Y.Equals(other.Y); } public override int GetHashCode() { - if (this.IsInfinity) - return 0; - - return x.GetHashCode() ^ y.GetHashCode(); + int hc = 0; + if (!IsInfinity) + { + hc ^= X.GetHashCode() * 17; + hc ^= Y.GetHashCode() * 257; + } + return hc; } // /** |