9 NAMESPACE_BEGIN(CryptoPP)
19 assert(pbits > qbits);
29 bool qFound = q.Randomize(rng, minQ, maxQ, Integer::PRIME, 7, 12);
31 bool solutionsExist = SolveModularQuadraticEquation(r1, r2, 1, -1, 1, q);
32 assert(solutionsExist);
33 }
while (!p.Randomize(rng, minP, maxP, Integer::PRIME, CRT(rng.
GenerateBit()?r1:r2, q, 2, 3, EuclideanMultiplicativeInverse(p, 3)), 3*q));
34 assert(((p.Squared() - p + 1) % q).IsZero());
43 t = XTR_Exponentiate(g, p+1, p);
46 g = XTR_Exponentiate(g, (p.Squared()-p+1)/q, p);
50 assert(XTR_Exponentiate(g, q, p) == three);
55 unsigned int bitCount = e.
BitCount();
60 unsigned int lowest1bit;
61 for (lowest1bit=0; e.
GetBit(lowest1bit) == 0; lowest1bit++) {}
66 GFP2Element S[5] = {gfp2.ConvertIn(3), c, gfp2.SpecialOperation1(c)};
70 for (i = e.
BitCount() - 1; i>lowest1bit; i--)
74 gfp2.RaiseToPthPower(S[0]);
75 gfp2.Accumulate(S[0], gfp2.SpecialOperation2(S[2], c, S[1]));
76 S[1] = gfp2.SpecialOperation1(S[1]);
77 S[2] = gfp2.SpecialOperation1(S[2]);
82 gfp2.RaiseToPthPower(S[2]);
83 gfp2.Accumulate(S[2], gfp2.SpecialOperation2(S[0], cp, S[1]));
84 S[1] = gfp2.SpecialOperation1(S[1]);
85 S[0] = gfp2.SpecialOperation1(S[0]);
92 S[1] = gfp2.SpecialOperation1(S[1]);
94 return gfp2.ConvertOut(S[1]);