The Lucas V algorithm calculates the Ve(P,1) modulo N value
of the Lucas recursion; for instance, the eth value of the Lucas
function modulo N. The algorithm was independently proposed by Postl
(see "Fast Evaluation of Dickson Polynomials," by H. Postl,
Contributions to General Algebra, Volume 6, 1988) and later by Yen
and Laih "Fast Algorithms for the LUC Digital Signature
Computation," by S.M. Yen and C.S. Laih, IEEE Proceedings in
Computational Digital Technology, Volume 142, 1995). This C++
implementation was written by Wei Dai (http://www.eskimo.co/~weidai/lucas.html).
Integer Lucas Integer Lucas (const Integer &e,
const Integer &P, const Integer &N)
{
unsigned i = e.BitCount();
if (i==0)
return 2;
Integer v=P, v1=(P*P-2)%N;
i--;
while (i--)
{
if (e(i)) //if ith bit of e is one
{
v = (v*v1-P)%N;
v1=(v1*v1-2)%N;
}
else
{
v1=(v*v1-P)%N;
v=(v*v-2)%N;
}
}
return v;
}
Example 5: Lucas V algorithm.
Back to Article