mod the input
This commit is contained in:
parent
3f7519bed4
commit
f38c0f5063
|
|
@ -165,6 +165,11 @@ function modsqrt(n, modulus) {
|
|||
|
||||
// TODO: add special case for modulus = 3 (mod 4)
|
||||
|
||||
n %= modulus;
|
||||
if (n < 0n) {
|
||||
n += modulus;
|
||||
}
|
||||
|
||||
if (n % modulus === 0n) {
|
||||
return 0n;
|
||||
} else if (legendreSymbol(n, modulus) !== 1n) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue