コード例 #1
0
        /**
         * return a sqrt root - the routine verifies that the calculation returns the right value - if
         * none exists it returns null.
         */
        public override ECFieldElement Sqrt()
        {
            // Raise this element to the exponent 2^519

            uint[] x1 = this.x;
            if (Nat.IsZero(17, x1) || Nat.IsOne(17, x1))
            {
                return(this);
            }

            uint[] t1 = Nat.Create(17);
            uint[] t2 = Nat.Create(17);

            SecP521R1Field.SquareN(x1, 519, t1);
            SecP521R1Field.Square(t1, t2);

            return(Nat.Eq(17, x1, t2) ? new SecP521R1FieldElement(t1) : null);
        }