From 68a06f46aed89831a74a0d8355956398450da49e Mon Sep 17 00:00:00 2001 From: filifa Date: Thu, 11 Dec 2025 23:49:34 -0500 Subject: [PATCH] reorder conditions --- modules/math.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/math.js b/modules/math.js index b3bbfcb..4add6a1 100644 --- a/modules/math.js +++ b/modules/math.js @@ -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); }