static void EvaluateQuadraticPoly(BigInteger *pResult, BigInteger *pValue, int quad, int linear, int constant) { multadd(pResult, quad, pValue, linear); // Multiply result by value. (void)BigIntMultiply(pResult, pValue, pResult); addbigint(pResult, constant); }
static int ComputeDLogModSubGroupOrder(int indexBase, int indexExp, BigInteger *Exponent, BigInteger *subGroupOrder) { // Set tmpBase to 1 in Montgomery notation. memcpy(tmpBase.limbs, MontgomeryMultR1, NumberLength * sizeof(limb)); // Set Exponent to zero. Exponent->limbs[0].x = 0; Exponent->nbrLimbs = 1; Exponent->sign = SIGN_POSITIVE; for (;;) { if (TestBigNbrEqual(Exponent, subGroupOrder)) { // All exponents have been tried and logarithm has not been found, so go out. indicateCannotComputeLog(indexBase, indexExp); return 0; } if (!memcmp(tmpBase.limbs, powerPHMontg, NumberLength * sizeof(limb))) { // Logarithm for this subgroup has been found. Go out. return 1; } // Set tmpBase to next power. modmult(tmpBase.limbs, primRootPwr, tmpBase.limbs); // Set next exponent. addbigint(Exponent, 1); } }