MathUtils { public static boolean isQuadraticResidue(BigInteger value, BigInteger modulus) { BigInteger res = value .modPow(modulus.subtract(BigInteger.ONE).shiftRight(1), modulus); return res.equals(BigInteger.ONE); } private  MathUtils(); static boolean isQuadraticResidue(BigInteger value, BigInteger modulus); static BigInteger modularSqrt(BigInteger value, BigInteger modulus); static BigInteger sum(List<BigInteger> summands, BigInteger modulus);  }
@Test public void testIsQuadraticResidue() { assertEquals(true, MathUtils.isQuadraticResidue(new BigInteger("2"), modulus)); assertEquals(false, MathUtils.isQuadraticResidue(new BigInteger("23"), modulus)); }