Thanks for your code, I understood. In case I want to shift right, I write the code like that:
Code:
void shiftright(uint64_t *x)
{
int i;
unsigned char a,b=0;
b=x[0]&1;
for (i=0;i<20;++i){
a=x[i]&1;
x[i]=x[i]>>1;
if (i!=0) if(b) x[i]|=1ULL<<63;
b=a;
}
}
And my mul function:
Code:
for (i=0;i<20;i++) c[i]=0ULL;
for (i=0;i<1279;i++){
if(a1[0]&1) for(j=0;j<20;j++) c[j]^=b1[j]; //if the bit of smallest power is 1
k=(b1[19] & (1ULL<<63)); //get the bit of largest power of b1
shiftleft(b1);
if(k) //if the bit of largest power is 1
for(j=0;j<20;j++) b1[j]^=f[j];
shiftright(a1);
}
if (c[19] & (1ULL<<63))
for(j=0;j<20;j++) c[j]^=f[j];
I still don't get the expected outcome. Did I miss something?