public override ECPoint ImportPoint(ECPoint p) { if (this != p.Curve && this.CoordinateSystem == COORD_JACOBIAN && !p.IsInfinity) { switch (p.Curve.CoordinateSystem) { case COORD_JACOBIAN: case COORD_JACOBIAN_CHUDNOVSKY: case COORD_JACOBIAN_MODIFIED: return(new FpPoint(this, FromBigInteger(p.RawXCoord.ToBigInteger()), FromBigInteger(p.RawYCoord.ToBigInteger()), new ECFieldElement[] { FromBigInteger(p.GetZCoord(0).ToBigInteger()) }, p.IsCompressed)); default: break; } } return(base.ImportPoint(p)); }
/** * Normalization ensures that any projective coordinate is 1, and therefore that the x, y * coordinates reflect those of the equivalent point in an affine coordinate system. Where more * than one point is to be normalized, this method will generally be more efficient than * normalizing each point separately. * * @param points * An array of points that will be updated in place with their normalized versions, * where necessary */ public virtual void NormalizeAll(ECPoint[] points) { CheckPoints(points); if (this.CoordinateSystem == ECCurve.COORD_AFFINE) { return; } /* * Figure out which of the points actually need to be normalized */ ECFieldElement[] zs = new ECFieldElement[points.Length]; int[] indices = new int[points.Length]; int count = 0; for (int i = 0; i < points.Length; ++i) { ECPoint p = points[i]; if (null != p && !p.IsNormalized()) { zs[count] = p.GetZCoord(0); indices[count++] = i; } } if (count == 0) { return; } ECAlgorithms.MontgomeryTrick(zs, 0, count); for (int j = 0; j < count; ++j) { int index = indices[j]; points[index] = points[index].Normalize(zs[j]); } }