椭圆曲线之GF(P)上的点,R+P,2P的CPP实现
将运算过程中得到的负数转换成整数
int RemoveMinus(int num, int p)
{
while (num < 0)
{
num += p;
}
return num;
}
取模运算(注意要考虑对分数取余的情况)
int getMod(int fz, int fm, int p)
{
int temp;
for (int i = 0; i < p; i++)
if ((fm * i) % p == fz % p)
{
temp = i;
break;
}
return temp;
}
获得GF(P)上椭圆曲线的点
void getPoint(int p, int a, int b)
{
for (int i = 0; i < p; i++)
{
int x = i, y;
int temp = pow(x, 3) + x + 1;
int flag = 0;
for (int j = 0; j < p; j++)
{
int temp1 = pow(j, 2);
if (temp1 % p == temp % p)
{
temp = pow(j, 2);
x = i;
flag = 1;
break;
}
}
if (flag == 1)
{
cout << "(" << x << "," << sqrt(temp) << ")";
if (