reorder conditions
This commit is contained in:
@@ -170,10 +170,10 @@ function modsqrt(n, modulus) {
|
||||
|
||||
if (n % modulus === 0n) {
|
||||
return 0n;
|
||||
} else if (legendreSymbol(n, modulus) !== 1n) {
|
||||
throw new Error("radicand is not a quadratic residue of the modulus");
|
||||
} else if (modulus === 2n) {
|
||||
return n % 2n;
|
||||
} else if (legendreSymbol(n, modulus) !== 1n) {
|
||||
throw new Error("radicand is not a quadratic residue of the modulus");
|
||||
} else if (modulus % 4n === 3n) {
|
||||
return modpow(n, (modulus+1n)/4n, modulus);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user