internal Config(ECCurve outer, int coord, ECEndomorphism endomorphism, ECMultiplier multiplier) { this.outer = outer; this.coord = coord; this.endomorphism = endomorphism; this.multiplier = multiplier; }
public static ECPoint MapPoint(ECEndomorphism endomorphism, ECPoint p) { EndoPreCompInfo precomp = (EndoPreCompInfo)p.Curve.Precompute(p, PRECOMP_NAME, new MapPointCallback(endomorphism, p)); return(precomp.MappedPoint); }
internal static ECPoint ImplSumOfMultiplies(ECEndomorphism endomorphism, ECPoint[] ps, BigInteger[] ks) { int halfCount = ps.Length, fullCount = halfCount << 1; bool[] negs = new bool[fullCount]; WNafPreCompInfo[] infos = new WNafPreCompInfo[fullCount]; byte[][] wnafs = new byte[fullCount][]; ECPointMap pointMap = endomorphism.PointMap; for (int i = 0; i < halfCount; ++i) { int j0 = i << 1, j1 = j0 + 1; BigInteger kj0 = ks[j0]; negs[j0] = kj0.SignValue < 0; kj0 = kj0.Abs(); BigInteger kj1 = ks[j1]; negs[j1] = kj1.SignValue < 0; kj1 = kj1.Abs(); int minWidth = WNafUtilities.GetWindowSize(System.Math.Max(kj0.BitLength, kj1.BitLength), 8); ECPoint P = ps[i]; WNafPreCompInfo infoP = WNafUtilities.Precompute(P, minWidth, true); ECPoint Q = EndoUtilities.MapPoint(endomorphism, P); WNafPreCompInfo infoQ = WNafUtilities.PrecomputeWithPointMap(Q, pointMap, infoP, true); int widthP = System.Math.Min(8, infoP.Width); int widthQ = System.Math.Min(8, infoQ.Width); infos[j0] = infoP; infos[j1] = infoQ; wnafs[j0] = WNafUtilities.GenerateWindowNaf(widthP, kj0); wnafs[j1] = WNafUtilities.GenerateWindowNaf(widthQ, kj1); } return(ImplSumOfMultiplies(negs, infos, wnafs)); }
internal static ECPoint ImplShamirsTrickWNaf(ECEndomorphism endomorphism, ECPoint P, BigInteger k, BigInteger l) { bool negK = k.SignValue < 0, negL = l.SignValue < 0; k = k.Abs(); l = l.Abs(); int minWidth = WNafUtilities.GetWindowSize(System.Math.Max(k.BitLength, l.BitLength), 8); WNafPreCompInfo infoP = WNafUtilities.Precompute(P, minWidth, true); ECPoint Q = EndoUtilities.MapPoint(endomorphism, P); WNafPreCompInfo infoQ = WNafUtilities.PrecomputeWithPointMap(Q, endomorphism.PointMap, infoP, true); int widthP = System.Math.Min(8, infoP.Width); int widthQ = System.Math.Min(8, infoQ.Width); ECPoint[] preCompP = negK ? infoP.PreCompNeg : infoP.PreComp; ECPoint[] preCompQ = negL ? infoQ.PreCompNeg : infoQ.PreComp; ECPoint[] preCompNegP = negK ? infoP.PreComp : infoP.PreCompNeg; ECPoint[] preCompNegQ = negL ? infoQ.PreComp : infoQ.PreCompNeg; byte[] wnafP = WNafUtilities.GenerateWindowNaf(widthP, k); byte[] wnafQ = WNafUtilities.GenerateWindowNaf(widthQ, l); return(ImplShamirsTrickWNaf(preCompP, preCompNegP, wnafP, preCompQ, preCompNegQ, wnafQ)); }
public Config SetEndomorphism(ECEndomorphism endomorphism) { this.endomorphism = endomorphism; return(this); }
public Config SetEndomorphism(ECEndomorphism endomorphism) { this.endomorphism = endomorphism; return this; }
private bool CheckExisting(EndoPreCompInfo existingEndo, ECEndomorphism endomorphism) { return(null != existingEndo && existingEndo.Endomorphism == endomorphism && existingEndo.MappedPoint != null); }
internal MapPointCallback(ECEndomorphism endomorphism, ECPoint point) { this.m_endomorphism = endomorphism; this.m_point = point; }