public static void FirstStep(DLPInput input, BigInteger[] factorBase, ref List <List <BigInteger> > coefficients, ref List <BigInteger> constantTerms) { var rand = new BigIntegerRandom(); for (int i = 1; i < input.order; i++) { //var k = rand.Next(0, input.order); //while (k == 0) //{ // k = rand.Next(0, input.order); //} var k = input.order - i; var temp = BigInteger.ModPow(input.g, k, input.p); var factorBaseFactorizationExponents = Factorization.GetFactorBaseFactorizationExponents(temp, factorBase); if (factorBaseFactorizationExponents != null) { coefficients.Add(factorBaseFactorizationExponents.ToList()); constantTerms.Add(k); //bool isLinearIndependent = GaussianElimination.IsLinearIndependent(coefficients, input.order); //if (!isLinearIndependent) // coefficients.RemoveAt(coefficients.Count - 1); //else // constantTerms.Add(k); } //if (coefficients.Count == factorBase.Length) if (coefficients.Count == LinearEquatationsCount) { return; } } }
public static BigInteger ThirdStep(DLPInput input, BigInteger[] factorBase, BigInteger[] factorBaseLogs) { for (BigInteger k = 1; k < input.order; k++) { var temp = (input.h * BigInteger.ModPow(input.g, k, input.p)).ModPositive(input.p); var factorBaseFactorizationExponents = Factorization.GetFactorBaseFactorizationExponents(temp, factorBase); if (factorBaseFactorizationExponents != null) { BigInteger x = 0; int i = 0; foreach (var log in factorBaseLogs) { x += log * factorBaseFactorizationExponents[i++]; } x -= k; return(x.ModPositive(input.order)); } } return(-1); }