reorder conditions
This commit is contained in:
parent
f00597cabc
commit
68a06f46ae
|
|
@ -170,10 +170,10 @@ function modsqrt(n, modulus) {
|
||||||
|
|
||||||
if (n % modulus === 0n) {
|
if (n % modulus === 0n) {
|
||||||
return 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) {
|
} else if (modulus === 2n) {
|
||||||
return n % 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) {
|
} else if (modulus % 4n === 3n) {
|
||||||
return modpow(n, (modulus+1n)/4n, modulus);
|
return modpow(n, (modulus+1n)/4n, modulus);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue