/** Tests the calculate method of SquareRootModuloP */ public void testCalculate() { // the prime number BigInteger prime = new BigInteger("401"); FiniteFieldPrime field = new FiniteFieldPrime(prime); // the value to find the square root of (modulo p) BigInteger value = new BigInteger("186"); // the square root finder SquareRootModuloP squareRoot = new SquareRootModuloP(field); BigInteger result = squareRoot.calculate(value); // the expected result Element expected = field.element(new BigInteger("304")); // the tests assertTrue(expected.equals(result)); prime = new BigInteger("2081"); field = new FiniteFieldPrime(prime); value = new BigInteger("302"); squareRoot = new SquareRootModuloP(field); result = squareRoot.calculate(value); expected = field.element(new BigInteger("1292")); assertTrue(expected.equals(result)); }
public void testGet() { BigInteger a1 = new BigInteger("7"); BigInteger a2 = new BigInteger("2"); BigInteger a3 = new BigInteger("91"); BigInteger a4 = new BigInteger("12"); BigInteger a6 = new BigInteger("54"); FiniteFieldPrime field = new FiniteFieldPrime(new BigInteger("93")); CubicCurve curve = new CubicCurve(a1, a2, a3, a4, a6, field); assertTrue(curve != null); assertTrue(a1.compareTo(curve.a1()) == 0 && a1 != curve.a1()); assertTrue(a2.compareTo(curve.a2()) == 0 && a2 != curve.a2()); assertTrue(a3.compareTo(curve.a3()) == 0 && a3 != curve.a3()); assertTrue(a4.compareTo(curve.a4()) == 0 && a4 != curve.a4()); assertTrue(a6.compareTo(curve.a6()) == 0 && a6 != curve.a6()); assertTrue(field.equals(curve.getField()) && field != curve.getField()); }