public static ECPoint SumOfTwoMultiplies(ECPoint P, BigInteger a, ECPoint Q, BigInteger b) { ECCurve cp = P.Curve; Q = ImportPoint(cp, Q); // Point multiplication for Koblitz curves (using WTNAF) beats Shamir's trick { AbstractF2mCurve f2mCurve = cp as AbstractF2mCurve; if (f2mCurve != null && f2mCurve.IsKoblitz) { return(ImplCheckResult(P.Multiply(a).Add(Q.Multiply(b)))); } } GlvEndomorphism glvEndomorphism = cp.GetEndomorphism() as GlvEndomorphism; if (glvEndomorphism != null) { return(ImplCheckResult( ImplSumOfMultipliesGlv(new ECPoint[] { P, Q }, new BigInteger[] { a, b }, glvEndomorphism))); } return(ImplCheckResult(ImplShamirsTrickWNaf(P, a, Q, b))); }
public static ECPoint SumOfMultiplies(ECPoint[] ps, BigInteger[] ks) { if (((ps == null) || (ks == null)) || ((ps.Length != ks.Length) || (ps.Length < 1))) { throw new ArgumentException("point and scalar arrays should be non-null, and of equal, non-zero, length"); } int length = ps.Length; switch (length) { case 1: return(ps[0].Multiply(ks[0])); case 2: return(SumOfTwoMultiplies(ps[0], ks[0], ps[1], ks[1])); } ECPoint point = ps[0]; ECCurve c = point.Curve; ECPoint[] pointArray = new ECPoint[length]; pointArray[0] = point; for (int i = 1; i < length; i++) { pointArray[i] = ImportPoint(c, ps[i]); } GlvEndomorphism glvEndomorphism = c.GetEndomorphism() as GlvEndomorphism; if (glvEndomorphism != null) { return(ValidatePoint(ImplSumOfMultipliesGlv(pointArray, ks, glvEndomorphism))); } return(ValidatePoint(ImplSumOfMultiplies(pointArray, ks))); }
public static ECPoint SumOfTwoMultiplies(ECPoint P, BigInteger a, ECPoint Q, BigInteger b) { ECCurve curve = P.Curve; Q = ImportPoint(curve, Q); AbstractF2mCurve abstractF2mCurve = curve as AbstractF2mCurve; if (abstractF2mCurve != null && abstractF2mCurve.IsKoblitz) { return(ValidatePoint(P.Multiply(a).Add(Q.Multiply(b)))); } GlvEndomorphism glvEndomorphism = curve.GetEndomorphism() as GlvEndomorphism; if (glvEndomorphism != null) { return(ValidatePoint(ImplSumOfMultipliesGlv(new ECPoint[2] { P, Q }, new BigInteger[2] { a, b }, glvEndomorphism))); } return(ValidatePoint(ImplShamirsTrickWNaf(P, a, Q, b))); }
internal static ECPoint ImplSumOfMultipliesGlv(ECPoint[] ps, BigInteger[] ks, GlvEndomorphism glvEndomorphism) { BigInteger order = ps[0].Curve.Order; int num = ps.Length; BigInteger[] array = new BigInteger[num << 1]; int i = 0; int num2 = 0; for (; i < num; i++) { BigInteger[] array2 = glvEndomorphism.DecomposeScalar(ks[i].Mod(order)); array[num2++] = array2[0]; array[num2++] = array2[1]; } ECPointMap pointMap = glvEndomorphism.PointMap; if (glvEndomorphism.HasEfficientPointMap) { return(ImplSumOfMultiplies(ps, pointMap, array)); } ECPoint[] array3 = new ECPoint[num << 1]; int j = 0; int num5 = 0; for (; j < num; j++) { ECPoint eCPoint = ps[j]; ECPoint eCPoint2 = pointMap.Map(eCPoint); array3[num5++] = eCPoint; array3[num5++] = eCPoint2; } return(ImplSumOfMultiplies(array3, array)); }
public static ECPoint SumOfMultiplies(ECPoint[] ps, BigInteger[] ks) { if (ps == null || ks == null || ps.Length != ks.Length || ps.Length < 1) { throw new ArgumentException("point and scalar arrays should be non-null, and of equal, non-zero, length"); } int num = ps.Length; switch (num) { case 1: return(ps[0].Multiply(ks[0])); case 2: return(SumOfTwoMultiplies(ps[0], ks[0], ps[1], ks[1])); default: { ECPoint eCPoint = ps[0]; ECCurve curve = eCPoint.Curve; ECPoint[] array = new ECPoint[num]; array[0] = eCPoint; for (int i = 1; i < num; i++) { array[i] = ImportPoint(curve, ps[i]); } GlvEndomorphism glvEndomorphism = curve.GetEndomorphism() as GlvEndomorphism; if (glvEndomorphism != null) { return(ValidatePoint(ImplSumOfMultipliesGlv(array, ks, glvEndomorphism))); } return(ValidatePoint(ImplSumOfMultiplies(array, ks))); } } }
public static ECPoint ImplSumOfMultipliesGlv(ECPoint[] ps, BigInteger[] ks, GlvEndomorphism glvEndomorphism) { BigInteger n = ps[0].Curve.Order; int len = ps.Length; BigInteger[] abs = new BigInteger[len << 1]; for (int i = 0, j = 0; i < len; ++i) { BigInteger[] ab = glvEndomorphism.DecomposeScalar(ks[i].Mod(n)); abs[j++] = ab[0]; abs[j++] = ab[1]; } ECPointMap pointMap = glvEndomorphism.PointMap; if (glvEndomorphism.HasEfficientPointMap) { return(ECAlgorithms.ImplSumOfMultiplies(ps, pointMap, abs)); } ECPoint[] pqs = new ECPoint[len << 1]; for (int i = 0, j = 0; i < len; ++i) { ECPoint p = ps[i], q = pointMap.Map(p); pqs[j++] = p; pqs[j++] = q; } return(ECAlgorithms.ImplSumOfMultiplies(pqs, abs)); }
public static ECPoint SumOfTwoMultiplies(ECPoint P, BigInteger a, ECPoint Q, BigInteger b) { ECCurve curve = P.Curve; Q = ECAlgorithms.ImportPoint(curve, Q); if (curve is F2mCurve) { F2mCurve f2mCurve = (F2mCurve)curve; if (f2mCurve.IsKoblitz) { return(ECAlgorithms.ValidatePoint(P.Multiply(a).Add(Q.Multiply(b)))); } } GlvEndomorphism glvEndomorphism = curve.GetEndomorphism() as GlvEndomorphism; if (glvEndomorphism != null) { return(ECAlgorithms.ValidatePoint(ECAlgorithms.ImplSumOfMultipliesGlv(new ECPoint[] { P, Q }, new BigInteger[] { a, b }, glvEndomorphism))); } return(ECAlgorithms.ValidatePoint(ECAlgorithms.ImplShamirsTrickWNaf(P, a, Q, b))); }
public GlvMultiplier(ECCurve curve, GlvEndomorphism glvEndomorphism) { if (curve == null || curve.Order == null) throw new ArgumentException("Need curve with known group order", "curve"); this.curve = curve; this.glvEndomorphism = glvEndomorphism; }
public GlvMultiplier(ECCurve curve, GlvEndomorphism glvEndomorphism) { if (curve == null || curve.Order == null) { throw new ArgumentException("Need curve with known group order", "curve"); } this.curve = curve; this.glvEndomorphism = glvEndomorphism; }
protected virtual ECMultiplier CreateDefaultMultiplier() { GlvEndomorphism glvEndomorphism = this.m_endomorphism as GlvEndomorphism; if (glvEndomorphism != null) { return(new GlvMultiplier(this, glvEndomorphism)); } return(new WNafL2RMultiplier()); }
public GlvMultiplier(ECCurve curve, GlvEndomorphism glvEndomorphism) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (curve == null || curve.Order == null) { throw new ArgumentException("Need curve with known group order", "curve"); } this.curve = curve; this.glvEndomorphism = glvEndomorphism; }
public static ECPoint SumOfTwoMultiplies(ECPoint P, BigInteger a, ECPoint Q, BigInteger b) { ECCurve c = P.Curve; Q = ImportPoint(c, Q); AbstractF2mCurve curve2 = c as AbstractF2mCurve; if ((curve2 != null) && curve2.IsKoblitz) { return(ValidatePoint(P.Multiply(a).Add(Q.Multiply(b)))); } GlvEndomorphism glvEndomorphism = c.GetEndomorphism() as GlvEndomorphism; if (glvEndomorphism != null) { ECPoint[] ps = new ECPoint[] { P, Q }; BigInteger[] ks = new BigInteger[] { a, b }; return(ValidatePoint(ImplSumOfMultipliesGlv(ps, ks, glvEndomorphism))); } return(ValidatePoint(ImplShamirsTrickWNaf(P, a, Q, b))); }
public static ECPoint SumOfMultiplies(ECPoint[] ps, BigInteger[] ks) { if (ps == null || ks == null || ps.Length != ks.Length || ps.Length < 1) { throw new ArgumentException("point and scalar arrays should be non-null, and of equal, non-zero, length"); } int count = ps.Length; switch (count) { case 1: return(ps[0].Multiply(ks[0])); case 2: return(SumOfTwoMultiplies(ps[0], ks[0], ps[1], ks[1])); default: break; } ECPoint p = ps[0]; ECCurve c = p.Curve; ECPoint[] imported = new ECPoint[count]; imported[0] = p; for (int i = 1; i < count; ++i) { imported[i] = ImportPoint(c, ps[i]); } GlvEndomorphism glvEndomorphism = c.GetEndomorphism() as GlvEndomorphism; if (glvEndomorphism != null) { return(ImplCheckResult(ImplSumOfMultipliesGlv(imported, ks, glvEndomorphism))); } return(ImplCheckResult(ImplSumOfMultiplies(imported, ks))); }
internal static ECPoint ImplSumOfMultipliesGlv(ECPoint[] ps, BigInteger[] ks, GlvEndomorphism glvEndomorphism) { BigInteger order = ps[0].Curve.Order; int length = ps.Length; BigInteger[] integerArray = new BigInteger[length << 1]; int index = 0; int num3 = 0; while (index < length) { BigInteger[] integerArray2 = glvEndomorphism.DecomposeScalar(ks[index].Mod(order)); integerArray[num3++] = integerArray2[0]; integerArray[num3++] = integerArray2[1]; index++; } ECPointMap pointMap = glvEndomorphism.PointMap; if (glvEndomorphism.HasEfficientPointMap) { return(ImplSumOfMultiplies(ps, pointMap, integerArray)); } ECPoint[] pointArray = new ECPoint[length << 1]; int num4 = 0; int num5 = 0; while (num4 < length) { ECPoint p = ps[num4]; ECPoint point2 = pointMap.Map(p); pointArray[num5++] = p; pointArray[num5++] = point2; num4++; } return(ImplSumOfMultiplies(pointArray, integerArray)); }
internal static ECPoint ImplSumOfMultipliesGlv(ECPoint[] ps, BigInteger[] ks, GlvEndomorphism glvEndomorphism) { BigInteger n = ps[0].Curve.Order; int len = ps.Length; BigInteger[] abs = new BigInteger[len << 1]; for (int i = 0, j = 0; i < len; ++i) { BigInteger[] ab = glvEndomorphism.DecomposeScalar(ks[i].Mod(n)); abs[j++] = ab[0]; abs[j++] = ab[1]; } ECPointMap pointMap = glvEndomorphism.PointMap; if (glvEndomorphism.HasEfficientPointMap) { return ECAlgorithms.ImplSumOfMultiplies(ps, pointMap, abs); } ECPoint[] pqs = new ECPoint[len << 1]; for (int i = 0, j = 0; i < len; ++i) { ECPoint p = ps[i], q = pointMap.Map(p); pqs[j++] = p; pqs[j++] = q; } return ECAlgorithms.ImplSumOfMultiplies(pqs, abs); }
internal static ECPoint ImplSumOfMultipliesGlv(ECPoint[] ps, BigInteger[] ks, GlvEndomorphism glvEndomorphism) { BigInteger n = ps[0].Curve.Order; int len = ps.Length; BigInteger[] abs = new BigInteger[len << 1]; for (int i = 0, j = 0; i < len; ++i) { BigInteger[] ab = glvEndomorphism.DecomposeScalar(ks[i].Mod(n)); abs[j++] = ab[0]; abs[j++] = ab[1]; } if (glvEndomorphism.HasEfficientPointMap) { return(ImplSumOfMultiplies(glvEndomorphism, ps, abs)); } ECPoint[] pqs = new ECPoint[len << 1]; for (int i = 0, j = 0; i < len; ++i) { ECPoint p = ps[i]; ECPoint q = EndoUtilities.MapPoint(glvEndomorphism, p); pqs[j++] = p; pqs[j++] = q; } return(ImplSumOfMultiplies(pqs, abs)); }