}
        public ECFieldElement sqrt()        {            if (!q.testBit(0))            {                throw new RuntimeException("not done yet");            }            // p mod 4 == 3            if (q.testBit(1))            {                // z = g^(u+1) + p, p = 4u + 3                ECFieldElement z = new Fp(q, x.modPow(q.shiftRight(2).add(ONE), q));                return z.square().equals(this) ? z : null;            }            // p mod 4 == 1            BigInteger qMinusOne = q.subtract(ECConstants.ONE);            BigInteger legendreExponent = qMinusOne.shiftRight(1);            if (!(x.modPow(legendreExponent, q).equals(ECConstants.ONE)))                return null;            BigInteger u = qMinusOne.shiftRight(2);            BigInteger k = u.shiftLeft(1).add(ECConstants.ONE);            BigInteger Q = this.x;            BigInteger fourQ = Q.shiftLeft(2).mod(q);            BigInteger U, V;            Random rand = new Random();            do            {                BigInteger P;                do                {                    P = new BigInteger(q.bitLength(), rand);                }                while (P.compareTo(q) >= 0                    || !(P.multiply(P).subtract(fourQ).modPow(legendreExponent, q).equals(qMinusOne)));                BigInteger[] result = lucasSequence(q, P, Q, k);                U = result[0];                V = result[1];                if (V.multiply(V).mod(q).equals(fourQ))                {                    // Integer division by 2, mod q                    if (V.testBit(0))                    {                        V = V.add(q);                    }                    V = V.shiftRight(1);                    //assert V.multiply(V).mod(q).equals(x);                    return new ECFieldElement.Fp(q, V);                }            }            while (U.equals(ECConstants.ONE) || U.equals(qMinusOne));            return null;//            BigInteger qMinusOne = q.subtract(ECConstants.ONE);//            BigInteger legendreExponent = qMinusOne.shiftRight(1); //divide(ECConstants.TWO);//            if (!(x.modPow(legendreExponent, q).equals(ECConstants.ONE)))//            {//                return null;//            }////            Random rand = new Random();//            BigInteger fourX = x.shiftLeft(2);////            BigInteger r;//            do//            {//                r = new BigInteger(q.bitLength(), rand);//            }//            while (r.compareTo(q) >= 0//                || !(r.multiply(r).subtract(fourX).modPow(legendreExponent, q).equals(qMinusOne)));////            BigInteger n1 = qMinusOne.shiftRight(2); //.divide(ECConstants.FOUR);//            BigInteger n2 = n1.add(ECConstants.ONE); //q.add(ECConstants.THREE).divide(ECConstants.FOUR);////            BigInteger wOne = WOne(r, x, q);//            BigInteger wSum = W(n1, wOne, q).add(W(n2, wOne, q)).mod(q);//            BigInteger twoR = r.shiftLeft(1); //ECConstants.TWO.multiply(r);////            BigInteger root = twoR.modPow(q.subtract(ECConstants.TWO), q)//                .multiply(x).mod(q)//                .multiply(wSum).mod(q);////            return new Fp(q, root);        }