Skip to content

Commit

Permalink
Set next to most significant limb to zero so second discrete logarith…
Browse files Browse the repository at this point in the history
…m calculation does not fail
  • Loading branch information
alpertron committed Jul 12, 2018
1 parent a8e731c commit 01df53c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dilog.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void DiscreteLogarithm(void)
{
CompressBigInteger(nbrToFactor, &modulus);
Bin2Dec(modulus.limbs, tofactorDec, modulus.nbrLimbs, groupLen);
factor(&modulus, nbrToFactor, factorsMod, astFactorsMod, NULL);
factor(&modulus, nbrToFactor, factorsMod, astFactorsMod);
NbrFactorsMod = astFactorsMod[0].multiplicity;
}
intToBigInteger(&DiscreteLog, 0); // DiscreteLog <- 0
Expand Down Expand Up @@ -244,7 +244,7 @@ void DiscreteLogarithm(void)
groupOrder.limbs[0].x--;
showText("Computing discrete logarithm...");
CompressBigInteger(nbrToFactor, &groupOrder);
factor(&groupOrder, nbrToFactor, factorsGO, astFactorsGO, NULL); // factor groupOrder.
factor(&groupOrder, nbrToFactor, factorsGO, astFactorsGO); // factor groupOrder.
NbrFactors = astFactorsGO[0].multiplicity;
NumberLength = *ptrPrime;
UncompressBigInteger(ptrPrime, &mod);
Expand Down Expand Up @@ -284,6 +284,7 @@ void DiscreteLogarithm(void)
{
NumberLength = *astFactorsGO[indexBase + 1].ptrFactor;
UncompressBigInteger(astFactorsGO[indexBase + 1].ptrFactor, &subGroupOrder);
subGroupOrder.limbs[subGroupOrder.nbrLimbs].x = 0;
strcpy(textExp, "Computing discrete logarithm in subgroup of ");
Bin2Dec(subGroupOrder.limbs, textExp + strlen(textExp), subGroupOrder.nbrLimbs, groupLen);
ptr = textExp + strlen(textExp);
Expand Down

0 comments on commit 01df53c

Please sign in to comment.