public ECDomainParameters( ECCurve curve, ECPoint g, BigInteger n, BigInteger h, byte[] seed) { if (curve == null) { throw new ArgumentNullException("curve"); } if (g == null) { throw new ArgumentNullException("g"); } if (n == null) { throw new ArgumentNullException("n"); } if (h == null) { throw new ArgumentNullException("h"); } this.curve = curve; this.g = g.Normalize(); this.n = n; this.h = h; this.seed = (seed == null ? null : (byte[])seed.Clone()); }
public virtual bool Equals(ECPoint other) { if (this == other) { return(true); } if (null == other) { return(false); } ECCurve c1 = this.Curve, c2 = other.Curve; bool n1 = (null == c1), n2 = (null == c2); bool i1 = IsInfinity, i2 = other.IsInfinity; if (i1 || i2) { return((i1 && i2) && (n1 || n2 || c1.Equals(c2))); } ECPoint p1 = this, p2 = other; if (n1 && n2) { // Points with null curve are in affine form, so already normalized } else if (n1) { p2 = p2.Normalize(); } else if (n2) { p1 = p1.Normalize(); } else if (!c1.Equals(c2)) { return(false); } else { // TODO Consider just requiring already normalized, to avoid silent performance degradation ECPoint[] points = new ECPoint[] { this, c1.ImportPoint(p2) }; // TODO This is a little strong, really only requires coZNormalizeAll to get Zs equal c1.NormalizeAll(points); p1 = points[0]; p2 = points[1]; } return(p1.XCoord.Equals(p2.XCoord) && p1.YCoord.Equals(p2.YCoord)); }
public virtual ECPoint ImportPoint(ECPoint p) { if (this == p.Curve) { return(p); } if (p.IsInfinity) { return(Infinity); } // TODO Default behaviour could be improved if the two curves have the same coordinate system by copying any Z coordinates. p = p.Normalize(); return(CreatePoint(p.XCoord.ToBigInteger(), p.YCoord.ToBigInteger(), p.IsCompressed)); }