public static GetLucas ( sbyte mu, int k, bool doV ) : BigInteger[] | ||
mu | sbyte | |
k | int | |
doV | bool | |
Результат | BigInteger[] |
public static BigInteger[] GetSi(AbstractF2mCurve curve) { if (!curve.IsKoblitz) { throw new ArgumentException("si is defined for Koblitz curves only"); } int fieldSize = curve.FieldSize; int intValue = curve.A.ToBigInteger().IntValue; sbyte mu = Tnaf.GetMu(intValue); int shiftsForCofactor = Tnaf.GetShiftsForCofactor(curve.Cofactor); int k = fieldSize + 3 - intValue; BigInteger[] lucas = Tnaf.GetLucas(mu, k, false); if (mu == 1) { lucas[0] = lucas[0].Negate(); lucas[1] = lucas[1].Negate(); } BigInteger bigInteger = BigInteger.One.Add(lucas[1]).ShiftRight(shiftsForCofactor); BigInteger bigInteger2 = BigInteger.One.Add(lucas[0]).ShiftRight(shiftsForCofactor).Negate(); return(new BigInteger[] { bigInteger, bigInteger2 }); }
public static BigInteger GetTw(sbyte mu, int w) { if (w != 4) { BigInteger[] lucas = Tnaf.GetLucas(mu, w, false); BigInteger m = BigInteger.Zero.SetBit(w); BigInteger val = lucas[1].ModInverse(m); return(BigInteger.Two.Multiply(lucas[0]).Multiply(val).Mod(m)); } if (mu == 1) { return(BigInteger.ValueOf(6L)); } return(BigInteger.ValueOf(10L)); }
public static BigInteger[] GetSi(int fieldSize, int curveA, BigInteger cofactor) { sbyte mu = Tnaf.GetMu(curveA); int shiftsForCofactor = Tnaf.GetShiftsForCofactor(cofactor); int k = fieldSize + 3 - curveA; BigInteger[] lucas = Tnaf.GetLucas(mu, k, false); if (mu == 1) { lucas[0] = lucas[0].Negate(); lucas[1] = lucas[1].Negate(); } BigInteger bigInteger = BigInteger.One.Add(lucas[1]).ShiftRight(shiftsForCofactor); BigInteger bigInteger2 = BigInteger.One.Add(lucas[0]).ShiftRight(shiftsForCofactor).Negate(); return(new BigInteger[] { bigInteger, bigInteger2 }); }
public static ZTauElement PartModReduction(BigInteger k, int m, sbyte a, BigInteger[] s, sbyte mu, sbyte c) { BigInteger bigInteger; if (mu == 1) { bigInteger = s[0].Add(s[1]); } else { bigInteger = s[0].Subtract(s[1]); } BigInteger[] lucas = Tnaf.GetLucas(mu, m, true); BigInteger vm = lucas[1]; SimpleBigDecimal lambda = Tnaf.ApproximateDivisionByN(k, s[0], vm, a, m, (int)c); SimpleBigDecimal lambda2 = Tnaf.ApproximateDivisionByN(k, s[1], vm, a, m, (int)c); ZTauElement zTauElement = Tnaf.Round(lambda, lambda2, mu); BigInteger u = k.Subtract(bigInteger.Multiply(zTauElement.u)).Subtract(BigInteger.ValueOf(2L).Multiply(s[1]).Multiply(zTauElement.v)); BigInteger v = s[1].Multiply(zTauElement.u).Subtract(s[0].Multiply(zTauElement.v)); return(new ZTauElement(u, v)); }