public static GetWNafPreCompInfo ( ECPoint p ) : |
||
p | ECPoint | |
리턴 |
public static ECPoint MapPointWithPrecomp(ECPoint p, int width, bool includeNegated, ECPointMap pointMap) { ECCurve curve = p.Curve; WNafPreCompInfo wNafPreCompInfo = WNafUtilities.Precompute(p, width, includeNegated); ECPoint eCPoint = pointMap.Map(p); WNafPreCompInfo wNafPreCompInfo2 = WNafUtilities.GetWNafPreCompInfo(curve.GetPreCompInfo(eCPoint, WNafUtilities.PRECOMP_NAME)); ECPoint twice = wNafPreCompInfo.Twice; if (twice != null) { ECPoint twice2 = pointMap.Map(twice); wNafPreCompInfo2.Twice = twice2; } ECPoint[] preComp = wNafPreCompInfo.PreComp; ECPoint[] array = new ECPoint[preComp.Length]; for (int i = 0; i < preComp.Length; i++) { array[i] = pointMap.Map(preComp[i]); } wNafPreCompInfo2.PreComp = array; if (includeNegated) { ECPoint[] array2 = new ECPoint[array.Length]; for (int j = 0; j < array2.Length; j++) { array2[j] = array[j].Negate(); } wNafPreCompInfo2.PreCompNeg = array2; } curve.SetPreCompInfo(eCPoint, WNafUtilities.PRECOMP_NAME, wNafPreCompInfo2); return(eCPoint); }
public static WNafPreCompInfo Precompute(ECPoint p, int width, bool includeNegated) { ECCurve curve = p.Curve; WNafPreCompInfo wNafPreCompInfo = WNafUtilities.GetWNafPreCompInfo(curve.GetPreCompInfo(p, WNafUtilities.PRECOMP_NAME)); int num = 0; int num2 = 1 << Math.Max(0, width - 2); ECPoint[] array = wNafPreCompInfo.PreComp; if (array == null) { array = WNafUtilities.EMPTY_POINTS; } else { num = array.Length; } if (num < num2) { array = WNafUtilities.ResizeTable(array, num2); if (num2 == 1) { array[0] = p.Normalize(); } else { int i = num; if (i == 0) { array[0] = p; i = 1; } ECFieldElement eCFieldElement = null; if (num2 == 2) { array[1] = p.ThreeTimes(); } else { ECPoint eCPoint = wNafPreCompInfo.Twice; ECPoint eCPoint2 = array[i - 1]; if (eCPoint == null) { eCPoint = array[0].Twice(); wNafPreCompInfo.Twice = eCPoint; if (ECAlgorithms.IsFpCurve(curve) && curve.FieldSize >= 64) { switch (curve.CoordinateSystem) { case 2: case 3: case 4: { eCFieldElement = eCPoint.GetZCoord(0); eCPoint = curve.CreatePoint(eCPoint.XCoord.ToBigInteger(), eCPoint.YCoord.ToBigInteger()); ECFieldElement eCFieldElement2 = eCFieldElement.Square(); ECFieldElement scale = eCFieldElement2.Multiply(eCFieldElement); eCPoint2 = eCPoint2.ScaleX(eCFieldElement2).ScaleY(scale); if (num == 0) { array[0] = eCPoint2; } break; } } } } while (i < num2) { eCPoint2 = (array[i++] = eCPoint2.Add(eCPoint)); } } curve.NormalizeAll(array, num, num2 - num, eCFieldElement); } } wNafPreCompInfo.PreComp = array; if (includeNegated) { ECPoint[] array2 = wNafPreCompInfo.PreCompNeg; int j; if (array2 == null) { j = 0; array2 = new ECPoint[num2]; } else { j = array2.Length; if (j < num2) { array2 = WNafUtilities.ResizeTable(array2, num2); } } while (j < num2) { array2[j] = array[j].Negate(); j++; } wNafPreCompInfo.PreCompNeg = array2; } curve.SetPreCompInfo(p, WNafUtilities.PRECOMP_NAME, wNafPreCompInfo); return(wNafPreCompInfo); }
public static WNafPreCompInfo GetWNafPreCompInfo(ECPoint p) { return(WNafUtilities.GetWNafPreCompInfo(p.Curve.GetPreCompInfo(p, WNafUtilities.PRECOMP_NAME))); }