我正在尝试计算 13 模 n 的平方根,其中:
n = p*q
n = 138885020192920482087634472213565258211
p = 9968252547389207681
q = 13932734903400492131
求 s mod n 的平方根意味着求一个 x,0 <= x < n, such that x2 = s mod n,或 x2 - s = 0 mod n。
我不知道该怎么做。我尝试使用欧拉定理、小费马定理和中国剩余定理。我不知道我是否错误地使用了这些方法,或者是否有其他方法可以解决这个问题。
import java.math.BigInteger;
public class Q1 {
public static void main(String args[]) {
String pHex = "8a5658e0b6843481";
String qHex = "c15b04936adf6c63";
//Convert to BigInteger
BigInteger p = new BigInteger(pHex, 16);
BigInteger q = new BigInteger(qHex, 16);
BigInteger n = p.multiply(q);
System.out.println("p = " + p);
System.out.println("q = " + q);
System.out.println("n = " + n);
//THESE VIDEOS ARE HELPFUL - https://www.youtube.com/watch?v=_6f0vMfBDLA - https://www.youtube.com/watch?v=dSIkv9U5WO8
//Eulers theorem
//x^phi(n) = 1 mod n
//s = sqrt(13) mod n
//s^2 = 13 mod n
//I HAVE NO CLUE
//I TRIED LITTLE FERMAT THEOREM - EULCID THEOREM - CHINESE REMAINDER THEOREM
//System.out.println(s);
//System.out.println(s.toString(16));
}
}