Post
Topic
Board Development & Technical Discussion
Re: Pollard's kangaroo ECDLP solver
by
NotATether
on 05/11/2021, 16:35:40 UTC
Hello, thank you to everyone who contributed to this project.
I want to try something and I need ModPow function for Int type.

All Mod functions use P.

Can a faster version be made for b=2?

I want to calculate 2 ^ e % m

For int type like this:

Code:
int ModPow(int b, int e, int m)
{
int result = 1;
if (1 & e)
result = b;
while (1) {
if (!e) break;
e >>= 1;
b = (b * b) % m;//ModMul
if (e & 1)
result = (result * b) % m;//ModMul
}
return result;
}


There is not one that I know of. You could've been able to replace the (b*b) with b << (b >> 1) which uses only bitwise operators, and other basic bitwise optimizations in other statements, if it wasn't for the presence of the possibly odd modulus n.