test_class.declarator: modulus = new BigInteger("113")
test_class.modifier: private
test_class.original_string: private BigInteger modulus = new BigInteger("113");
test_class.type: BigInteger
test_class.var_name: modulus
test_class.file: core/src/test/java/dk/alexandra/fresco/framework/util/TestMathUtils.java
test_class.identifier: TestMathUtils
test_case.body: @Test(expected = IllegalArgumentException.class)
    public void testModularSqrtNoSqrt() {
      MathUtils.modularSqrt(new BigInteger("23"), modulus);
    }
test_case.class_method_signature: TestMathUtils.testModularSqrtNoSqrt()
test_case.full_signature: @Test(expected = IllegalArgumentException.class) public void testModularSqrtNoSqrt()
test_case.identifier: testModularSqrtNoSqrt
test_case.invocations: modularSqrt
test_case.modifiers: @Test(expected = IllegalArgumentException.class) public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testModularSqrtNoSqrt()
focal_class.declarator: TWO = BigInteger.valueOf(2)
focal_class.modifier: private static final
focal_class.original_string: private static final BigInteger TWO = BigInteger.valueOf(2);
focal_class.type: BigInteger
focal_class.var_name: TWO
focal_class.file: core/src/main/java/dk/alexandra/fresco/framework/util/MathUtils.java
focal_class.identifier: MathUtils
focal_class.class_method_signature: MathUtils.MathUtils()
focal_class.full_signature: private  MathUtils()
focal_class.identifier: MathUtils
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.signature:  MathUtils()
focal_class.class_method_signature: MathUtils.isQuadraticResidue(BigInteger value, BigInteger modulus)
focal_class.full_signature: public static boolean isQuadraticResidue(BigInteger value, BigInteger modulus)
focal_class.identifier: isQuadraticResidue
focal_class.modifiers: public static
focal_class.parameters: (BigInteger value, BigInteger modulus)
focal_class.return: boolean
focal_class.signature: boolean isQuadraticResidue(BigInteger value, BigInteger modulus)
focal_class.class_method_signature: MathUtils.modularSqrt(BigInteger value, BigInteger modulus)
focal_class.full_signature: public static BigInteger modularSqrt(BigInteger value, BigInteger modulus)
focal_class.identifier: modularSqrt
focal_class.modifiers: public static
focal_class.parameters: (BigInteger value, BigInteger modulus)
focal_class.return: BigInteger
focal_class.signature: BigInteger modularSqrt(BigInteger value, BigInteger modulus)
focal_class.class_method_signature: MathUtils.sum(List<BigInteger> summands, BigInteger modulus)
focal_class.full_signature: public static BigInteger sum(List<BigInteger> summands, BigInteger modulus)
focal_class.identifier: sum
focal_class.modifiers: public static
focal_class.parameters: (List<BigInteger> summands, BigInteger modulus)
focal_class.return: BigInteger
focal_class.signature: BigInteger sum(List<BigInteger> summands, BigInteger modulus)
focal_class.class_method_signature: MathUtils.getNonQuadraticResidue(BigInteger modulus)
focal_class.full_signature: private static BigInteger getNonQuadraticResidue(BigInteger modulus)
focal_class.identifier: getNonQuadraticResidue
focal_class.modifiers: private static
focal_class.parameters: (BigInteger modulus)
focal_class.return: BigInteger
focal_class.signature: BigInteger getNonQuadraticResidue(BigInteger modulus)
focal_class.class_method_signature: MathUtils.expressAsProductOfPowerOfTwo(BigInteger value)
focal_class.full_signature: private static Pair<BigInteger, Integer> expressAsProductOfPowerOfTwo(BigInteger value)
focal_class.identifier: expressAsProductOfPowerOfTwo
focal_class.modifiers: private static
focal_class.parameters: (BigInteger value)
focal_class.return: Pair<BigInteger, Integer>
focal_class.signature: Pair<BigInteger, Integer> expressAsProductOfPowerOfTwo(BigInteger value)
focal_method.body: public static BigInteger modularSqrt(BigInteger value, BigInteger modulus) {
      // check if square root exists
      if (!isQuadraticResidue(value, modulus)) {
        throw new IllegalArgumentException("Value has no square root in field");
      }
  
      // find q and s such that (p - 1) = q * 2^s
      Pair<BigInteger, Integer> factors = expressAsProductOfPowerOfTwo(
          modulus.subtract(BigInteger.ONE));
      BigInteger q = factors.getFirst();
      int s = factors.getSecond();
  
      // find non-quadratic residue for field
      BigInteger z = getNonQuadraticResidue(modulus);
  
      int m = s;
      BigInteger c = z.modPow(q, modulus);
      BigInteger t = value.modPow(q, modulus);
      BigInteger r = value.modPow(q.add(BigInteger.ONE).divide(TWO), modulus);
  
      while (!t.equals(BigInteger.ONE)) {
        int i = 0;
        BigInteger power = t;
        while (!power.equals(BigInteger.ONE)) {
          power = power.pow(2).mod(modulus);
          i++;
        }
        BigInteger exp = TWO.pow(m - i - 1).mod(modulus);
        BigInteger b = c.modPow(exp, modulus);
  
        m = i;
        c = b.pow(2).mod(modulus);
        t = t.multiply(c).mod(modulus);
        r = r.multiply(b).mod(modulus);
      }
      return r;
    }
focal_method.class_method_signature: MathUtils.modularSqrt(BigInteger value, BigInteger modulus)
focal_method.full_signature: public static BigInteger modularSqrt(BigInteger value, BigInteger modulus)
focal_method.identifier: modularSqrt
focal_method.invocations: isQuadraticResidue expressAsProductOfPowerOfTwo subtract getFirst getSecond getNonQuadraticResidue modPow modPow modPow divide add equals equals mod pow mod pow modPow mod pow mod multiply mod multiply
focal_method.modifiers: public static
focal_method.parameters: (BigInteger value, BigInteger modulus)
focal_method.return: BigInteger
focal_method.signature: BigInteger modularSqrt(BigInteger value, BigInteger modulus)