You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when n is odd, your code is as below:
// odd case
// a(bc) mod n = ((a mod n)(bc mod n)) mod n
// --> bc mod n = ((b mod n)(c mod n)) mod n
// hMs: half Multiply single
long hMs = ((half % b) * (a % b)) % b;
return (int)((half * hMs) % b);
But I think 'long hMs = (half * (a % b)) % b;' is the right statement.
(a^(n/2) * a^(n/2) * a) mod b = ((a^(n/2) mod b) * ((a^(n/2) * a ) mod b)) mod b
= (half * (((a^(n/2) mod b) * (a mod b)) mod b) mod b
= (half * ((half * (a mod b)) mod b)) mod b
The text was updated successfully, but these errors were encountered:
when n is odd, your code is as below:
// odd case
// a(bc) mod n = ((a mod n)(bc mod n)) mod n
// --> bc mod n = ((b mod n)(c mod n)) mod n
// hMs: half Multiply single
long hMs = ((half % b) * (a % b)) % b;
return (int)((half * hMs) % b);
But I think 'long hMs = (half * (a % b)) % b;' is the right statement.
(a^(n/2) * a^(n/2) * a) mod b = ((a^(n/2) mod b) * ((a^(n/2) * a ) mod b)) mod b
= (half * (((a^(n/2) mod b) * (a mod b)) mod b) mod b
= (half * ((half * (a mod b)) mod b)) mod b
The text was updated successfully, but these errors were encountered: