Loops through the integer bit per bit, if a bit is 1 then x is added to the result. Looping through the multiplier in this manner allows us to use as many point doubling operations as possible. No reason to say 5P=P+P+P+P+P, when you might as well just use 5P=2(2P)+P.
This is not the most effecient method of point multiplication, but it's faster than P+P+P+... which is not computational feasiable.
*/
intbits=mpz_sizeinbase(multiplier,2);
unsignedlongintbit=0;
while(bit<=bits)
{
if(mpz_tstbit(multiplier,bit))
{
point_addition(t,x,R,curve);
point_copy(R,t);
}
point_doubling(t,x,curve);
point_copy(x,t);
bit++;
}
//Release temporary variables
point_clear(x);
point_clear(t);
}
}
/*Decompress a point from hexadecimal representation
*This function is implemented as specified in SEC 1: Elliptic Curve Cryptography, section 2.3.4.*/